Skip to content

resolve

etl_craft.config.resolve

Resolving settings: every value is a variable name or a value.

A setting whose text is a valid variable name, and that the secrets source defines, takes that variable's value; anything else is used exactly as written. So Profile: dev is the profile dev unless a variable named dev is set, and Profile: ETL_CRAFT_PROFILE is whatever that variable holds. For a profile's own fields, a profile-specific variable wins over the plain name: ENGINE_PROD_SECRET over ENGINE_SECRET for the prod profile.

Secrets are the exception. A secret field must name a variable, and that variable must be set: the file is meant to be committed, and falling back to the text would send a mistyped variable name to the server as a password.

Resolver dataclass

Resolves settings against one set of variables and records where each value came from.

origin names the source in error messages; path is the config file.

for_source classmethod

for_source(source: SourceConfig, path: Path) -> Resolver

Build the resolver for everything after Secrets.

selected_name

selected_name(var_name: str, profile: str | None, field_name: str | None) -> str

Return the profile-specific variable when it is set, else var_name.

resolve

resolve(raw: Any, where: str, *, profile: str | None = None, field_name: str | None = None) -> Any

Return raw resolved: a set variable's value, else raw itself.

Lists resolve item by item; values YAML already typed (numbers, booleans) are returned as they are.

text

text(raw: Any, where: str, *, profile: str | None = None, field_name: str | None = None) -> str | None

Resolve a setting that must be a non-empty string; None when it is absent.

secret_name

secret_name(raw: Any, where: str, *, profile: str | None, field_name: str) -> str | None

Return the variable a secret field names, or None when the field is absent.

Raises ConfigurationError when the field is not a variable name, or names one that is not set. Only the selected profile is parsed, so another environment's secrets need not be present.

missing_hint

missing_hint(name: str) -> str

Suggest similarly named variables without showing any of their values.

hint

hint(where: str) -> str

Explain a bad value that was used as written because no variable by its name is set.

read_secrets_file

read_secrets_file(path: str | None) -> dict[str, str]

Read the .env file Secrets.Path names; ConfigurationError if it is unreadable.

source_values

source_values(source: SourceConfig) -> Mapping[str, str]

Return the variables the secrets source defines.

profile_variable_name

profile_variable_name(var_name: str, profile: str, field_name: str) -> str | None

Insert the profile before a field's suffix: ENGINE_SECRET becomes ENGINE_DEV_SECRET.

Returns None when var_name does not end with the field's name, and var_name itself when it already carries the profile. from_address also matches _FROM.

resolve_secret

resolve_secret(config: ConnectorConfig, profile: ConnectionProfile | EmailProfile) -> str

Read profile's secret from the secrets source, as it is now.

Raises ConfigurationError if the variable is no longer set.

resolve_named_secret

resolve_named_secret(config: ConnectorConfig, name: str) -> str

Resolve an additional connection secret without retaining it in the config.

profile_needs_secret

profile_needs_secret(profile: ConnectionProfile | EmailProfile) -> bool

Whether connecting with profile reads a secret.

profile_secret

profile_secret(config: ConnectorConfig, profile: ConnectionProfile | EmailProfile) -> str

Return profile's secret, or "" when its auth mode presents none.

none, sts and sso without a client secret have nothing to present; a key file's passphrase is read when the profile names one.