genvid.toolbox.ConsulTemplate
- class genvid.toolbox.ConsulTemplate
Bases:
objectThin wrapper API around
consul-template.- class OptionKind
Bases:
EnumUsed 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
- __init__(executable: Optional[Union[Path, str]] = None)
Initialize the wrapper.
- Parameters:
executable – Path to the
consul-templatebinary file.- Raises:
ConsulTemplateExecutableNotFound – If the executable couldn’t be found or the permissions didn’t allow execution of the binary.
- property executable
consul-templatebinary location.
- property 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: Optional[Mapping[str, str]] = None, **kwargs) ConsulTemplateOutput
Execute
consul-templatein non-daemon form.consul-templatewill be started in a subprocess with the--onceoption appended automatically. The exact behavior will depend on the options passed tokwargs(you can check the-hofconsul-templatefor 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-templateand not marked asConsulTemplate.OptionKind.DISABLED.See also
The output of
consul-template -hfor an exhaustive list of all supported options. Theonceoption 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-
Nonevalue which is not abool.ConsulTemplateExecutionFailed – If the the
consul-templateprocess returned an exit code different from 0.
- Returns:
A
ConsulTemplateOutputobject holding the state returned following execution ofconsul-template.
New in version 1.22.0.
- class consul_template.ConsulTemplate
Implementation of
genvid.toolbox.ConsulTemplate