mirror of
https://github.com/containers/skopeo.git
synced 2025-07-02 17:42:29 +00:00
Simplify inspectOptions.writeOutput a bit more
Don't maintain a named array variable that we only append to exactly once. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
parent
c345785d28
commit
bcc0d54e54
@ -217,12 +217,10 @@ func (opts *inspectOptions) run(args []string, stdout io.Writer) (retErr error)
|
||||
return opts.writeOutput(stdout, outputData)
|
||||
}
|
||||
|
||||
// writeOutput writes outputData depending on opts.format to stdout
|
||||
func (opts *inspectOptions) writeOutput(stdout io.Writer, outputData any) error {
|
||||
var data []any
|
||||
|
||||
// writeOutput writes data depending on opts.format to stdout
|
||||
func (opts *inspectOptions) writeOutput(stdout io.Writer, data any) error {
|
||||
if report.IsJSON(opts.format) || opts.format == "" {
|
||||
out, err := json.MarshalIndent(outputData, "", " ")
|
||||
out, err := json.MarshalIndent(data, "", " ")
|
||||
if err == nil {
|
||||
fmt.Fprintf(stdout, "%s\n", string(out))
|
||||
}
|
||||
@ -234,6 +232,5 @@ func (opts *inspectOptions) writeOutput(stdout io.Writer, outputData any) error
|
||||
return err
|
||||
}
|
||||
defer rpt.Flush()
|
||||
data = append(data, outputData)
|
||||
return rpt.Execute(data)
|
||||
return rpt.Execute([]any{data})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user