YamlConfigReader

Config reader that reads configuration from YAML file.

Implements: FileConfigReader

Description

The YamlConfigReader allows you to create a config reader that reads a configuration from a YAML file.

Configuration parameters

  • path: path to the configuration file
  • parameters: this entire section is used as template parameters

Constructors

Creates a new instance of the config reader.

YamlConfigReader(path: str = None)

  • path: str - (optional) path to the configuration file.

Instance methods

read_config_

Reads a configuration and parameterizes it with given values.

read_config_(correlation_id: Optional[str], parameters: ConfigParams): ConfigParams

  • correlation_id: Optional[str] - (optional) transaction id to trace execution through a call chain.
  • parameters: ConfigParams - values of the configuration parameters or None to skip parameterization.
  • returns: ConfigParams - ConfigParams configuration.

read_object_

Reads a configuration file, parameterizes its content and converts it into a YAML object.

read_object_(correlation_id: Optional[str], parameters: ConfigParams): Any

  • correlation_id: Optional[str] - (optional) transaction id to trace execution through a call chain.
  • parameters: ConfigParams - values of the configuration parameters.
  • returns: Any - a YAML object with a configuration.

read_config

Reads a configuration from a file, parameterizes it with given values and returns a new ConfigParams object.

static read_config(correlation_id: Optional[str], path: str, parameters: ConfigParams): ConfigParams

  • correlation_id: Optional[str] - (optional) transaction id to trace the execution through a call chain.
  • path: str - a path to configuration file.
  • parameters: ConfigParams - values of the configuration parameters.
  • returns: ConfigParams - ConfigParams configuration.

read_object

Reads a configuration file, parameterizes its content and converts it into a YAML object.

static read_object(correlation_id: Optional[str], path: str, parameters: ConfigParams): Any

  • correlation_id: Optional[str] - (optional) transaction id to trace the execution through a call chain.
  • path: str - a path to configuration file.
  • parameters: ConfigParams - values of the configuration parameters.
  • returns: Any - a YAML object containing a configuration.

Examples

key1: "{{KEY1_VALUE}}"
key2: "{{KEY2_VALUE}}"
configReader = YamlConfigReader("config.yml")
parameters = ConfigParams.from_tuples("KEY1_VALUE", 123, "KEY2_VALUE", "ABC")
configReader.read_config_("123", parameters)

See also