summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-11-15 16:30:38 +0100
committerGitHub <noreply@github.com>2021-11-15 16:30:38 +0100
commite9d8ca22b8ea5923d6188225cd2d2254bdc4d898 (patch)
treedbb04a3758c48fbaf3289d624e3fe84518133206 /cmd
parentd40736fef1c0cbfc57ed39678bf95c016a13b512 (diff)
parent73e1cdfe9e41a8748b75b9461c087e4cee5d2183 (diff)
downloadpodman-e9d8ca22b8ea5923d6188225cd2d2254bdc4d898.tar.gz
podman-e9d8ca22b8ea5923d6188225cd2d2254bdc4d898.tar.bz2
podman-e9d8ca22b8ea5923d6188225cd2d2254bdc4d898.zip
Merge pull request #11076 from boaz0/closes_10275
Support template unit files in podman generate systemd
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/generate/systemd.go11
1 files changed, 10 insertions, 1 deletions
diff --git a/cmd/podman/generate/systemd.go b/cmd/podman/generate/systemd.go
index 2ab33c26b..cdc103865 100644
--- a/cmd/podman/generate/systemd.go
+++ b/cmd/podman/generate/systemd.go
@@ -21,6 +21,7 @@ import (
const (
restartPolicyFlagName = "restart-policy"
timeFlagName = "time"
+ newFlagName = "new"
)
var (
@@ -53,10 +54,11 @@ func init() {
flags := systemdCmd.Flags()
flags.BoolVarP(&systemdOptions.Name, "name", "n", false, "Use container/pod names instead of IDs")
flags.BoolVarP(&files, "files", "f", false, "Generate .service files instead of printing to stdout")
+ flags.BoolVar(&systemdOptions.TemplateUnitFile, "template", false, "Make it a template file and use %i and %I specifiers. Working only for containers")
flags.UintVarP(&systemdTimeout, timeFlagName, "t", containerConfig.Engine.StopTimeout, "Stop timeout override")
_ = systemdCmd.RegisterFlagCompletionFunc(timeFlagName, completion.AutocompleteNone)
- flags.BoolVarP(&systemdOptions.New, "new", "", false, "Create a new container or pod instead of starting an existing one")
+ flags.BoolVar(&systemdOptions.New, newFlagName, false, "Create a new container or pod instead of starting an existing one")
flags.BoolVarP(&systemdOptions.NoHeader, "no-header", "", false, "Skip header generation")
containerPrefixFlagName := "container-prefix"
@@ -93,6 +95,13 @@ func systemd(cmd *cobra.Command, args []string) error {
logrus.Warnln("The generated units should be placed on your remote system")
}
+ if cmd.Flags().Changed(newFlagName) && !systemdOptions.New && systemdOptions.TemplateUnitFile {
+ return errors.New("--template cannot be set with --new=false")
+ }
+ if !systemdOptions.New && systemdOptions.TemplateUnitFile {
+ systemdOptions.New = true
+ }
+
reports, err := registry.ContainerEngine().GenerateSystemd(registry.GetContext(), args[0], systemdOptions)
if err != nil {
return err