summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/common/completion.go18
-rw-r--r--cmd/podman/common/create.go8
-rw-r--r--cmd/podman/common/create_opts.go1
-rw-r--r--cmd/podman/common/specgen.go2
-rw-r--r--cmd/podman/generate/generate.go4
-rw-r--r--cmd/podman/generate/kube.go14
-rw-r--r--cmd/podman/images/save.go2
-rw-r--r--cmd/podman/machine/ssh.go2
-rw-r--r--cmd/podman/play/kube.go17
-rw-r--r--cmd/podman/play/play.go4
-rw-r--r--cmd/podman/root.go6
-rw-r--r--cmd/podman/system/unshare.go6
12 files changed, 65 insertions, 19 deletions
diff --git a/cmd/podman/common/completion.go b/cmd/podman/common/completion.go
index bc106263c..6086df297 100644
--- a/cmd/podman/common/completion.go
+++ b/cmd/podman/common/completion.go
@@ -21,7 +21,7 @@ var (
// ChangeCmds is the list of valid Change commands to passed to the Commit call
ChangeCmds = []string{"CMD", "ENTRYPOINT", "ENV", "EXPOSE", "LABEL", "ONBUILD", "STOPSIGNAL", "USER", "VOLUME", "WORKDIR"}
// LogLevels supported by podman
- LogLevels = []string{"debug", "info", "warn", "warning", "error", "fatal", "panic"}
+ LogLevels = []string{"trace", "debug", "info", "warn", "warning", "error", "fatal", "panic"}
)
type completeType int
@@ -405,6 +405,20 @@ func AutocompletePodsRunning(cmd *cobra.Command, args []string, toComplete strin
return getPods(cmd, toComplete, completeDefault, "running", "degraded")
}
+// AutocompleteForKube - Autocomplete all Podman objects supported by kube generate.
+func AutocompleteForKube(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
+ if !validCurrentCmdLine(cmd, args, toComplete) {
+ return nil, cobra.ShellCompDirectiveNoFileComp
+ }
+ containers, _ := getContainers(cmd, toComplete, completeDefault)
+ pods, _ := getPods(cmd, toComplete, completeDefault)
+ volumes, _ := getVolumes(cmd, toComplete)
+ objs := containers
+ objs = append(objs, pods...)
+ objs = append(objs, volumes...)
+ return objs, cobra.ShellCompDirectiveNoFileComp
+}
+
// AutocompleteContainersAndPods - Autocomplete container names and pod names.
func AutocompleteContainersAndPods(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
if !validCurrentCmdLine(cmd, args, toComplete) {
@@ -995,7 +1009,7 @@ func AutocompleteEventBackend(cmd *cobra.Command, args []string, toComplete stri
}
// AutocompleteLogLevel - Autocomplete log level options.
-// -> "debug", "info", "warn", "error", "fatal", "panic"
+// -> "trace", "debug", "info", "warn", "error", "fatal", "panic"
func AutocompleteLogLevel(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return LogLevels, cobra.ShellCompDirectiveNoFileComp
}
diff --git a/cmd/podman/common/create.go b/cmd/podman/common/create.go
index dda709ecd..220a30a10 100644
--- a/cmd/podman/common/create.go
+++ b/cmd/podman/common/create.go
@@ -576,6 +576,14 @@ func DefineCreateFlags(cmd *cobra.Command, cf *ContainerCLIOpts) {
`If a container with the same name exists, replace it`,
)
+ requiresFlagName := "requires"
+ createFlags.StringSliceVar(
+ &cf.Requires,
+ requiresFlagName, []string{},
+ "Add one or more requirement containers that must be started before this container will start",
+ )
+ _ = cmd.RegisterFlagCompletionFunc(requiresFlagName, AutocompleteContainers)
+
restartFlagName := "restart"
createFlags.StringVar(
&cf.Restart,
diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go
index a296ef4f1..e14918fe1 100644
--- a/cmd/podman/common/create_opts.go
+++ b/cmd/podman/common/create_opts.go
@@ -93,6 +93,7 @@ type ContainerCLIOpts struct {
ReadOnlyTmpFS bool
Restart string
Replace bool
+ Requires []string
Rm bool
RootFS bool
Secrets []string
diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go
index d1b67d963..363a8f5f9 100644
--- a/cmd/podman/common/specgen.go
+++ b/cmd/podman/common/specgen.go
@@ -486,6 +486,8 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string
s.ReadOnlyFilesystem = c.ReadOnly
s.ConmonPidFile = c.ConmonPIDFile
+ s.DependencyContainers = c.Requires
+
// TODO
// outside of specgen and oci though
// defaults to true, check spec/storage
diff --git a/cmd/podman/generate/generate.go b/cmd/podman/generate/generate.go
index c559b9e1b..a6d39bbbe 100644
--- a/cmd/podman/generate/generate.go
+++ b/cmd/podman/generate/generate.go
@@ -12,8 +12,8 @@ var (
// Command: podman _generate_
generateCmd = &cobra.Command{
Use: "generate",
- Short: "Generate structured data based on containers and pods.",
- Long: "Generate structured data (e.g., Kubernetes yaml or systemd units) based on containers and pods.",
+ Short: "Generate structured data based on containers, pods or volumes.",
+ Long: "Generate structured data (e.g., Kubernetes YAML or systemd units) based on containers, pods or volumes.",
RunE: validate.SubCommandExists,
}
containerConfig = util.DefaultContainerConfig()
diff --git a/cmd/podman/generate/kube.go b/cmd/podman/generate/kube.go
index 90e58271f..9767b0e06 100644
--- a/cmd/podman/generate/kube.go
+++ b/cmd/podman/generate/kube.go
@@ -17,20 +17,22 @@ import (
var (
kubeOptions = entities.GenerateKubeOptions{}
kubeFile = ""
- kubeDescription = `Command generates Kubernetes pod and service YAML (v1 specification) from Podman containers or a pod.
+ kubeDescription = `Command generates Kubernetes Pod, Service or PersistenVolumeClaim YAML (v1 specification) from Podman containers, pods or volumes.
-Whether the input is for a container or pod, Podman will always generate the specification as a pod.`
+ Whether the input is for a container or pod, Podman will always generate the specification as a pod.`
kubeCmd = &cobra.Command{
- Use: "kube [options] {CONTAINER...|POD}",
- Short: "Generate Kubernetes YAML from a container or pod.",
+ Use: "kube [options] {CONTAINER...|POD...|VOLUME...}",
+ Short: "Generate Kubernetes YAML from containers, pods or volumes.",
Long: kubeDescription,
RunE: kube,
Args: cobra.MinimumNArgs(1),
- ValidArgsFunction: common.AutocompleteContainersAndPods,
+ ValidArgsFunction: common.AutocompleteForKube,
Example: `podman generate kube ctrID
podman generate kube podID
- podman generate kube --service podID`,
+ podman generate kube --service podID
+ podman generate kube volumeName
+ podman generate kube ctrID podID volumeName --service`,
}
)
diff --git a/cmd/podman/images/save.go b/cmd/podman/images/save.go
index 6c03fc3c6..f1f7e8b2e 100644
--- a/cmd/podman/images/save.go
+++ b/cmd/podman/images/save.go
@@ -102,7 +102,7 @@ func save(cmd *cobra.Command, args []string) (finalErr error) {
tags []string
succeeded = false
)
- if cmd.Flag("compress").Changed && (saveOpts.Format != define.OCIManifestDir && saveOpts.Format != define.V2s2ManifestDir && saveOpts.Format == "") {
+ if cmd.Flag("compress").Changed && (saveOpts.Format != define.OCIManifestDir && saveOpts.Format != define.V2s2ManifestDir) {
return errors.Errorf("--compress can only be set when --format is either 'oci-dir' or 'docker-dir'")
}
if len(saveOpts.Output) == 0 {
diff --git a/cmd/podman/machine/ssh.go b/cmd/podman/machine/ssh.go
index 504fcbe46..ecc6d3b82 100644
--- a/cmd/podman/machine/ssh.go
+++ b/cmd/podman/machine/ssh.go
@@ -78,7 +78,7 @@ func ssh(cmd *cobra.Command, args []string) error {
vm, err = qemu.LoadVMByName(vmName)
}
if err != nil {
- return errors.Wrapf(err, "vm %s not found", args[0])
+ return errors.Wrapf(err, "vm %s not found", vmName)
}
return vm.SSH(vmName, sshOpts)
}
diff --git a/cmd/podman/play/kube.go b/cmd/podman/play/kube.go
index 4c0f7f39e..30d6d86f0 100644
--- a/cmd/podman/play/kube.go
+++ b/cmd/podman/play/kube.go
@@ -32,11 +32,11 @@ var (
kubeOptions = playKubeOptionsWrapper{}
kubeDescription = `Command reads in a structured file of Kubernetes YAML.
- It creates the pod and containers described in the YAML. The containers within the pod are then started and the ID of the new Pod is output.`
+ It creates pods or volumes based on the Kubernetes kind described in the YAML. Supported kinds are Pods, Deployments and PersistentVolumeClaims.`
kubeCmd = &cobra.Command{
Use: "kube [options] KUBEFILE|-",
- Short: "Play a pod based on Kubernetes YAML.",
+ Short: "Play a pod or volume based on Kubernetes YAML.",
Long: kubeDescription,
RunE: kube,
Args: cobra.ExactArgs(1),
@@ -65,6 +65,10 @@ func init() {
flags.StringVar(&kubeOptions.Network, networkFlagName, "", "Connect pod to CNI network(s)")
_ = kubeCmd.RegisterFlagCompletionFunc(networkFlagName, common.AutocompleteNetworkFlag)
+ staticIPFlagName := "ip"
+ flags.IPSliceVar(&kubeOptions.StaticIPs, staticIPFlagName, nil, "Static IP addresses to assign to the pods")
+ _ = kubeCmd.RegisterFlagCompletionFunc(staticIPFlagName, completion.AutocompleteNone)
+
logDriverFlagName := "log-driver"
flags.StringVar(&kubeOptions.LogDriver, logDriverFlagName, "", "Logging driver for the container")
_ = kubeCmd.RegisterFlagCompletionFunc(logDriverFlagName, common.AutocompleteLogDriver)
@@ -129,6 +133,15 @@ func kube(cmd *cobra.Command, args []string) error {
return err
}
+ // Print volumes report
+ for i, volume := range report.Volumes {
+ if i == 0 {
+ fmt.Println("Volumes:")
+ }
+ fmt.Println(volume.Name)
+ }
+
+ // Print pods report
for _, pod := range report.Pods {
for _, l := range pod.Logs {
fmt.Fprint(os.Stderr, l)
diff --git a/cmd/podman/play/play.go b/cmd/podman/play/play.go
index 92f87ad80..89c7e0139 100644
--- a/cmd/podman/play/play.go
+++ b/cmd/podman/play/play.go
@@ -11,8 +11,8 @@ var (
// Command: podman _play_
playCmd = &cobra.Command{
Use: "play",
- Short: "Play a pod and its containers from a structured file.",
- Long: "Play structured data (e.g., Kubernetes pod or service yaml) based on containers and pods.",
+ Short: "Play containers, pods or volumes from a structured file.",
+ Long: "Play structured data (e.g., Kubernetes YAML) based on containers, pods or volumes.",
RunE: validate.SubCommandExists,
}
)
diff --git a/cmd/podman/root.go b/cmd/podman/root.go
index 4527c2646..9e5d2a236 100644
--- a/cmd/podman/root.go
+++ b/cmd/podman/root.go
@@ -416,7 +416,11 @@ func formatError(err error) string {
strings.TrimSuffix(err.Error(), ": "+define.ErrOCIRuntime.Error()),
)
} else {
- message = "Error: " + err.Error()
+ if logrus.IsLevelEnabled(logrus.TraceLevel) {
+ message = fmt.Sprintf("Error: %+v", err)
+ } else {
+ message = fmt.Sprintf("Error: %v", err)
+ }
}
return message
}
diff --git a/cmd/podman/system/unshare.go b/cmd/podman/system/unshare.go
index 5e6ff569b..c07751532 100644
--- a/cmd/podman/system/unshare.go
+++ b/cmd/podman/system/unshare.go
@@ -12,9 +12,10 @@ import (
)
var (
+ unshareOptions = entities.SystemUnshareOptions{}
unshareDescription = "Runs a command in a modified user namespace."
unshareCommand = &cobra.Command{
- Use: "unshare [COMMAND [ARG...]]",
+ Use: "unshare [options] [COMMAND [ARG...]]",
DisableFlagsInUseLine: true,
Short: "Run a command in a modified user namespace",
Long: unshareDescription,
@@ -33,6 +34,7 @@ func init() {
})
flags := unshareCommand.Flags()
flags.SetInterspersed(false)
+ flags.BoolVar(&unshareOptions.RootlessCNI, "rootless-cni", false, "Join the rootless network namespace used for CNI networking")
}
func unshare(cmd *cobra.Command, args []string) error {
@@ -49,5 +51,5 @@ func unshare(cmd *cobra.Command, args []string) error {
args = []string{shell}
}
- return registry.ContainerEngine().Unshare(registry.Context(), args)
+ return registry.ContainerEngine().Unshare(registry.Context(), args, unshareOptions)
}