summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/podman/pods/inspect.go13
-rw-r--r--completions/bash/podman13
-rw-r--r--docs/source/markdown/podman-pod-inspect.1.md51
-rw-r--r--pkg/api/server/register_images.go9
-rw-r--r--pkg/domain/entities/pods.go2
-rw-r--r--test/system/200-pod.bats12
6 files changed, 82 insertions, 18 deletions
diff --git a/cmd/podman/pods/inspect.go b/cmd/podman/pods/inspect.go
index 1e333247b..34c07c11b 100644
--- a/cmd/podman/pods/inspect.go
+++ b/cmd/podman/pods/inspect.go
@@ -4,6 +4,7 @@ import (
"context"
"fmt"
+ "github.com/containers/buildah/pkg/formats"
"github.com/containers/libpod/cmd/podman/registry"
"github.com/containers/libpod/pkg/domain/entities"
"github.com/pkg/errors"
@@ -36,6 +37,7 @@ func init() {
})
flags := inspectCmd.Flags()
flags.BoolVarP(&inspectOptions.Latest, "latest", "l", false, "Act on the latest pod podman is aware of")
+ flags.StringVarP(&inspectOptions.Format, "format", "f", "json", "Format the output to a Go template or json")
if registry.IsRemote() {
_ = flags.MarkHidden("latest")
}
@@ -54,10 +56,11 @@ func inspect(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
- b, err := json.MarshalIndent(responses, "", " ")
- if err != nil {
- return err
+ var data interface{} = responses
+ var out formats.Writer = formats.JSONStruct{Output: data}
+ if inspectOptions.Format != "json" {
+ out = formats.StdoutTemplate{Output: data, Template: inspectOptions.Format}
}
- fmt.Println(string(b))
- return nil
+
+ return out.Out()
}
diff --git a/completions/bash/podman b/completions/bash/podman
index 8f02a4b36..a58becaf0 100644
--- a/completions/bash/podman
+++ b/completions/bash/podman
@@ -3345,6 +3345,18 @@ _podman_pod_unpause() {
esac
}
+_podman_pod_inspect() {
+ local options_with_args="
+ --format
+ -f
+ --latest
+ -l
+ "
+
+ _complete_ "$options_with_args"
+}
+
+
_podman_pod() {
local boolean_options="
--help
@@ -3362,6 +3374,7 @@ _podman_pod() {
stop
top
unpause
+ inspect
"
local aliases="
list
diff --git a/docs/source/markdown/podman-pod-inspect.1.md b/docs/source/markdown/podman-pod-inspect.1.md
index 831d28259..bc04b2b32 100644
--- a/docs/source/markdown/podman-pod-inspect.1.md
+++ b/docs/source/markdown/podman-pod-inspect.1.md
@@ -18,21 +18,50 @@ to run pods such as CRI-O, the last started pod could be from either of those me
The latest option is not supported on the remote client.
+**-f**, **--format**=*format*
+
+Change the default output format. This can be of a supported type like 'json'
+or a Go template.
+Valid placeholders for the Go template are listed below:
+
+| **Placeholder** | **Description** |
+| ----------------- | ----------------------------------------------------------------------------- |
+| .ID | Pod ID |
+| .Name | Pod name |
+| .State | Pod state |
+| .Hostname | Pod hostname |
+| .Labels | Pod labels |
+| .Created | Time when the pod was created |
+| .CreateCgroup | Whether cgroup was created |
+| .CgroupParent | Pod cgroup parent |
+| .CgroupPath | Pod cgroup path |
+| .CreateInfra | Whether infrastructure created |
+| .InfraContainerID | Pod infrastructure ID |
+| .SharedNamespaces | Pod shared namespaces |
+| .NumContainers | Number of containers in the pod |
+| .Containers | Pod containers |
+
## EXAMPLE
```
# podman pod inspect foobar
{
- "Config": {
- "id": "3513ca70583dd7ef2bac83331350f6b6c47d7b4e526c908e49d89ebf720e4693",
- "name": "foobar",
- "labels": {},
- "cgroupParent": "/libpod_parent",
- "UsePodCgroup": true,
- "created": "2018-08-08T11:15:18.823115347-05:00"
- },
- "State": {
- "CgroupPath": ""
- },
+
+ "Id": "3513ca70583dd7ef2bac83331350f6b6c47d7b4e526c908e49d89ebf720e4693",
+ "Name": "foobar",
+ "Labels": {},
+ "CgroupParent": "/libpod_parent",
+ "CreateCgroup": true,
+ "Created": "2018-08-08T11:15:18.823115347-05:00"
+ "State": "created",
+ "Hostname": "",
+ "SharedNamespaces": [
+ "uts",
+ "ipc",
+ "net"
+ ]
+ "CreateInfra": false,
+ "InfraContainerID": "1020dd70583dd7ff2bac83331350f6b6e007de0d026c908e49d89ebf891d4699"
+ "CgroupPath": ""
"Containers": [
{
"id": "d53f8bf1e9730281264aac6e6586e327429f62c704abea4b6afb5d8a2b2c9f2c",
diff --git a/pkg/api/server/register_images.go b/pkg/api/server/register_images.go
index c885dc81a..64094e8e4 100644
--- a/pkg/api/server/register_images.go
+++ b/pkg/api/server/register_images.go
@@ -631,13 +631,18 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
// required: true
// description: Name of image to push.
// - in: query
- // name: tag
+ // name: destination
// type: string
- // description: The tag to associate with the image on the registry.
+ // description: Allows for pushing the image to a different destintation than the image refers to.
// - in: query
// name: credentials
// description: username:password for the registry.
// type: string
+ // - in: query
+ // name: tlsVerify
+ // description: Require TLS verification.
+ // type: boolean
+ // default: true
// - in: header
// name: X-Registry-Auth
// type: string
diff --git a/pkg/domain/entities/pods.go b/pkg/domain/entities/pods.go
index a4896ce4d..1a38a7aa4 100644
--- a/pkg/domain/entities/pods.go
+++ b/pkg/domain/entities/pods.go
@@ -184,6 +184,8 @@ type PodInspectOptions struct {
// Options for the API.
NameOrID string
+
+ Format string
}
type PodInspectReport struct {
diff --git a/test/system/200-pod.bats b/test/system/200-pod.bats
index e3643a3bd..f34cd0707 100644
--- a/test/system/200-pod.bats
+++ b/test/system/200-pod.bats
@@ -170,4 +170,16 @@ function random_ip() {
is "$output" ".*options $dns_opt" "--dns-opt was added"
}
+@test "podman pod inspect - format" {
+ skip_if_remote "podman-pod does not work with podman-remote"
+
+ run_podman pod create --name podtest
+ podid=$output
+
+ run_podman pod inspect --format '-> {{.Name}}: {{.NumContainers}}' podtest
+ is "$output" "-> podtest: 1"
+
+ run_podman pod rm -f podtest
+}
+
# vim: filetype=sh