tdfs4ds.deploy.plan¶
tdfs4ds.deploy.plan
¶
plan_deployment: compare a bundle of definitions with the TARGET store (the active session) and
decide, object by object, what a deployment does (0.3.8.15). Read-only on the target.
Situations: create (absent), identical (same fingerprint), different (another definition
under the name), unavailable (a required outside object is missing), to_initialise (a
manager that exists but is empty). The conflict policy turns each into a decision: create,
skip, replace or fail. A plan holding a fail cannot be applied.
SITUATIONS
module-attribute
¶
DeploymentError
¶
Bases: RuntimeError
A deployment cannot proceed.
DeploymentPlan
¶
What a deployment of a bundle to one environment does. Deterministic JSON (save).
report
¶
The plan as Markdown (fmt='md') or a standalone HTML page; written when path is given.
Returns the text.
logger_safe
¶
Wrapper around the global logger that only emits logs when
tdfs4ds.DISPLAY_LOGS is True. level is a string like "info", "error", etc.
bundle_root
¶
(root, definitions folder) of a bundle given its root or its definitions folder.
load_definitions
¶
(definitions in deployment order, {key: relative file}, manifest) of a bundle.
load_environment
¶
An environment as a dict: a path to a YAML file or a dict. ${NAME} is expanded from the
process environment (environ). Keys: name, connection, variables, domain_map,
options.
load_policy
¶
The conflict policy: policy (dict or path), else <root>/conflict_policy.yaml, else the defaults.
documentation_covered
¶
True when every part of definition is in target with the same text (extra target parts are allowed: a deployment never deletes documentation). Pure.
fingerprint
¶
The fingerprint of a definition (None for None). Pure.
documentation_parts
¶
{part key: normalised text} of a documentation definition.
resolve_value
¶
{{VAR}} -> the raw value (a database name as it is, for a YAML field or a catalog value).
A non-string passes through; an unknown variable raises KeyError naming it.
reverse_refs
¶
{DB (normalised): VAR} for a database-level rewrite of target text; when two variables share
a value, the first of prefer wins, then the alphabetical order.
dump_json
¶
Deterministic JSON (sorted keys, 2-space indent, LF, trailing newline).
write_text
¶
Write text UTF-8 with LF line ends; parents created. Returns the path.
split_qualified
¶
Split 'db.obj' / '"db"."obj"' / 'obj' into (db, obj) (raw,
de-quoted but original case preserved). db is '' when unqualified.
for_environment
¶
defn with its data domains renamed by the environment's domain_map. Pure.
resolved_name
¶
(database, object) of a definition in the environment (raw database name).
collect_target
¶
{key: {"defn": target definition or None, "state": ..., ...}} for every definition (already
mapped to the environment). Read-only.
_restricted
¶
target limited to what defn declares (a deployment adds, it never deletes settings, terms, properties or documentation parts the target holds besides). Pure.
classify
¶
(situation, target fingerprint, reason) of one definition against what the target holds. Pure.
_domain_missing_properties_only
¶
True when the target holds the domain's clock and settings as the bundle has them and only some of its feature properties are missing (none differs): what an apply stopped before the properties leaves. Pure.
decide
¶
The decision of the policy for one object. Pure.
build_plan
¶
build_plan(defs: List[Dict[str, Any]], files: Dict[str, str], target: Dict[str, Dict[str, Any]], env: Dict[str, Any], policy: Dict[str, Any], *, definitions_path: str = '', manifest: Optional[Dict[str, Any]] = None) -> DeploymentPlan
The plan from definitions (mapped to the environment) and what the target holds. Pure.
cross_database_grants
¶
cross_database_grants(defs: List[Dict[str, Any]], values: Dict[str, str], schema: Optional[str], view_schema: Optional[str]) -> List[Dict[str, Any]]
The SELECT ... WITH GRANT OPTION each target view database needs on what its views read in
another database (Teradata resolves a view with the rights of the database holding it: Error
3523 / 5315 at apply otherwise). Same rule and text as the migration's Databases group
(migration.access). Pure; statements only, never executed.
An object the bundle requires (it exists on the target) is granted by name; an object the deployment creates is granted on its database (an object right on a missing object is refused).
check_grants
¶
Fill each grant's status (granted / missing / unknown) from what the session can read in
DBC (migration.access.read_rights). Read-only, never raises: unreadable = unknown.
plan_deployment
¶
Compare a bundle with the target store (the active session) and plan the deployment. Read-only.
Parameters¶
definitions_path : str
The bundle folder (or its definitions folder).
environment : str | dict
The environment file (environments/<env>.yaml) or its content.
policy : dict | str | None
Conflict policy; None = the bundle's conflict_policy.yaml, else the defaults
(create -> create, identical -> skip, different -> fail, unavailable -> fail).
Returns¶
DeploymentPlan
.actions, .counts, .has_unresolved_conflicts, .save(path), .report(path, fmt).