genvid.toolbox.ConsulTemplate¶
-
class
genvid.toolbox.
ConsulTemplate
(executable: typing.Union[pathlib.Path, str, NoneType] = None)¶ Bases:
object
Thin wrapper API around
consul-template
.-
class
OptionKind
¶ Bases:
enum.Enum
Used to describe the different options to
consul-template
.This is necessary as some of the assumptions made by this wrapper must be enforced at the option level. The following description exists:
FLAG
- The option is supported as a flag (without value).TAKES_VALUE
- The option is supported and requires a value.DISABLED
- The option cannot be used directly.
-
FLAG
= 0¶
-
TAKES_VALUE
= 1¶
-
DISABLED
= 2¶
-
executable
¶ consul-template
binary location.
-
version
¶ Retrieve the version string of
consul-template --version
.This is the only way to retrieve the version through this API as the option is disabled on all other methods.
-
once
(*, env: typing.Union[typing.Mapping[str, str], NoneType] = None, **kwargs) → genvid.toolbox.consul_template.ConsulTemplateOutput¶ Execute
consul-template
in non-daemon form.consul-template
will be started in a subprocess with the--once
option appended automatically. The exact behavior will depend on the options passed tokwargs
(you can check the-h
ofconsul-template
for more information about the command).Parameters: - env –
If provided, will run the subprocess with the provided environment. This is particularly useful if the template depends on a lot on environment variables.
Note
The script will automatically convert all key/values into strings.
- kwargs –
Any parameters recognized by
consul-template
and not marked asConsulTemplate.OptionKind.DISABLED
.See also
The output of
consul-template -h
for an exhaustive list of all supported options. Theonce
option is added automatically and therefore should not be added again in the argument. The other option not accepted is version.
Raises: - ConsulTemplateUseOfDisabledOption – If one of the keyword argument matches an option name which has been explicitely disabled.
- ConsulTemplateUseOfUnknownOption – If one of
the keyword argument does not match any known option to
consul-template
. - ConsulTemplateInvalidUseOfFlag – If a flag option is used with
a non-
None
value which is not abool
. - ConsulTemplateExecutionFailed – If the the
consul-template
process returned an exit code different from 0.
Returns: A
ConsulTemplateOutput
object holding the state returned following execution ofconsul-template
.New in version 1.22.0.
- env –
-
class
-
class
consul_template.
ConsulTemplate
¶ Implementation of
genvid.toolbox.ConsulTemplate