Fix comment and misc code issues

Signed-off-by: Nassim 'Nass' Eddequiouaq <eddequiouaq.nassim@gmail.com>
This commit is contained in:
Nassim 'Nass' Eddequiouaq 2018-03-09 20:26:43 +01:00
parent c5554f811b
commit 8c3d0b93d6
2 changed files with 10 additions and 11 deletions

View File

@ -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")
}
}

View File

@ -17,7 +17,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
@ -65,7 +65,7 @@ func TestTrustInspectPrettyCommandOfflineErrors(t *testing.T) {
cli = test.NewFakeCli(&fakeClient{})
cli.SetNotaryClient(notaryfake.GetOfflineNotaryRepository)
cmd := newInspectCommand(cli)
cmd = newInspectCommand(cli)
cmd.Flags().Set("pretty", "true")
cmd.SetArgs([]string{"nonexistent-reg-name.io/image:tag"})
cmd.SetOutput(ioutil.Discard)
@ -83,7 +83,7 @@ func TestTrustInspectPrettyCommandUninitializedErrors(t *testing.T) {
cli = test.NewFakeCli(&fakeClient{})
cli.SetNotaryClient(notaryfake.GetUninitializedNotaryRepository)
cmd := newInspectCommand(cli)
cmd = newInspectCommand(cli)
cmd.Flags().Set("pretty", "true")
cmd.SetArgs([]string{"reg/unsigned-img:tag"})
cmd.SetOutput(ioutil.Discard)
@ -99,17 +99,17 @@ func TestTrustInspectPrettyCommandEmptyNotaryRepoErrors(t *testing.T) {
cmd.SetOutput(ioutil.Discard)
assert.NilError(t, cmd.Execute())
assert.Check(t, is.Contains(cli.OutBuffer().String(), "No signatures for reg/img:unsigned-tag"))
assert.Check(t, is.Contains(cli.OutBuffer().String(), "Administrative keys for reg/img:"))
assert.Check(t, is.Contains(cli.OutBuffer().String(), "Administrative keys for reg/img"))
cli = test.NewFakeCli(&fakeClient{})
cli.SetNotaryClient(notaryfake.GetEmptyTargetsNotaryRepository)
cmd := newInspectCommand(cli)
cmd = newInspectCommand(cli)
cmd.Flags().Set("pretty", "true")
cmd.SetArgs([]string{"reg/img"})
cmd.SetOutput(ioutil.Discard)
assert.NilError(t, cmd.Execute())
assert.Check(t, is.Contains(cli.OutBuffer().String(), "No signatures for reg/img"))
assert.Check(t, is.Contains(cli.OutBuffer().String(), "Administrative keys for reg/img:"))
assert.Check(t, is.Contains(cli.OutBuffer().String(), "Administrative keys for reg/img"))
}
func TestTrustInspectPrettyCommandFullRepoWithoutSigners(t *testing.T) {