diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-01-19 20:29:01 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-19 20:29:01 -0500 |
commit | 7fc8bf4a428c08fcb9c9e97d238628319a20986e (patch) | |
tree | ddcd1faacca37f72bafc6f3bc77c55f3829eb387 /pkg/systemd/generate/pods.go | |
parent | 6b59b10248b0bd92127dfc455ca40579d4c396a0 (diff) | |
parent | b9a2d8698a22c4b267e252caad56d8b31fcadd38 (diff) | |
download | podman-7fc8bf4a428c08fcb9c9e97d238628319a20986e.tar.gz podman-7fc8bf4a428c08fcb9c9e97d238628319a20986e.tar.bz2 podman-7fc8bf4a428c08fcb9c9e97d238628319a20986e.zip |
Merge pull request #12887 from esendjer/main
Add custom defined dependencies to podman generate systemd
Diffstat (limited to 'pkg/systemd/generate/pods.go')
-rw-r--r-- | pkg/systemd/generate/pods.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/pkg/systemd/generate/pods.go b/pkg/systemd/generate/pods.go index 17e1dc5a2..003c23e77 100644 --- a/pkg/systemd/generate/pods.go +++ b/pkg/systemd/generate/pods.go @@ -83,10 +83,30 @@ type podInfo struct { RunRoot string // Add %i and %I to description and execute parts - this should not be used IdentifySpecifier bool + // Wants are the list of services that this service is (weak) dependent on. This + // option does not influence the order in which services are started or stopped. + Wants []string + // After ordering dependencies between the list of services and this service. + After []string + // Similar to Wants, but declares a stronger requirement dependency. + Requires []string } const podTemplate = headerTemplate + `Requires={{{{- range $index, $value := .RequiredServices -}}}}{{{{if $index}}}} {{{{end}}}}{{{{ $value }}}}.service{{{{end}}}} Before={{{{- range $index, $value := .RequiredServices -}}}}{{{{if $index}}}} {{{{end}}}}{{{{ $value }}}}.service{{{{end}}}} +{{{{- if or .Wants .After .Requires }}}} + +# User-defined dependencies +{{{{- end}}}} +{{{{- if .Wants}}}} +Wants={{{{- range $index, $value := .Wants }}}}{{{{ if $index}}}} {{{{end}}}}{{{{ $value }}}}{{{{end}}}} +{{{{- end}}}} +{{{{- if .After}}}} +After={{{{- range $index, $value := .After }}}}{{{{ if $index}}}} {{{{end}}}}{{{{ $value }}}}{{{{end}}}} +{{{{- end}}}} +{{{{- if .Requires}}}} +Requires={{{{- range $index, $value := .Requires }}}}{{{{ if $index}}}} {{{{end}}}}{{{{ $value }}}}{{{{end}}}} +{{{{- end}}}} [Service] Environment={{{{.EnvVariable}}}}=%n |