summaryrefslogtreecommitdiff
path: root/cmd/podman/images/trust_show.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-12-02 19:28:48 +0100
committerGitHub <noreply@github.com>2021-12-02 19:28:48 +0100
commit4ff0ba4c8731e3dc1d56010f80468260104f3abc (patch)
tree897ede56e699e7f39ad5aa949851bf7fd11ea3c3 /cmd/podman/images/trust_show.go
parentee39281c35e3ceca98c0c51c9cc5d792c56ba533 (diff)
parent61792de36ea2ea98f6e3aef3821d1b15beebf9e0 (diff)
downloadpodman-4ff0ba4c8731e3dc1d56010f80468260104f3abc.tar.gz
podman-4ff0ba4c8731e3dc1d56010f80468260104f3abc.tar.bz2
podman-4ff0ba4c8731e3dc1d56010f80468260104f3abc.zip
Merge pull request #12455 from jwhonce/issues/10974
Refactor podman image command output
Diffstat (limited to 'cmd/podman/images/trust_show.go')
-rw-r--r--cmd/podman/images/trust_show.go27
1 files changed, 9 insertions, 18 deletions
diff --git a/cmd/podman/images/trust_show.go b/cmd/podman/images/trust_show.go
index c0e56f504..04ea24ca5 100644
--- a/cmd/podman/images/trust_show.go
+++ b/cmd/podman/images/trust_show.go
@@ -48,11 +48,12 @@ func showTrust(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
- if showTrustOptions.Raw {
+
+ switch {
+ case showTrustOptions.Raw:
fmt.Println(string(trust.Raw))
return nil
- }
- if showTrustOptions.JSON {
+ case showTrustOptions.JSON:
b, err := json.MarshalIndent(trust.Policies, "", " ")
if err != nil {
return err
@@ -60,23 +61,13 @@ func showTrust(cmd *cobra.Command, args []string) error {
fmt.Println(string(b))
return nil
}
+ rpt := report.New(os.Stdout, cmd.Name())
+ defer rpt.Flush()
- format := "{{range . }}{{.RepoName}}\t{{.Type}}\t{{.GPGId}}\t{{.SignatureStore}}\n{{end -}}"
- tmpl, err := report.NewTemplate("list").Parse(format)
- if err != nil {
- return err
- }
-
- w, err := report.NewWriterDefault(os.Stdout)
+ rpt, err = rpt.Parse(report.OriginPodman,
+ "{{range . }}{{.RepoName}}\t{{.Type}}\t{{.GPGId}}\t{{.SignatureStore}}\n{{end -}}")
if err != nil {
return err
}
-
- if err := tmpl.Execute(w, trust.Policies); err != nil {
- return err
- }
- if err := w.Flush(); err != nil {
- return err
- }
- return nil
+ return rpt.Execute(trust.Policies)
}