aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman/networks/inspect.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/podman/networks/inspect.go')
-rw-r--r--cmd/podman/networks/inspect.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/cmd/podman/networks/inspect.go b/cmd/podman/networks/inspect.go
new file mode 100644
index 000000000..0bc73579a
--- /dev/null
+++ b/cmd/podman/networks/inspect.go
@@ -0,0 +1,46 @@
+package network
+
+import (
+ "encoding/json"
+ "fmt"
+
+ "github.com/containers/libpod/cmd/podman/registry"
+ "github.com/containers/libpod/pkg/domain/entities"
+ "github.com/spf13/cobra"
+)
+
+var (
+ networkinspectDescription = `Inspect network`
+ networkinspectCommand = &cobra.Command{
+ Use: "inspect NETWORK [NETWORK...] [flags] ",
+ Short: "network inspect",
+ Long: networkinspectDescription,
+ RunE: networkInspect,
+ Example: `podman network inspect podman`,
+ Args: cobra.MinimumNArgs(1),
+ Annotations: map[string]string{
+ registry.ParentNSRequired: "",
+ },
+ }
+)
+
+func init() {
+ registry.Commands = append(registry.Commands, registry.CliCommand{
+ Mode: []entities.EngineMode{entities.ABIMode},
+ Command: networkinspectCommand,
+ Parent: networkCmd,
+ })
+}
+
+func networkInspect(cmd *cobra.Command, args []string) error {
+ responses, err := registry.ContainerEngine().NetworkInspect(registry.Context(), args, entities.NetworkInspectOptions{})
+ if err != nil {
+ return err
+ }
+ b, err := json.MarshalIndent(responses, "", " ")
+ if err != nil {
+ return err
+ }
+ fmt.Println(string(b))
+ return nil
+}