Skip to main content

Module process_api

Module process_api 

Source
Expand description

Substrate primitive for the Api::namespaced::<Process> binding every workspace consumer of the tatara Process CRD reaches for when it needs a namespace-scoped typed handle from a bare Client + &str namespace pair (no per-crate reconciler context in scope).

Owns the 1-link chain

let api: Api<Process> = Api::namespaced(<client>, <ns>);

that every below-controller-layer + boundary-layer Process-handle consumer hand-authored pre-lift at each namespace-scoped bind site.

Sibling to the ns-scoped K8s-typed-handle family already lifted at:

  • crate::configmap::namespaced — the K8s built-in ConfigMap ns-scoped handle binder, opened for the same tatara-export-worker + tatara-closed-loop-probe consumers that could not thread through a shared reconciler context.
  • tatara_reconciler::context::Context::process_api — the reconciler’s per-request Process-typed handle binder (kept as a forwarder that delegates through THIS substrate primitive post-lift, so a future normalization at the substrate owner reaches BOTH the reconciler-side handler sprawl AND every below-controller boundary/export-worker consumer through ONE owner).
  • tatara_pool_reconciler::context::PoolContext::{pool_api, allocation_api,pools_all_api,allocations_all_api} — the pool-reconciler’s tatara-CRD-typed handle binders.
  • tatara_github_watcher::handler::HandlerState::allocation_api — the github-watcher’s per-request allocation-typed handle binder.

All sibling lifts closed the Api::namespaced(<client>.clone(), <ns>) shape at either a controller-owned context struct (per-CRD binder) or a workspace-wide substrate module (per-K8s-built-in binder). This primitive closes the SAME shape at the tatara Process CRD for the THREE consumer sites that neither own a reconciler context nor thread through a shared per-request state:

  • tatara_reconciler::boundary::evaluate_process_phase — the ConditionKind::ProcessPhase boundary evaluator. Called with a bare Client moved in from check_conditions (no Context in scope; the evaluator sits below the reconciler layer so it can be reused by the tatara-check binary).
  • tatara_reconciler::boundary::check_depends_on — the spec.dependsOn evaluator. Iterates every dep with a client.clone() per row; also called from the boundary layer without a Context.
  • tatara_export_worker::main::read_artifact — the export worker’s ProcessSnapshotSource reader. tatara-export-worker is a below-controller-layer binary that DOES NOT depend on tatara-reconciler (would introduce a cycle) so it cannot reach the reconciler’s Context::process_api.

Pre-lift the 1-link let api: Api<Process> = Api::namespaced( <client>, <ns>) chain recurred at THESE THREE hand-authored consumer sites past the ★★ PRIME-DIRECTIVE ≥ 2 duplication threshold. Post-lift each consumer reads tatara_process::process_api::namespaced(client, ns) and the ns-scoped Process handle binding lives at ONE substrate owner.

§Naming

The module is named [process_api] — the tatara-process crate already owns a top-level crd module carrying the Process type itself, so a bare process submodule would collide with the crate’s own name and read as an accidental self-reference (tatara_process::process::namespaced). process_api names the axis it closes (“build a typed Api for the tatara Process CRD”) explicitly, mirrors the reconciler’s own process_api method on Context, and reads unambiguously at every callsite.

Fixing the concrete K = Process at the primitive lands three guarantees the pre-lift 3-site sprawl could not offer:

  • the two use tatara_process::crd::Process; / use tatara_process::prelude::*; imports at the callsite crates are the ONE typed edge to the Process CRD; any future rename or module-path shift lands at ONE substrate primitive rather than at every consumer;
  • a regression that swapped Api::namespaced for Api::all at ONE callsite is now structurally impossible — the scope choice is owned by the primitive’s name (peer Api::all cluster-wide Process consumers route through tatara_reconciler::context::Context::processes_all_api on the reconciler side; a future workspace-wide cluster-scoped peer composes as process_api::all on this module);
  • a future migration to Api::namespaced_with(client, ns, &ar) (for the same ns-scoped posture through the dynamic-object channel, mirroring tatara-reconciler::ssapply’s DynamicObject consumer) lands at ONE point — every downstream consumer inherits the shift mechanically.

Functions§

namespaced
Bind a namespace-scoped typed Api<Process> handle for Client + ns.