summaryrefslogtreecommitdiff
path: root/pkg/api
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 /pkg/api
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 'pkg/api')
-rw-r--r--pkg/api/handlers/libpod/generate.go58
-rw-r--r--pkg/api/server/register_generate.go7
2 files changed, 37 insertions, 28 deletions
diff --git a/pkg/api/handlers/libpod/generate.go b/pkg/api/handlers/libpod/generate.go
index 48c4c59e1..431927ac5 100644
--- a/pkg/api/handlers/libpod/generate.go
+++ b/pkg/api/handlers/libpod/generate.go
@@ -17,20 +17,21 @@ func GenerateSystemd(w http.ResponseWriter, r *http.Request) {
runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime)
decoder := r.Context().Value(api.DecoderKey).(*schema.Decoder)
query := struct {
- Name bool `schema:"useName"`
- New bool `schema:"new"`
- NoHeader bool `schema:"noHeader"`
- TemplateUnitFile bool `schema:"templateUnitFile"`
- RestartPolicy *string `schema:"restartPolicy"`
- RestartSec uint `schema:"restartSec"`
- StopTimeout uint `schema:"stopTimeout"`
- StartTimeout uint `schema:"startTimeout"`
- ContainerPrefix *string `schema:"containerPrefix"`
- PodPrefix *string `schema:"podPrefix"`
- Separator *string `schema:"separator"`
- Wants []string `schema:"wants"`
- After []string `schema:"after"`
- Requires []string `schema:"requires"`
+ Name bool `schema:"useName"`
+ New bool `schema:"new"`
+ NoHeader bool `schema:"noHeader"`
+ TemplateUnitFile bool `schema:"templateUnitFile"`
+ RestartPolicy *string `schema:"restartPolicy"`
+ RestartSec uint `schema:"restartSec"`
+ StopTimeout uint `schema:"stopTimeout"`
+ StartTimeout uint `schema:"startTimeout"`
+ ContainerPrefix *string `schema:"containerPrefix"`
+ PodPrefix *string `schema:"podPrefix"`
+ Separator *string `schema:"separator"`
+ Wants []string `schema:"wants"`
+ After []string `schema:"after"`
+ Requires []string `schema:"requires"`
+ AdditionalEnvVariables []string `schema:"additionalEnvVariables"`
}{
StartTimeout: 0,
StopTimeout: util.DefaultContainerConfig().Engine.StopTimeout,
@@ -58,20 +59,21 @@ func GenerateSystemd(w http.ResponseWriter, r *http.Request) {
containerEngine := abi.ContainerEngine{Libpod: runtime}
options := entities.GenerateSystemdOptions{
- Name: query.Name,
- New: query.New,
- NoHeader: query.NoHeader,
- TemplateUnitFile: query.TemplateUnitFile,
- RestartPolicy: query.RestartPolicy,
- StartTimeout: &query.StartTimeout,
- StopTimeout: &query.StopTimeout,
- ContainerPrefix: ContainerPrefix,
- PodPrefix: PodPrefix,
- Separator: Separator,
- RestartSec: &query.RestartSec,
- Wants: query.Wants,
- After: query.After,
- Requires: query.Requires,
+ Name: query.Name,
+ New: query.New,
+ NoHeader: query.NoHeader,
+ TemplateUnitFile: query.TemplateUnitFile,
+ RestartPolicy: query.RestartPolicy,
+ StartTimeout: &query.StartTimeout,
+ StopTimeout: &query.StopTimeout,
+ ContainerPrefix: ContainerPrefix,
+ PodPrefix: PodPrefix,
+ Separator: Separator,
+ RestartSec: &query.RestartSec,
+ Wants: query.Wants,
+ After: query.After,
+ Requires: query.Requires,
+ AdditionalEnvVariables: query.AdditionalEnvVariables,
}
report, err := containerEngine.GenerateSystemd(r.Context(), utils.GetName(r), options)
diff --git a/pkg/api/server/register_generate.go b/pkg/api/server/register_generate.go
index 82fbe3d09..ac2818db0 100644
--- a/pkg/api/server/register_generate.go
+++ b/pkg/api/server/register_generate.go
@@ -93,6 +93,13 @@ func (s *APIServer) registerGenerateHandlers(r *mux.Router) error {
// type: string
// default: []
// description: Systemd Requires list for the container or pods.
+ // - in: query
+ // name: additionalEnvVariables
+ // type: array
+ // items:
+ // type: string
+ // default: []
+ // description: Set environment variables to the systemd unit files.
// produces:
// - application/json
// responses: