Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
Rename resource method Policy() to Policies()
Browse files Browse the repository at this point in the history
  • Loading branch information
2opremio committed Feb 27, 2019
1 parent d76ecab commit 5d97bae
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cluster/kubernetes/sync.go
Expand Up @@ -60,7 +60,7 @@ func (c *Cluster) Sync(spec cluster.SyncSet) error {
csum := sha1.Sum(res.Bytes())
checkHex := hex.EncodeToString(csum[:])
checksums[id] = checkHex
if res.Policy().Has(policy.Ignore) {
if res.Policies().Has(policy.Ignore) {
logger.Log("info", "not applying resource; ignore annotation in file", "resource", res.ResourceID(), "source", res.Source())
continue
}
Expand Down
4 changes: 2 additions & 2 deletions daemon/daemon.go
Expand Up @@ -128,7 +128,7 @@ func (d *Daemon) ListServicesWithOptions(ctx context.Context, opts v11.ListServi
readOnly := v6.ReadOnlyOK
var policies policy.Set
if resource, ok := resources[service.ID.String()]; ok {
policies = resource.Policy()
policies = resource.Policies()
}
switch {
case policies == nil:
Expand Down Expand Up @@ -637,7 +637,7 @@ func getServiceContainers(service cluster.Controller, imageRepos update.ImageRep
imageRepo := c.Image.Name
var policies policy.Set
if resource != nil {
policies = resource.Policy()
policies = resource.Policies()
}
tagPattern := policy.GetTagPattern(policies, c.Name)

Expand Down
2 changes: 1 addition & 1 deletion daemon/daemon_test.go
Expand Up @@ -520,7 +520,7 @@ func TestDaemon_PolicyUpdate(t *testing.T) {
if err != nil {
t.Fatalf("Error: %s", err.Error())
}
return len(m[svc].Policy()) > 0
return len(m[svc].Policies()) > 0
}, "Waiting for new annotation")
}

Expand Down
4 changes: 2 additions & 2 deletions daemon/images.go
Expand Up @@ -44,7 +44,7 @@ func (d *Daemon) pollForNewImages(logger log.Logger) {
for _, service := range services {
var p policy.Set
if resource, ok := candidateServices[service.ID]; ok {
p = resource.Policy()
p = resource.Policies()
}
containers:
for _, container := range service.ContainersOrNil() {
Expand Down Expand Up @@ -106,7 +106,7 @@ func (d *Daemon) getAllowedAutomatedResources(ctx context.Context) (resources, e

result := map[flux.ResourceID]resource.Resource{}
for _, resource := range resources {
policies := resource.Policy()
policies := resource.Policies()
if policies.Has(policy.Automated) && !policies.Has(policy.Locked) && !policies.Has(policy.Ignore) {
result[resource.ResourceID()] = resource
}
Expand Down
2 changes: 1 addition & 1 deletion resource/resource.go
Expand Up @@ -9,7 +9,7 @@ import (
// For the minute we just care about
type Resource interface {
ResourceID() flux.ResourceID // name, to correlate with what's in the cluster
Policy() policy.Set // policy for this resource; e.g., whether it is locked, automated, ignored
Policies() policy.Set // policy for this resource; e.g., whether it is locked, automated, ignored
Source() string // where did this come from (informational)
Bytes() []byte // the definition, for sending to cluster.Sync
}
Expand Down
2 changes: 1 addition & 1 deletion update/filter.go
Expand Up @@ -82,7 +82,7 @@ type LockedFilter struct {
}

func (f *LockedFilter) Filter(u ControllerUpdate) ControllerResult {
if u.Resource.Policy().Has(policy.Locked) {
if u.Resource.Policies().Has(policy.Locked) {
return ControllerResult{
Status: ReleaseStatusSkipped,
Error: Locked,
Expand Down
2 changes: 1 addition & 1 deletion update/release_image.go
Expand Up @@ -229,7 +229,7 @@ func (s ReleaseImageSpec) calculateImageUpdates(rc ReleaseContext, candidates []
// Use the container's filter if the spec does not want to force release, or
// all images requested
if !s.Force || s.ImageSpec == ImageSpecLatest {
if pattern, ok := u.Resource.Policy().Get(policy.TagPrefix(container.Name)); ok {
if pattern, ok := u.Resource.Policies().Get(policy.TagPrefix(container.Name)); ok {
tagPattern = policy.NewPattern(pattern)
}
}
Expand Down

0 comments on commit 5d97bae

Please sign in to comment.