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

Commit

Permalink
Merge pull request #1119 from weaveworks/issue/1118-spurious-readonly
Browse files Browse the repository at this point in the history
Correct mistaken assignment of loop var
  • Loading branch information
squaremo authored Jun 4, 2018
2 parents 8a40734 + 4ba6a53 commit a83ef89
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,17 @@ func (d *Daemon) getPolicyResourceMap(ctx context.Context) (policy.ResourceMap,
return err
})

// Capture errors related to read-only repositories
// The reason something is missing from the map differs depending
// on the state of the git repo.
switch {
case err == git.ErrNotReady:
globalReadOnly = v6.ReadOnlyNotReady
case err == git.ErrNoConfig:
globalReadOnly = v6.ReadOnlyNoRepo
case err != nil:
return nil, globalReadOnly, errors.Wrap(err, "getting service policies")
default:
globalReadOnly = v6.ReadOnlyMissing
}

return services, globalReadOnly, nil
Expand All @@ -98,17 +101,18 @@ func (d *Daemon) ListServices(ctx context.Context, namespace string) ([]v6.Contr
return nil, errors.Wrap(err, "getting services from cluster")
}

policyResourceMap, readOnly, err := d.getPolicyResourceMap(ctx)
policyResourceMap, missingReason, err := d.getPolicyResourceMap(ctx)
if err != nil {
return nil, err
}

var res []v6.ControllerStatus
for _, service := range clusterServices {
readOnly := v6.ReadOnlyOK
policies, ok := policyResourceMap[service.ID]
switch {
case !ok:
readOnly = v6.ReadOnlyMissing
readOnly = missingReason
case service.IsSystem:
readOnly = v6.ReadOnlySystem
}
Expand Down

0 comments on commit a83ef89

Please sign in to comment.