Module documentation — bc-configs • Make configurations easy 0.2.2 documentation

# Module documentation

- Configurator
  - About
    - Building the environment variable name
    - Customizing the environment variable name
    - Casting the environment variable value
    - Optional fields
    - Default values
    - `BaseConfig`
  - BaseConfig
    - `BaseConfig`
- Environ Source
  - About
    - `EnvironSourceException`
    - `VaultConfig`
      - `VaultConfig.address`
      - `VaultConfig.mount`
      - `VaultConfig.password`
      - `VaultConfig.path`
      - `VaultConfig.token`
      - `VaultConfig.username`
      - `VaultConfig.has_filled_connect_fields()`
      - `VaultConfig.need_to_use()`
    - `define()`
  - Content
  - define
    - `define()`
  - VaultConfig
    - `VaultConfig`
      - `VaultConfig.address`
      - `VaultConfig.mount`
      - `VaultConfig.password`
      - `VaultConfig.path`
      - `VaultConfig.token`
      - `VaultConfig.username`
      - `VaultConfig.has_filled_connect_fields()`
      - `VaultConfig.need_to_use()`
  - EnvironSourceException
    - `EnvironSourceException`

pydantic model bc_configs.BaseConfig

  Bases: `BaseModel`, `ABC`

  Provides to receive values from the environment variables on the validation step of pydantic model.

  Show JSON schema

      {
         "title": "BaseConfig",
         "description": "Provides to receive values from the environment variables on the validation step of\npydantic model.",
         "type": "object",
         "properties": {}
      }

  Validators:

    - `_populate_from_env` » `all fields`

exception bc_configs.EnvironSourceException

  Bases: `Exception`

  Exception raised when there is an issue with the environment source.

pydantic model bc_configs.VaultConfig

  Bases: `BaseConfig`

  Configuration for HashiCorp Vault.

  Show JSON schema

      {
         "title": "VaultConfig",
         "description": "Configuration for HashiCorp Vault.",
         "type": "object",
         "properties": {
            "address": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The address of the Vault server.",
               "title": "Address"
            },
            "mount": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The mount point of the Vault server.",
               "title": "Mount"
            },
            "path": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The path to the secret in the Vault.",
               "title": "Path"
            },
            "token": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The authentication token for accessing the Vault.",
               "title": "Token"
            },
            "username": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The username for authentication (if token is not provided).",
               "title": "Username"
            },
            "password": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "The password for authentication (if token is not provided).",
               "title": "Password"
            }
         }
      }

  Fields:

    - `address (str | None)`

    - `mount (str | None)`

    - `password (str | None)`

    - `path (str | None)`

    - `token (str | None)`

    - `username (str | None)`

  Validators:

    - `_populate_from_env` » `all fields`

  field address: str | None = None

    The address of the Vault server.

    Validated by:

      - `_populate_from_env`

  field mount: str | None = None

    The mount point of the Vault server.

    Validated by:

      - `_populate_from_env`

  field password: str | None = None

    The password for authentication (if token is not provided).

    Validated by:

      - `_populate_from_env`

  field path: str | None = None

    The path to the secret in the Vault.

    Validated by:

      - `_populate_from_env`

  field token: str | None = None

    The authentication token for accessing the Vault.

    Validated by:

      - `_populate_from_env`

  field username: str | None = None

    The username for authentication (if token is not provided).

    Validated by:

      - `_populate_from_env`

  has_filled_connect_fields() → bool

    Check if all connect fields are filled.

    Returns:

      True if all fields are filled, False otherwise.

    Return type:

      bool

  need_to_use() → bool

    Check if the token or username and password are provided.

    Returns:

      True if the token or username and password are provided, False otherwise.

    Return type:

      bool

bc_configs.define(*, vault_config: VaultConfig | None = None) → None

  Define the configuration for the application.

  Parameters:

    vault_config (VaultConfig | None) – The configuration for accessing secrets from a vault. Defaults to None.