From 60e82a40c1733cce2b2e407a5e9a7a06c08bbaa9 Mon Sep 17 00:00:00 2001 From: Elena Morozova Date: Fri, 5 Oct 2018 16:41:45 -0700 Subject: [PATCH] Add error checks --- cmd/fluxctl/release_cmd.go | 4 ++++ daemon/daemon.go | 8 +++++++- git/operations_test.go | 4 +++- remote/rpc/compat.go | 3 +++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/cmd/fluxctl/release_cmd.go b/cmd/fluxctl/release_cmd.go index 855a25803..1509eec47 100644 --- a/cmd/fluxctl/release_cmd.go +++ b/cmd/fluxctl/release_cmd.go @@ -172,6 +172,10 @@ func (opts *controllerReleaseOpts) RunE(cmd *cobra.Command, args []string) error Cause: opts.cause, Spec: spec, }) + if err != nil { + fmt.Fprintln(cmd.OutOrStderr(), err.Error()) + return nil + } opts.dryRun = false } diff --git a/daemon/daemon.go b/daemon/daemon.go index 840af3a93..b2180ab6b 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -14,6 +14,7 @@ import ( "github.com/weaveworks/flux" "github.com/weaveworks/flux/api" "github.com/weaveworks/flux/api/v10" + "github.com/weaveworks/flux/api/v11" "github.com/weaveworks/flux/api/v6" "github.com/weaveworks/flux/api/v9" "github.com/weaveworks/flux/cluster" @@ -27,7 +28,6 @@ import ( "github.com/weaveworks/flux/release" "github.com/weaveworks/flux/resource" "github.com/weaveworks/flux/update" - "github.com/weaveworks/flux/api/v11" ) const ( @@ -175,12 +175,18 @@ func (d *Daemon) ListImagesWithOptions(ctx context.Context, opts v10.ListImagesO var err error if opts.Spec == update.ResourceSpecAll { services, err = d.Cluster.AllControllers("") + if err != nil { + return nil, errors.Wrap(err, "getting all controllers") + } } else { id, err := opts.Spec.AsID() if err != nil { return nil, errors.Wrap(err, "treating service spec as ID") } services, err = d.Cluster.SomeControllers([]flux.ResourceID{id}) + if err != nil { + return nil, errors.Wrap(err, "getting some controllers") + } } resources, _, err := d.getResources(ctx) diff --git a/git/operations_test.go b/git/operations_test.go index 7abc6fa07..b1c31d4bf 100644 --- a/git/operations_test.go +++ b/git/operations_test.go @@ -201,7 +201,9 @@ func TestOnelinelog_WithGitpath(t *testing.T) { func TestCheckPush(t *testing.T) { upstreamDir, upstreamCleanup := testfiles.TempDir(t) defer upstreamCleanup() - err := createRepo(upstreamDir, []string{"config"}) + if err := createRepo(upstreamDir, []string{"config"}); err != nil { + t.Fatal(err) + } cloneDir, cloneCleanup := testfiles.TempDir(t) defer cloneCleanup() diff --git a/remote/rpc/compat.go b/remote/rpc/compat.go index 6d1797f43..70b6f4b8e 100644 --- a/remote/rpc/compat.go +++ b/remote/rpc/compat.go @@ -156,6 +156,9 @@ func listImagesWithOptions(ctx context.Context, client listImagesWithoutOptionsC ns, _, _ = resourceID.Components() } services, err := client.ListServices(ctx, ns) + if err != nil { + return statuses, err + } policyMap := map[flux.ResourceID]map[string]string{} for _, service := range services {