lso.config

A module for loading configuration data, including a configuration schema that data is validated against.

Data is loaded from a file, the location of which may be specified when using load_from_file(). Configuration file location can also be loaded from environment variable $SETTINGS_FILENAME, which is default

behaviour in load().

class lso.config.Config(*, ansible_playbooks_root_dir)

Bases: BaseModel

Simple Configuration class.

Contains the root directory at which Ansible playbooks are present.

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

model_computed_fields = {}

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

model_fields = {'ansible_playbooks_root_dir': FieldInfo(annotation=str, required=True)}

Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

This replaces Model.__fields__ from Pydantic V1.

lso.config.load()

Load a configuration file, located at the path specified in the environment variable $SETTINGS_FILENAME.

Loading and validating the file is performed by load_from_file().

Returns:

a dict containing the parsed configuration parameters

lso.config.load_from_file(file)

Load, validate and return configuration parameters.

Input is validated against this JSON schema:

CONFIG_SCHEMA
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "ansible_playbooks_root_dir": {
      "type": "string"
    }
  },
  "required": [
    "ansible_playbooks_root_dir"
  ],
  "additionalProperties": false
}
Parameters:

filePath object that produces the configuration file.

Returns:

a dict containing the parsed configuration parameters.