summaryrefslogtreecommitdiff
path: root/cmd/podman/machine
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-05-04 08:33:22 -0400
committerGitHub <noreply@github.com>2022-05-04 08:33:22 -0400
commit1975975cf4bcf9ea16f5a49909f1357ec881e615 (patch)
tree874d1aa57eeccd3ecfe8a5609869bdc8c2b65aa1 /cmd/podman/machine
parent3d84661195aa8fbf3dab67375099cb991fd7fe81 (diff)
parent88015cf0d8c62e27452899c870555667d658427f (diff)
downloadpodman-1975975cf4bcf9ea16f5a49909f1357ec881e615.tar.gz
podman-1975975cf4bcf9ea16f5a49909f1357ec881e615.tar.bz2
podman-1975975cf4bcf9ea16f5a49909f1357ec881e615.zip
Merge pull request #14099 from jwhonce/wip/machine_inspect
Implement --format for machine inspect
Diffstat (limited to 'cmd/podman/machine')
-rw-r--r--cmd/podman/machine/inspect.go31
1 files changed, 24 insertions, 7 deletions
diff --git a/cmd/podman/machine/inspect.go b/cmd/podman/machine/inspect.go
index 0ddcec8b5..b8de8e4f4 100644
--- a/cmd/podman/machine/inspect.go
+++ b/cmd/podman/machine/inspect.go
@@ -6,10 +6,10 @@ package machine
import (
"os"
+ "github.com/containers/common/pkg/report"
"github.com/containers/podman/v4/cmd/podman/common"
"github.com/containers/podman/v4/cmd/podman/registry"
"github.com/containers/podman/v4/cmd/podman/utils"
- "github.com/containers/podman/v4/libpod/define"
"github.com/containers/podman/v4/pkg/machine"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
@@ -65,12 +65,29 @@ func inspect(cmd *cobra.Command, args []string) error {
}
vms = append(vms, *ii)
}
- if len(inspectFlag.format) > 0 {
- // need jhonce to work his template magic
- return define.ErrNotImplemented
- }
- if err := printJSON(vms); err != nil {
- logrus.Error(err)
+ switch {
+ case cmd.Flag("format").Changed:
+ row := report.NormalizeFormat(inspectFlag.format)
+ row = report.EnforceRange(row)
+
+ tmpl, err := report.NewTemplate("Machine inspect").Parse(row)
+ if err != nil {
+ return err
+ }
+
+ w, err := report.NewWriterDefault(os.Stdout)
+ if err != nil {
+ return err
+ }
+
+ if err := tmpl.Execute(w, vms); err != nil {
+ logrus.Error(err)
+ }
+ w.Flush()
+ default:
+ if err := printJSON(vms); err != nil {
+ logrus.Error(err)
+ }
}
return errs.PrintErrors()
}