Browse Source

Rename resource method Policy() to Policies()

Alfonso Acosta 2 months ago
parent
commit
61227bbf15

+ 1
- 1
cluster/kubernetes/resource/resource.go View File

@@ -94,7 +94,7 @@ func PolicyFromAnnotations(annotations map[string]string) policy.Set {
94 94
 	return set
95 95
 }
96 96
 
97
-func (o baseObject) Policy() policy.Set {
97
+func (o baseObject) Policies() policy.Set {
98 98
 	return PolicyFromAnnotations(o.Meta.Annotations)
99 99
 }
100 100
 

+ 1
- 1
cluster/kubernetes/sync.go View File

@@ -60,7 +60,7 @@ func (c *Cluster) Sync(spec cluster.SyncSet) error {
60 60
 		csum := sha1.Sum(res.Bytes())
61 61
 		checkHex := hex.EncodeToString(csum[:])
62 62
 		checksums[id] = checkHex
63
-		if res.Policy().Has(policy.Ignore) {
63
+		if res.Policies().Has(policy.Ignore) {
64 64
 			logger.Log("info", "not applying resource; ignore annotation in file", "resource", res.ResourceID(), "source", res.Source())
65 65
 			continue
66 66
 		}

+ 2
- 2
daemon/daemon.go View File

@@ -128,7 +128,7 @@ func (d *Daemon) ListServicesWithOptions(ctx context.Context, opts v11.ListServi
128 128
 		readOnly := v6.ReadOnlyOK
129 129
 		var policies policy.Set
130 130
 		if resource, ok := resources[service.ID.String()]; ok {
131
-			policies = resource.Policy()
131
+			policies = resource.Policies()
132 132
 		}
133 133
 		switch {
134 134
 		case policies == nil:
@@ -637,7 +637,7 @@ func getServiceContainers(service cluster.Controller, imageRepos update.ImageRep
637 637
 		imageRepo := c.Image.Name
638 638
 		var policies policy.Set
639 639
 		if resource != nil {
640
-			policies = resource.Policy()
640
+			policies = resource.Policies()
641 641
 		}
642 642
 		tagPattern := policy.GetTagPattern(policies, c.Name)
643 643
 

+ 1
- 1
daemon/daemon_test.go View File

@@ -520,7 +520,7 @@ func TestDaemon_PolicyUpdate(t *testing.T) {
520 520
 		if err != nil {
521 521
 			t.Fatalf("Error: %s", err.Error())
522 522
 		}
523
-		return len(m[svc].Policy()) > 0
523
+		return len(m[svc].Policies()) > 0
524 524
 	}, "Waiting for new annotation")
525 525
 }
526 526
 

+ 2
- 2
daemon/images.go View File

@@ -44,7 +44,7 @@ func (d *Daemon) pollForNewImages(logger log.Logger) {
44 44
 	for _, service := range services {
45 45
 		var p policy.Set
46 46
 		if resource, ok := candidateServices[service.ID]; ok {
47
-			p = resource.Policy()
47
+			p = resource.Policies()
48 48
 		}
49 49
 	containers:
50 50
 		for _, container := range service.ContainersOrNil() {
@@ -106,7 +106,7 @@ func (d *Daemon) getAllowedAutomatedResources(ctx context.Context) (resources, e
106 106
 
107 107
 	result := map[flux.ResourceID]resource.Resource{}
108 108
 	for _, resource := range resources {
109
-		policies := resource.Policy()
109
+		policies := resource.Policies()
110 110
 		if policies.Has(policy.Automated) && !policies.Has(policy.Locked) && !policies.Has(policy.Ignore) {
111 111
 			result[resource.ResourceID()] = resource
112 112
 		}

+ 2
- 2
policy/policy_test.go View File

@@ -16,10 +16,10 @@ func TestJSON(t *testing.T) {
16 16
 	policy := boolPolicy.Set(LockedUser, "user@example.com")
17 17
 
18 18
 	if !(policy.Has(Ignore) && policy.Has(Locked)) {
19
-		t.Errorf("Policy did not include those added")
19
+		t.Errorf("Policies did not include those added")
20 20
 	}
21 21
 	if val, ok := policy.Get(LockedUser); !ok || val != "user@example.com" {
22
-		t.Errorf("Policy did not include policy that was set")
22
+		t.Errorf("Policies did not include policy that was set")
23 23
 	}
24 24
 
25 25
 	bs, err := json.Marshal(policy)

+ 1
- 1
resource/resource.go View File

@@ -9,7 +9,7 @@ import (
9 9
 // For the minute we just care about
10 10
 type Resource interface {
11 11
 	ResourceID() flux.ResourceID // name, to correlate with what's in the cluster
12
-	Policy() policy.Set          // policy for this resource; e.g., whether it is locked, automated, ignored
12
+	Policies() policy.Set        // policy for this resource; e.g., whether it is locked, automated, ignored
13 13
 	Source() string              // where did this come from (informational)
14 14
 	Bytes() []byte               // the definition, for sending to cluster.Sync
15 15
 }

+ 1
- 1
update/filter.go View File

@@ -82,7 +82,7 @@ type LockedFilter struct {
82 82
 }
83 83
 
84 84
 func (f *LockedFilter) Filter(u ControllerUpdate) ControllerResult {
85
-	if u.Resource.Policy().Has(policy.Locked) {
85
+	if u.Resource.Policies().Has(policy.Locked) {
86 86
 		return ControllerResult{
87 87
 			Status: ReleaseStatusSkipped,
88 88
 			Error:  Locked,

+ 1
- 1
update/release_image.go View File

@@ -229,7 +229,7 @@ func (s ReleaseImageSpec) calculateImageUpdates(rc ReleaseContext, candidates []
229 229
 			// Use the container's filter if the spec does not want to force release, or
230 230
 			// all images requested
231 231
 			if !s.Force || s.ImageSpec == ImageSpecLatest {
232
-				if pattern, ok := u.Resource.Policy().Get(policy.TagPrefix(container.Name)); ok {
232
+				if pattern, ok := u.Resource.Policies().Get(policy.TagPrefix(container.Name)); ok {
233 233
 					tagPattern = policy.NewPattern(pattern)
234 234
 				}
235 235
 			}

Loading…
Cancel
Save