File tree 2 files changed +16
-6
lines changed
2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ type ConfigRefType string
30
30
const (
31
31
ConfigRefMap ConfigRefType = "configmap"
32
32
ConfigRefSecret ConfigRefType = "secret"
33
+
34
+ configTrackingDisabledAnnotationKey = "flagger.app/config-tracking"
33
35
)
34
36
35
37
// ConfigRef holds the reference to a tracked Kubernetes ConfigMap or Secret
@@ -52,12 +54,7 @@ func checksum(data interface{}) string {
52
54
}
53
55
54
56
func configIsDisabled (annotations map [string ]string ) bool {
55
- for k , v := range annotations {
56
- if k == "flagger.app/config-tracking" && strings .HasPrefix (v , "disable" ) {
57
- return true
58
- }
59
- }
60
- return false
57
+ return strings .HasPrefix (annotations [configTrackingDisabledAnnotationKey ], "disable" )
61
58
}
62
59
63
60
// getRefFromConfigMap transforms a Kubernetes ConfigMap into a ConfigRef
Original file line number Diff line number Diff line change @@ -10,6 +10,19 @@ import (
10
10
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
11
11
)
12
12
13
+ func TestConfigIsDisabled (t * testing.T ) {
14
+ for _ , c := range []struct {
15
+ annotations map [string ]string
16
+ exp bool
17
+ }{
18
+ {annotations : map [string ]string {configTrackingDisabledAnnotationKey : "disable" }, exp : true },
19
+ {annotations : map [string ]string {"app" : "disable" }, exp : false },
20
+ {annotations : map [string ]string {}, exp : false },
21
+ } {
22
+ assert .Equal (t , configIsDisabled (c .annotations ), c .exp )
23
+ }
24
+ }
25
+
13
26
func TestConfigTracker_ConfigMaps (t * testing.T ) {
14
27
t .Run ("deployment" , func (t * testing.T ) {
15
28
mocks := newDeploymentFixture ()
You can’t perform that action at this time.
0 commit comments