From 3d69121433bc3dfc1b42ae4d679b860154b20e68 Mon Sep 17 00:00:00 2001 From: Nassim 'Nass' Eddequiouaq Date: Fri, 9 Mar 2018 20:26:43 +0100 Subject: [PATCH] Fix comment and misc code issues Signed-off-by: Nassim 'Nass' Eddequiouaq (cherry picked from commit 8c3d0b93d631f948376a81c7baecc6dad88ce248) Signed-off-by: Vincent Demeester --- components/cli/cli/command/trust/inspect.go | 9 ++++----- components/cli/cli/command/trust/inspect_pretty_test.go | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/components/cli/cli/command/trust/inspect.go b/components/cli/cli/command/trust/inspect.go index ae481c1ab7..9f10878acc 100644 --- a/components/cli/cli/command/trust/inspect.go +++ b/components/cli/cli/command/trust/inspect.go @@ -14,9 +14,8 @@ import ( type inspectOptions struct { remotes []string - /* FIXME(n4ss): this is consistent with `docker service inspect` but we should provide - * a `--format` flag too. (format and pretty-print should be exclusive) - */ + // FIXME(n4ss): this is consistent with `docker service inspect` but we should provide + // a `--format` flag too. (format and pretty-print should be exclusive) prettyPrint bool } @@ -41,7 +40,7 @@ func newInspectCommand(dockerCli command.Cli) *cobra.Command { func runInspect(dockerCli command.Cli, opts inspectOptions) error { if opts.prettyPrint { - var err error = nil + var err error for index, remote := range opts.remotes { if err = prettyPrintTrustInfo(dockerCli, remote); err != nil { @@ -49,7 +48,7 @@ func runInspect(dockerCli command.Cli, opts inspectOptions) error { } // Additional separator between the inspection output of each image - if index < len(opts.remotes) - 1 { + if index < len(opts.remotes)-1 { fmt.Fprint(dockerCli.Out(), "\n\n") } } diff --git a/components/cli/cli/command/trust/inspect_pretty_test.go b/components/cli/cli/command/trust/inspect_pretty_test.go index 7cfe86cfef..93e5686958 100644 --- a/components/cli/cli/command/trust/inspect_pretty_test.go +++ b/components/cli/cli/command/trust/inspect_pretty_test.go @@ -16,7 +16,7 @@ import ( "github.com/theupdateframework/notary/tuf/data" ) -/* TODO(n4ss): remove common tests with the regular inspect command */ +// TODO(n4ss): remove common tests with the regular inspect command type fakeClient struct { dockerClient.Client @@ -98,7 +98,7 @@ func TestTrustInspectPrettyCommandEmptyNotaryRepoErrors(t *testing.T) { cmd.SetOutput(ioutil.Discard) assert.NoError(t, cmd.Execute()) assert.Contains(t, cli.OutBuffer().String(), "No signatures for reg/img:unsigned-tag") - assert.Contains(t, cli.OutBuffer().String(), "Administrative keys for reg/img:") + assert.Contains(t, cli.OutBuffer().String(), "Administrative keys for reg/img") cli = test.NewFakeCli(&fakeClient{}) cli.SetNotaryClient(getEmptyTargetsNotaryRepository) @@ -108,7 +108,7 @@ func TestTrustInspectPrettyCommandEmptyNotaryRepoErrors(t *testing.T) { cmd.SetOutput(ioutil.Discard) assert.NoError(t, cmd.Execute()) assert.Contains(t, cli.OutBuffer().String(), "No signatures for reg/img") - assert.Contains(t, cli.OutBuffer().String(), "Administrative keys for reg/img:") + assert.Contains(t, cli.OutBuffer().String(), "Administrative keys for reg/img") } func TestTrustInspectPrettyCommandFullRepoWithoutSigners(t *testing.T) {