stages/systemd.unit.create: Environment and EnvironmentFile
Support the Environment and EnvironmentFile options in the Service section of the unit file. The Environment option is set as an object with keys "key" and "value" and the key is validated with a pattern. Updated the stage to special-case the Environment option.
This commit is contained in:
parent
79d788ac23
commit
77e7c0538a
2 changed files with 30 additions and 0 deletions
|
|
@ -23,6 +23,9 @@ def main(tree, options):
|
|||
for option, value in opts.items():
|
||||
if isinstance(value, list):
|
||||
for v in value:
|
||||
if option == "Environment":
|
||||
# Option value becomes "KEY=VALUE" (quoted)
|
||||
v = '"' + v["key"] + "=" + str(v["value"]) + '"'
|
||||
config.set(section, str(option) + "=" + str(v))
|
||||
else:
|
||||
config.set(section, option, str(value))
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@
|
|||
" - 'ExecStartPre' - [string]",
|
||||
" - 'ExecStopPost' - [string]",
|
||||
" - 'ExecStart' - [string]",
|
||||
" - 'Environment' - [object]",
|
||||
" - 'EnvironmentFile' - [string]",
|
||||
" - 'Install' section",
|
||||
" - 'WantedBy' - [string]",
|
||||
" - 'RequiredBy' - [string]"
|
||||
|
|
@ -142,6 +144,31 @@
|
|||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"Environment": {
|
||||
"type": "array",
|
||||
"description": "Sets environment variables for executed process.",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"description": "Sets environment variables for executed process.",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"key": {
|
||||
"type": "string",
|
||||
"pattern": "^[A-Za-z_][A-Za-z0-9_]*"
|
||||
},
|
||||
"value": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"EnvironmentFile": {
|
||||
"type": "array",
|
||||
"description": "Path to file that contains environment variables to set for the process.",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue