genvid.toolbox.ConfigurationLoader¶
-
class
genvid.toolbox.
ConfigurationLoader
(tool: genvid.toolbox.basetool.BaseTool, renderer: typing.Union[typing.Callable[[typing.Union[pathlib.Path, str], typing.Union[typing.Mapping[str, str], NoneType]], typing.Any], NoneType] = None)¶ Bases:
object
This class provides methods to load or update configurations described by templates.
New in version 1.33.0.
-
TemplateRenderer
= typing.Callable[[typing.Union[pathlib.Path, str], typing.Union[typing.Mapping[str, str], NoneType]], typing.Any]¶
-
load_config_folder
(source: typing.Union[pathlib.Path, str], *, env: typing.Union[typing.Mapping[str, str], NoneType] = None, job_template_dir: typing.Union[pathlib.Path, str, NoneType] = None, with_consul_template: bool = False) → dict¶ Loads the configuration file(s) (all files in a directory or a specific file) from the source and returns it.
Parameters: - source – Path to the configuration file/folder.
- with_consul_template – Execute consul-template on the configuration file(s) (if source is a directory) before using it only if it is set to true.
- job_template_dir – Path to Folder from where nomad templates should be loaded. If not mentioned, no jobs will be loaded.
- env – An optional environment to use with
consul-template
. If None, the default environment will be used.
Returns: The configuration as a dictionary that can be used directly with
set_config()
.Raises: FileNotFoundError – If the
job_template_dir
is notNone
and is not a valid directory.New in version 1.30.0.
Changed in version 1.33.0: Moved from
ProjectTool
.
-
load_nomad_job_template
(name, job_folder: typing.Union[pathlib.Path, str])¶ Read nomad job templates from the specific directory. Files only with extension of .nomad.tmpl are read.
Parameters: - name – Name of the file without extension.
- job_folder – Path to directory containing jobs.
New in version 1.30.0: Add support for
pathlib.Path
as job_folder.Changed in version 1.33.0: Moved from
ProjectTool
.
-
update_config
(config: dict, isLocal: bool)¶ Update the specified configuration.
Parameters: - config – The configuration to update.
- isLocal – If the configuration is for a local cluster or a remote cluster.
Returns: The updated configuration.
New in version 1.31.0.
Changed in version 1.33.0: Moved from
ProjectTool
.
-
-
class
project.
ConfigurationLoader
¶ Implementation of
genvid.toolbox.ConfigurationLoader