yera.creds.loaders
Credential key validation and transformation helpers.
Symbols
flatten_json
flatten_json(
obj: dict[str, Any],
prefix: str,
) → dict[str, str]Recursively flatten obj into dotted keys rooted at prefix.
Returns a flat {dotted_key: str_value} mapping.
Raises
a flattened key fails structural validation, two source entries produce the same flattened key (duplicate collision), or two flattened keys stand in a prefix relationship (leaf-namespace conflict).
a leaf value is not a string.
is_leaf
is_leaf(
key: str,
creds: dict[str, dict[str, Any]],
) → boolReturn True when key is a stored credential leaf.
is_namespace
is_namespace(
key: str,
creds: dict[str, dict[str, Any]],
) → boolReturn True when leaves exist under key (proper prefix).
leaves_under
leaves_under(
path: str,
creds: dict[str, dict[str, Any]],
) → dict[str, dict[str, Any]]Return all leaf entries whose key starts with path + '.'.
raise_if_credential_group_key_prefix_conflict
raise_if_credential_group_key_prefix_conflict(
credentials: dict[str, Any],
group_name: str,
credentials_file: Path,
) → NoneRaise if credentials keys contain a leaf-namespace prefix pair.
Raises
includes group_name and credentials_file in the message.
raise_if_flat_credential_keys_prefix_conflict
raise_if_flat_credential_keys_prefix_conflict(
keys: Iterable[str],
prefix_message: str,
) → NoneRaise if any key is a proper dotted prefix of another (leaf-namespace conflict).
keys are dotted credential paths. After sorting, only adjacent pairs need
checking: if K immediately precedes K.<segment> lexicographically among
sorted keys, every prefix relationship appears as some adjacent pair.
Raises
two keys stand in prefix relationship.
validate_credential_group_name
validate_credential_group_name(
name: str,
) → NoneValidate a credential group name.
A valid credential group name:
- Is non-empty and not whitespace-only.
- Contains no dots (
.). - Contains no control characters (U+0000-U+001F).
Raises
the name fails any structural rule.
validate_credential_key
validate_credential_key(
key: str,
) → NoneValidate a credential key as a dotted path.
A valid key:
- Is non-empty.
- When split on
".", produces only non-empty segments (no leading dot, trailing dot, or consecutive dots). - Contains no control characters (U+0000-U+001F) in any segment.
Raises
the key fails any structural rule.