summaryrefslogtreecommitdiff
path: root/cmd/podman/pods/create.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-11-13 16:46:51 +0100
committerGitHub <noreply@github.com>2020-11-13 16:46:51 +0100
commit2993e97dec9d998d2eca7c5aee918b1429596a85 (patch)
tree9bdb3b5c766d913a8d1980ad017276e1f1a51b7c /cmd/podman/pods/create.go
parent6d9d9fee30b5982858d51a666f0c335ba47323a0 (diff)
parentae3816614de1c2a0c9ab9cd05afebc5b1dda6429 (diff)
downloadpodman-2993e97dec9d998d2eca7c5aee918b1429596a85.tar.gz
podman-2993e97dec9d998d2eca7c5aee918b1429596a85.tar.bz2
podman-2993e97dec9d998d2eca7c5aee918b1429596a85.zip
Merge pull request #6442 from Luap99/podman-autocomplete
Shell completion
Diffstat (limited to 'cmd/podman/pods/create.go')
-rw-r--r--cmd/podman/pods/create.go68
1 files changed, 52 insertions, 16 deletions
diff --git a/cmd/podman/pods/create.go b/cmd/podman/pods/create.go
index efa84dcb4..d33455e81 100644
--- a/cmd/podman/pods/create.go
+++ b/cmd/podman/pods/create.go
@@ -7,6 +7,7 @@ import (
"os"
"strings"
+ "github.com/containers/common/pkg/completion"
"github.com/containers/podman/v2/cmd/podman/common"
"github.com/containers/podman/v2/cmd/podman/parse"
"github.com/containers/podman/v2/cmd/podman/registry"
@@ -27,11 +28,12 @@ var (
You can then start it at any time with the podman pod start <pod_id> command. The pod will be created with the initial state 'created'.`
createCommand = &cobra.Command{
- Use: "create [options]",
- Args: validate.NoArgs,
- Short: "Create a new empty pod",
- Long: podCreateDescription,
- RunE: create,
+ Use: "create [options]",
+ Args: validate.NoArgs,
+ Short: "Create a new empty pod",
+ Long: podCreateDescription,
+ RunE: create,
+ ValidArgsFunction: completion.AutocompleteNone,
}
)
@@ -51,19 +53,53 @@ func init() {
})
flags := createCommand.Flags()
flags.SetInterspersed(false)
- flags.AddFlagSet(common.GetNetFlags())
- flags.StringVar(&createOptions.CGroupParent, "cgroup-parent", "", "Set parent cgroup for the pod")
+
+ common.DefineNetFlags(createCommand)
+
+ cgroupParentflagName := "cgroup-parent"
+ flags.StringVar(&createOptions.CGroupParent, cgroupParentflagName, "", "Set parent cgroup for the pod")
+ _ = createCommand.RegisterFlagCompletionFunc(cgroupParentflagName, completion.AutocompleteDefault)
+
flags.BoolVar(&createOptions.Infra, "infra", true, "Create an infra container associated with the pod to share namespaces with")
- flags.StringVar(&createOptions.InfraConmonPidFile, "infra-conmon-pidfile", "", "Path to the file that will receive the POD of the infra container's conmon")
- flags.String("infra-image", containerConfig.Engine.InfraImage, "The image of the infra container to associate with the pod")
- flags.String("infra-command", containerConfig.Engine.InfraCommand, "The command to run on the infra container when the pod is started")
- flags.StringSliceVar(&labelFile, "label-file", []string{}, "Read in a line delimited file of labels")
- flags.StringSliceVarP(&labels, "label", "l", []string{}, "Set metadata on pod (default [])")
- flags.StringVarP(&createOptions.Name, "name", "n", "", "Assign a name to the pod")
- flags.StringVarP(&createOptions.Hostname, "hostname", "", "", "Set a hostname to the pod")
- flags.StringVar(&podIDFile, "pod-id-file", "", "Write the pod ID to the file")
+
+ infraConmonPidfileFlagName := "infra-conmon-pidfile"
+ flags.StringVar(&createOptions.InfraConmonPidFile, infraConmonPidfileFlagName, "", "Path to the file that will receive the POD of the infra container's conmon")
+ _ = createCommand.RegisterFlagCompletionFunc(infraConmonPidfileFlagName, completion.AutocompleteDefault)
+
+ infraImageFlagName := "infra-image"
+ flags.String(infraImageFlagName, containerConfig.Engine.InfraImage, "The image of the infra container to associate with the pod")
+ _ = createCommand.RegisterFlagCompletionFunc(infraImageFlagName, common.AutocompleteImages)
+
+ infraCommandFlagName := "infra-command"
+ flags.String(infraCommandFlagName, containerConfig.Engine.InfraCommand, "The command to run on the infra container when the pod is started")
+ _ = createCommand.RegisterFlagCompletionFunc(infraCommandFlagName, completion.AutocompleteNone)
+
+ labelFileFlagName := "label-file"
+ flags.StringSliceVar(&labelFile, labelFileFlagName, []string{}, "Read in a line delimited file of labels")
+ _ = createCommand.RegisterFlagCompletionFunc(labelFileFlagName, completion.AutocompleteDefault)
+
+ labelFlagName := "label"
+ flags.StringSliceVarP(&labels, labelFlagName, "l", []string{}, "Set metadata on pod (default [])")
+ _ = createCommand.RegisterFlagCompletionFunc(labelFlagName, completion.AutocompleteNone)
+
+ nameFlagName := "name"
+ flags.StringVarP(&createOptions.Name, nameFlagName, "n", "", "Assign a name to the pod")
+ _ = createCommand.RegisterFlagCompletionFunc(nameFlagName, completion.AutocompleteNone)
+
+ hostnameFlagName := "hostname"
+ flags.StringVarP(&createOptions.Hostname, hostnameFlagName, "", "", "Set a hostname to the pod")
+ _ = createCommand.RegisterFlagCompletionFunc(hostnameFlagName, completion.AutocompleteNone)
+
+ podIDFileFlagName := "pod-id-file"
+ flags.StringVar(&podIDFile, podIDFileFlagName, "", "Write the pod ID to the file")
+ _ = createCommand.RegisterFlagCompletionFunc(podIDFileFlagName, completion.AutocompleteDefault)
+
flags.BoolVar(&replace, "replace", false, "If a pod with the same exists, replace it")
- flags.StringVar(&share, "share", specgen.DefaultKernelNamespaces, "A comma delimited list of kernel namespaces the pod will share")
+
+ shareFlagName := "share"
+ flags.StringVar(&share, shareFlagName, specgen.DefaultKernelNamespaces, "A comma delimited list of kernel namespaces the pod will share")
+ _ = createCommand.RegisterFlagCompletionFunc(shareFlagName, common.AutocompletePodShareNamespace)
+
flags.SetNormalizeFunc(aliasNetworkFlag)
}