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 to kwargs (you can check the -h of consul-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 as ConsulTemplate.OptionKind.DISABLED.

    See also

    The output of consul-template -h for an exhaustive list of all supported options. The once option is added automatically and therefore should not be added again in the argument. The other option not accepted is version.

Raises:
Returns:

A ConsulTemplateOutput object holding the state returned following execution of consul-template.

New in version 1.22.0.

class consul_template.ConsulTemplate

Implementation of genvid.toolbox.ConsulTemplate