saltext.kubernetes.utils._kuberesource¶
Shared helpers for the kuberesource_* companion execution modules.
Each kuberesource_* module is a thin wrapper that pulls resource
identity from __resource__["id"] (set by Salt’s resources-layer
dispatcher) and forwards to the existing kubernetes.* execution
module functions. The shared logic lives here so each companion
module stays small and predictable.
Added in version 2.1.0.
- saltext.kubernetes.utils._kuberesource.virtual_or_dormant()[source]¶
Shared
__virtual__for kuberesource companion modules.Returns
"kubernetes"when Salt’s resources subsystem is loadable, the (False, reason) sentinel otherwise. Identical contract tosaltext.kubernetes.resources.kubernetes.__virtual__.
- saltext.kubernetes.utils._kuberesource.resource_identity(resource_dunder)[source]¶
Parse the active resource’s identity from
__resource__["id"].Schema (mirrors
saltext.kubernetes.resources.kubernetes._make_id):Cluster-scoped:
<kind>:<name>-> (kind, None, name) Namespaced:<kind>:<namespace>/<name>-> (kind, namespace, name)Raises
CommandExecutionErrorif the dunder is missing or malformed — should never happen if the dispatcher is wired correctly, but a clear error beats a NameError when it does.
- saltext.kubernetes.utils._kuberesource.require_kind(actual_kind, *expected_kinds)[source]¶
Reject a dispatch when the resource’s kind doesn’t match any expected.
Companion modules like
kuberesource_cmd(Pod-only),kuberesource_node(Node-only),kuberesource_workload(workload kinds) need to refuse dispatches against the wrong kind early with a clear error.