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

Correct mistaken assignment of loop var #1119

Merged
merged 1 commit into from
Jun 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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