From 56a65cffac2cee3132c950d49ea8a5b46eabbff1 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Tue, 13 Aug 2019 13:06:37 +0200 Subject: generate systemd: support pods and geneartig files Support generating systemd unit files for a pod. Podman generates one unit file for the pod including the PID file for the infra container's conmon process and one unit file for each container (excluding the infra container). Note that this change implies refactorings in the `pkg/systemdgen` API. Signed-off-by: Valentin Rothberg --- cmd/podman/cliconfig/config.go | 1 + cmd/podman/generate_systemd.go | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'cmd/podman') diff --git a/cmd/podman/cliconfig/config.go b/cmd/podman/cliconfig/config.go index e7ad921da..9b5633516 100644 --- a/cmd/podman/cliconfig/config.go +++ b/cmd/podman/cliconfig/config.go @@ -156,6 +156,7 @@ type GenerateKubeValues struct { type GenerateSystemdValues struct { PodmanCommand Name bool + Files bool RestartPolicy string StopTimeout int } diff --git a/cmd/podman/generate_systemd.go b/cmd/podman/generate_systemd.go index 222fc4c98..aa202a68d 100644 --- a/cmd/podman/generate_systemd.go +++ b/cmd/podman/generate_systemd.go @@ -5,7 +5,6 @@ import ( "github.com/containers/libpod/cmd/podman/cliconfig" "github.com/containers/libpod/pkg/adapter" - "github.com/containers/libpod/pkg/systemdgen" "github.com/pkg/errors" "github.com/spf13/cobra" ) @@ -40,7 +39,10 @@ func init() { containerSystemdCommand.SetHelpTemplate(HelpTemplate()) containerSystemdCommand.SetUsageTemplate(UsageTemplate()) flags := containerSystemdCommand.Flags() - flags.BoolVarP(&containerSystemdCommand.Name, "name", "n", false, "use the container name instead of ID") + flags.BoolVarP(&containerSystemdCommand.Name, "name", "n", false, "use the container/pod name instead of ID") + if !remoteclient { + flags.BoolVarP(&containerSystemdCommand.Files, "files", "f", false, "generate files instead of printing to stdout") + } flags.IntVarP(&containerSystemdCommand.StopTimeout, "timeout", "t", -1, "stop timeout override") flags.StringVar(&containerSystemdCommand.RestartPolicy, "restart-policy", "on-failure", "applicable systemd restart-policy") } @@ -56,10 +58,6 @@ func generateSystemdCmd(c *cliconfig.GenerateSystemdValues) error { if c.Flag("timeout").Changed && c.StopTimeout < 0 { return errors.New("timeout value must be 0 or greater") } - // Make sure the input restart policy is valid - if err := systemdgen.ValidateRestartPolicy(c.RestartPolicy); err != nil { - return err - } unit, err := runtime.GenerateSystemd(c) if err != nil { -- cgit v1.2.3-54-g00ecf