mirror of
https://github.com/containers/podman.git
synced 2025-10-14 09:45:59 +08:00
Handlers for generate systemd
with custom dependencies
This commit includes: * Handlers for generate systemd unit with manually defined dependencies such as: Wants=, After= and Requires= * The new unit and e2e tests for checking generated systemd units for container and pod with custom dependencies * Documented descriptions for custom dependencies options Signed-off-by: Eugene (Evgenii) Shubin <esendjer@gmail.com>
This commit is contained in:
@ -94,6 +94,13 @@ type containerInfo struct {
|
||||
RunRoot string
|
||||
// Add %i and %I to description and execute parts
|
||||
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 containerTemplate = headerTemplate + `
|
||||
@ -101,6 +108,19 @@ const containerTemplate = headerTemplate + `
|
||||
BindsTo={{{{- range $index, $value := .BoundToServices -}}}}{{{{if $index}}}} {{{{end}}}}{{{{ $value }}}}.service{{{{end}}}}
|
||||
After={{{{- range $index, $value := .BoundToServices -}}}}{{{{if $index}}}} {{{{end}}}}{{{{ $value }}}}.service{{{{end}}}}
|
||||
{{{{- 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{{{{- if (eq .IdentifySpecifier true) }}}}-%i{{{{- end}}}}
|
||||
@ -201,6 +221,9 @@ func generateContainerInfo(ctr *libpod.Container, options entities.GenerateSyste
|
||||
CreateCommand: createCommand,
|
||||
RunRoot: runRoot,
|
||||
containerEnv: envs,
|
||||
Wants: options.Wants,
|
||||
After: options.After,
|
||||
Requires: options.Requires,
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
|
Reference in New Issue
Block a user