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

Commit

Permalink
Adapt minimally to the possible absence of a repo
Browse files Browse the repository at this point in the history
Of the API methods, ListControllers is the only one for which a git
repo is optional; make it return a response with less information,
rather than an error, if the repo is not ready.

Some other methods either don't try to look at the repo (ListImages), in
which case no change is needed.

The remainder refer to the repo (usually because they want to write to
it), so must return an error. That will happen as things stand, since
attempting to clone the repo results in an error.
  • Loading branch information
squaremo committed Feb 26, 2018
1 parent b1ff4c6 commit 109f8fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ func (d *Daemon) ListServices(ctx context.Context, namespace string) ([]flux.Con
services, err = d.Manifests.ServicesWithPolicies(checkout.ManifestDir())
return err
})
if err != nil {
switch {
case err == git.ErrNotReady:
services = policy.ResourceMap{}
case err != nil:
return nil, errors.Wrap(err, "getting service policies")
}

Expand Down
2 changes: 1 addition & 1 deletion git/working.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func (r *Repo) Clone(ctx context.Context, conf Config) (*Checkout, error) {
upstream := r.Origin()
repoDir, err := r.workingClone(ctx, conf.Branch)
if err != nil {
return nil, CloningError(upstream.URL, err)
return nil, err
}

if err := config(ctx, repoDir, conf.UserName, conf.UserEmail); err != nil {
Expand Down

0 comments on commit 109f8fa

Please sign in to comment.