From 8fbe06b8cbd8e3bc425d83130d562eb0c19f309b Mon Sep 17 00:00:00 2001 From: "wuhua.ck" Date: Thu, 15 Apr 2021 22:36:50 +0800 Subject: add flag "--pidfile" for podman create/run Signed-off-by: chenkang --- cmd/podman/common/create.go | 6 ++++++ cmd/podman/common/create_opts.go | 1 + cmd/podman/common/specgen.go | 1 + cmd/podman/containers/create.go | 4 ++++ cmd/podman/containers/run.go | 2 ++ 5 files changed, 14 insertions(+) (limited to 'cmd/podman') diff --git a/cmd/podman/common/create.go b/cmd/podman/common/create.go index 220a30a10..e574f228e 100644 --- a/cmd/podman/common/create.go +++ b/cmd/podman/common/create.go @@ -817,6 +817,12 @@ func DefineCreateFlags(cmd *cobra.Command, cf *ContainerCLIOpts) { ) _ = cmd.RegisterFlagCompletionFunc(cgroupConfFlagName, completion.AutocompleteNone) + pidFileFlagName := "pidfile" + createFlags.StringVar( + &cf.PidFile, + pidFileFlagName, "", + "Write the container process ID to the file") + _ = createFlags.MarkHidden("signature-policy") if registry.IsRemote() { _ = createFlags.MarkHidden("env-host") diff --git a/cmd/podman/common/create_opts.go b/cmd/podman/common/create_opts.go index e14918fe1..040dc6570 100644 --- a/cmd/podman/common/create_opts.go +++ b/cmd/podman/common/create_opts.go @@ -122,6 +122,7 @@ type ContainerCLIOpts struct { VolumesFrom []string Workdir string SeccompPolicy string + PidFile string Net *entities.NetOptions diff --git a/cmd/podman/common/specgen.go b/cmd/podman/common/specgen.go index 363a8f5f9..310a07a00 100644 --- a/cmd/podman/common/specgen.go +++ b/cmd/podman/common/specgen.go @@ -644,6 +644,7 @@ func FillOutSpecGen(s *specgen.SpecGenerator, c *ContainerCLIOpts, args []string s.Timezone = c.Timezone s.Umask = c.Umask s.Secrets = c.Secrets + s.PidFile = c.PidFile return nil } diff --git a/cmd/podman/containers/create.go b/cmd/podman/containers/create.go index 2da9aaf5e..5d2f3aad6 100644 --- a/cmd/podman/containers/create.go +++ b/cmd/podman/containers/create.go @@ -63,6 +63,10 @@ func createFlags(cmd *cobra.Command) { common.DefineNetFlags(cmd) flags.SetNormalizeFunc(utils.AliasFlags) + + if registry.IsRemote() { + _ = flags.MarkHidden("pidfile") + } } func init() { diff --git a/cmd/podman/containers/run.go b/cmd/podman/containers/run.go index 1a9fa2f0f..fa3310fad 100644 --- a/cmd/podman/containers/run.go +++ b/cmd/podman/containers/run.go @@ -76,8 +76,10 @@ func runFlags(cmd *cobra.Command) { detachKeysFlagName := "detach-keys" flags.StringVar(&runOpts.DetachKeys, detachKeysFlagName, containerConfig.DetachKeys(), "Override the key sequence for detaching a container. Format is a single character `[a-Z]` or a comma separated sequence of `ctrl-`, where `` is one of: `a-cf`, `@`, `^`, `[`, `\\`, `]`, `^` or `_`") _ = cmd.RegisterFlagCompletionFunc(detachKeysFlagName, common.AutocompleteDetachKeys) + if registry.IsRemote() { _ = flags.MarkHidden("preserve-fds") + _ = flags.MarkHidden("pidfile") } } -- cgit v1.2.3-54-g00ecf From e16200ac9f0e8fde836a14cc6951203e8986122a Mon Sep 17 00:00:00 2001 From: chenkang Date: Fri, 16 Apr 2021 15:52:03 +0800 Subject: add flag autocomplete Signed-off-by: chenkang --- cmd/podman/common/create.go | 1 + 1 file changed, 1 insertion(+) (limited to 'cmd/podman') diff --git a/cmd/podman/common/create.go b/cmd/podman/common/create.go index e574f228e..da391d30d 100644 --- a/cmd/podman/common/create.go +++ b/cmd/podman/common/create.go @@ -822,6 +822,7 @@ func DefineCreateFlags(cmd *cobra.Command, cf *ContainerCLIOpts) { &cf.PidFile, pidFileFlagName, "", "Write the container process ID to the file") + _ = cmd.RegisterFlagCompletionFunc(pidFileFlagName, completion.AutocompleteDefault) _ = createFlags.MarkHidden("signature-policy") if registry.IsRemote() { -- cgit v1.2.3-54-g00ecf From f331c9445f0be468a47a43e290845f7b637535d5 Mon Sep 17 00:00:00 2001 From: chenkang Date: Fri, 16 Apr 2021 23:09:17 +0800 Subject: hide conmon-pidfile flag on remote mode Signed-off-by: chenkang --- cmd/podman/containers/create.go | 1 + cmd/podman/containers/run.go | 1 + 2 files changed, 2 insertions(+) (limited to 'cmd/podman') diff --git a/cmd/podman/containers/create.go b/cmd/podman/containers/create.go index 5d2f3aad6..507e9c221 100644 --- a/cmd/podman/containers/create.go +++ b/cmd/podman/containers/create.go @@ -65,6 +65,7 @@ func createFlags(cmd *cobra.Command) { flags.SetNormalizeFunc(utils.AliasFlags) if registry.IsRemote() { + _ = flags.MarkHidden("conmon-pidfile") _ = flags.MarkHidden("pidfile") } } diff --git a/cmd/podman/containers/run.go b/cmd/podman/containers/run.go index fa3310fad..8e27977c0 100644 --- a/cmd/podman/containers/run.go +++ b/cmd/podman/containers/run.go @@ -79,6 +79,7 @@ func runFlags(cmd *cobra.Command) { if registry.IsRemote() { _ = flags.MarkHidden("preserve-fds") + _ = flags.MarkHidden("conmon-pidfile") _ = flags.MarkHidden("pidfile") } } -- cgit v1.2.3-54-g00ecf