1
0
mirror of https://github.com/docker/docs.git synced 2026-11-05 00:14:17 +03:00

Introduce flag --output on notary verify

If --output(-o for short) was provided, we write to a file,
instead of STDOUT.

Signed-off-by: Hu Keping <hukeping@huawei.com>
This commit is contained in:
HuKeping
2016-05-07 19:26:40 +08:00
parent e48b027ac3
commit 75ac7f6f72

View File

@@ -92,7 +92,8 @@ type tufCommander struct {
sha256 string
sha512 string
input string
input string
output string
}
func (t *tufCommander) AddToCommand(cmd *cobra.Command) {
@@ -122,6 +123,7 @@ func (t *tufCommander) AddToCommand(cmd *cobra.Command) {
cmdTufVerify := cmdTufVerifyTemplate.ToCommand(t.tufVerify)
cmdTufVerify.Flags().StringVarP(&t.input, "input", "i", "", "Read from a file, instead of STDIN")
cmdTufVerify.Flags().StringVarP(&t.output, "output", "o", "", "Write to a file, instead of STDOUT")
cmd.AddCommand(cmdTufVerify)
}
@@ -532,7 +534,14 @@ func (t *tufCommander) tufVerify(cmd *cobra.Command, args []string) error {
return fmt.Errorf("data not present in the trusted collection, %v", err)
}
_, _ = os.Stdout.Write(payload)
if t.output != "" {
if err := ioutil.WriteFile(t.output, payload, 0644); err != nil {
return err
}
} else {
_, _ = os.Stdout.Write(payload)
}
return nil
}