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
SUPPORTED_OPTIONS = {'config': <OptionKind.TAKES_VALUE: 1>, 'consul_transport_tls_handshake_timeout': <OptionKind.TAKES_VALUE: 1>, 'vault_ssl': <OptionKind.FLAG: 0>, 'vault_ssl_ca_cert': <OptionKind.TAKES_VALUE: 1>, 'exec_splay': <OptionKind.TAKES_VALUE: 1>, 'vault_transport_dial_keep_alive': <OptionKind.TAKES_VALUE: 1>, 'vault_retry': <OptionKind.FLAG: 0>, 'kill_signal': <OptionKind.TAKES_VALUE: 1>, 'retry': <OptionKind.TAKES_VALUE: 1>, 'vault_retry_backoff': <OptionKind.TAKES_VALUE: 1>, 'vault_agent_token_file': <OptionKind.TAKES_VALUE: 1>, 'dry': <OptionKind.FLAG: 0>, 'syslog': <OptionKind.FLAG: 0>, 'consul_token': <OptionKind.TAKES_VALUE: 1>, 'exec': <OptionKind.TAKES_VALUE: 1>, 'pid_file': <OptionKind.TAKES_VALUE: 1>, 'consul_transport_disable_keep_alives': <OptionKind.FLAG: 0>, 'syslog_facility': <OptionKind.TAKES_VALUE: 1>, 'vault_transport_max_idle_conns_per_host': <OptionKind.TAKES_VALUE: 1>, 'consul_auth': <OptionKind.TAKES_VALUE: 1>, 'consul_addr': <OptionKind.TAKES_VALUE: 1>, 'vault_ssl_cert': <OptionKind.TAKES_VALUE: 1>, 'dedup': <OptionKind.FLAG: 0>, 'exec_kill_timeout': <OptionKind.TAKES_VALUE: 1>, 'template': <OptionKind.TAKES_VALUE: 1>, 'wait': <OptionKind.FLAG: 0>, 'exec_kill_signal': <OptionKind.TAKES_VALUE: 1>, 'consul_retry_max_backoff': <OptionKind.TAKES_VALUE: 1>, 'vault_unwrap_token': <OptionKind.FLAG: 0>, 'version': <OptionKind.DISABLED: 2>, 'consul_ssl_cert': <OptionKind.TAKES_VALUE: 1>, 'vault_ssl_server_name': <OptionKind.TAKES_VALUE: 1>, 'vault_transport_disable_keep_alives': <OptionKind.FLAG: 0>, 'vault_renew_token': <OptionKind.FLAG: 0>, 'consul_ssl_ca_cert': <OptionKind.TAKES_VALUE: 1>, 'vault_ssl_ca_path': <OptionKind.TAKES_VALUE: 1>, 'reload_signal': <OptionKind.TAKES_VALUE: 1>, 'consul_transport_max_idle_conns_per_host': <OptionKind.TAKES_VALUE: 1>, 'max_stale': <OptionKind.TAKES_VALUE: 1>, 'vault_ssl_verify': <OptionKind.FLAG: 0>, 'vault_transport_tls_handshake_timeout': <OptionKind.TAKES_VALUE: 1>, 'consul_retry_attempts': <OptionKind.TAKES_VALUE: 1>, 'vault_addr': <OptionKind.TAKES_VALUE: 1>, 'consul_retry_backoff': <OptionKind.TAKES_VALUE: 1>, 'consul_ssl': <OptionKind.FLAG: 0>, 'exec_reload_signal': <OptionKind.TAKES_VALUE: 1>, 'consul_transport_dial_keep_alive': <OptionKind.TAKES_VALUE: 1>, 'vault_ssl_key': <OptionKind.TAKES_VALUE: 1>, 'once': <OptionKind.DISABLED: 2>, 'consul_ssl_server_name': <OptionKind.TAKES_VALUE: 1>, 'consul_retry': <OptionKind.FLAG: 0>, 'vault_retry_attempts': <OptionKind.TAKES_VALUE: 1>, 'consul_ssl_ca_path': <OptionKind.TAKES_VALUE: 1>, 'consul_ssl_key': <OptionKind.TAKES_VALUE: 1>, 'vault_token': <OptionKind.TAKES_VALUE: 1>, 'vault_grace': <OptionKind.TAKES_VALUE: 1>, 'consul_transport_dial_timeout': <OptionKind.TAKES_VALUE: 1>, 'consul_ssl_verify': <OptionKind.FLAG: 0>, 'vault_transport_dial_timeout': <OptionKind.TAKES_VALUE: 1>, 'log_level': <OptionKind.TAKES_VALUE: 1>, 'vault_retry_max_backoff': <OptionKind.TAKES_VALUE: 1>}

Options defined by consul-template.

We store a ConsulTemplate.OptionKind describing the option’s usage in this API.

See also

ConsulTemplate.OptionKind for more information.

For more information about what is the purpose of each option, it is suggested to execute the consul-template binary directly with the -h option.

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.

Raises:
Returns:

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

New in version 1.21.0.

class consul_template.ConsulTemplate

Implementation of genvid.toolbox.ConsulTemplate