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