Use cli.Context.App.Writer in the "inspect" and "standalone-verify" commands

This will make the implementations testable in the future, and prevent
spreading the untestable code via copy&paste.
This commit is contained in:
Miloslav Trmač
2016-03-23 17:42:10 +01:00
parent 59f7abe749
commit df076baf56
2 changed files with 3 additions and 4 deletions

View File

@@ -43,7 +43,7 @@ var inspectCmd = cli.Command{
return err
}
if c.Bool("raw") {
fmt.Println(string(rawManifest))
fmt.Fprintln(c.App.Writer, string(rawManifest))
return nil
}
imgInspect, err := img.Inspect()
@@ -77,7 +77,7 @@ var inspectCmd = cli.Command{
if err != nil {
return err
}
fmt.Println(string(out))
fmt.Fprintln(c.App.Writer, string(out))
return nil
},
}

View File

@@ -70,7 +70,6 @@ func standaloneVerify(context *cli.Context) error {
mech, err := signature.NewGPGSigningMechanism()
if err != nil {
return fmt.Errorf("Error initializing GPG: %v", err)
}
sig, err := signature.VerifyDockerManifestSignature(unverifiedSignature, unverifiedManifest, expectedDockerReference, mech, expectedFingerprint)
@@ -78,7 +77,7 @@ func standaloneVerify(context *cli.Context) error {
return fmt.Errorf("Error verifying signature: %v", err)
}
fmt.Printf("Signature verified, digest %s\n", sig.DockerManifestDigest)
fmt.Fprintf(context.App.Writer, "Signature verified, digest %s\n", sig.DockerManifestDigest)
return nil
}