summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-09-06 15:40:55 +0200
committerGitHub <noreply@github.com>2022-09-06 15:40:55 +0200
commit4e06aa37714ecb5b38e189cf85f4aec9b1e6399a (patch)
tree8b7d0545f9946cddb01d98050063e0422fbfe8ac /cmd/podman
parent34b0be6cffef86ff54846e5548d1accf3fefc272 (diff)
parenta9a411f8a83ab5644582b8929a32abacc18a17fc (diff)
downloadpodman-4e06aa37714ecb5b38e189cf85f4aec9b1e6399a.tar.gz
podman-4e06aa37714ecb5b38e189cf85f4aec9b1e6399a.tar.bz2
podman-4e06aa37714ecb5b38e189cf85f4aec9b1e6399a.zip
Merge pull request #15584 from sstosh/generate-systemd-env
Add generate systemd -e/--env option
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/generate/systemd.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/cmd/podman/generate/systemd.go b/cmd/podman/generate/systemd.go
index e40416534..a7cdd9bfe 100644
--- a/cmd/podman/generate/systemd.go
+++ b/cmd/podman/generate/systemd.go
@@ -13,6 +13,7 @@ import (
"github.com/containers/podman/v4/cmd/podman/registry"
"github.com/containers/podman/v4/cmd/podman/utils"
"github.com/containers/podman/v4/pkg/domain/entities"
+ envLib "github.com/containers/podman/v4/pkg/env"
systemDefine "github.com/containers/podman/v4/pkg/systemd/define"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
@@ -28,9 +29,11 @@ const (
wantsFlagName = "wants"
afterFlagName = "after"
requiresFlagName = "requires"
+ envFlagName = "env"
)
var (
+ envInput []string
files bool
format string
systemdRestart string
@@ -109,6 +112,9 @@ func init() {
flags.StringArrayVar(&systemdOptions.Requires, requiresFlagName, nil, "Similar to wants, but declares stronger requirement dependencies")
_ = systemdCmd.RegisterFlagCompletionFunc(requiresFlagName, completion.AutocompleteNone)
+ flags.StringArrayVarP(&envInput, envFlagName, "e", nil, "Set environment variables to the systemd unit files")
+ _ = systemdCmd.RegisterFlagCompletionFunc(envFlagName, completion.AutocompleteNone)
+
flags.SetNormalizeFunc(utils.TimeoutAliasFlags)
}
@@ -141,6 +147,13 @@ func systemd(cmd *cobra.Command, args []string) error {
if cmd.Flags().Changed(stopTimeoutCompatFlagName) {
setStopTimeout++
}
+ if cmd.Flags().Changed(envFlagName) {
+ cliEnv, err := envLib.ParseSlice(envInput)
+ if err != nil {
+ return fmt.Errorf("error parsing environment variables: %w", err)
+ }
+ systemdOptions.AdditionalEnvVariables = envLib.Slice(cliEnv)
+ }
switch setStopTimeout {
case 1:
systemdOptions.StopTimeout = &stopTimeout