You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by nf...@apache.org on 2019/11/12 17:26:36 UTC
[camel-k] branch master updated: Fix #1038: redeploy integration
when trait config changes
This is an automated email from the ASF dual-hosted git repository.
nferraro pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-k.git
The following commit(s) were added to refs/heads/master by this push:
new 2528e49 Fix #1038: redeploy integration when trait config changes
2528e49 is described below
commit 2528e491844101d7788323bf5212e7785906598e
Author: Nicola Ferraro <ni...@gmail.com>
AuthorDate: Tue Nov 12 00:31:05 2019 +0100
Fix #1038: redeploy integration when trait config changes
---
pkg/util/digest/digest.go | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/pkg/util/digest/digest.go b/pkg/util/digest/digest.go
index 2c1acf2..8790360 100644
--- a/pkg/util/digest/digest.go
+++ b/pkg/util/digest/digest.go
@@ -21,6 +21,7 @@ import (
"crypto/sha256"
"encoding/base64"
"math/rand"
+ "sort"
"strconv"
"github.com/apache/camel-k/pkg/apis/camel/v1alpha1"
@@ -70,6 +71,23 @@ func ComputeForIntegration(integration *v1alpha1.Integration) (string, error) {
}
}
+ // Integration traits
+ for _, name := range sortedTraitSpecMapKeys(integration.Spec.Traits) {
+ if _, err := hash.Write([]byte(name + "[")); err != nil {
+ return "", err
+ }
+ spec := integration.Spec.Traits[name]
+ for _, prop := range sortedStringMapKeys(spec.Configuration) {
+ val := spec.Configuration[prop]
+ if _, err := hash.Write([]byte(prop + "=" + val + ",")); err != nil {
+ return "", err
+ }
+ }
+ if _, err := hash.Write([]byte("]")); err != nil {
+ return "", err
+ }
+ }
+
// Add a letter at the beginning and use URL safe encoding
digest := "v" + base64.RawURLEncoding.EncodeToString(hash.Sum(nil))
return digest, nil
@@ -104,3 +122,21 @@ func ComputeForIntegrationKit(kit *v1alpha1.IntegrationKit) (string, error) {
func Random() string {
return "v" + strconv.FormatInt(rand.Int63(), 10)
}
+
+func sortedStringMapKeys(m map[string]string) []string {
+ res := make([]string, 0, len(m))
+ for k := range m {
+ res = append(res, k)
+ }
+ sort.Strings(res)
+ return res
+}
+
+func sortedTraitSpecMapKeys(m map[string]v1alpha1.TraitSpec) []string {
+ res := make([]string, 0, len(m))
+ for k := range m {
+ res = append(res, k)
+ }
+ sort.Strings(res)
+ return res
+}