saltext.kubernetes.utils._kinds

Kind registry for the saltext-kubernetes extension.

A single source of truth for per-Kubernetes-kind metadata used by the wait subsystem and (future) the operations modules:

  • which kubernetes-client API class hosts the kind’s CRUD methods (e.g. CoreV1Api for Pod, AppsV1Api for Deployment)

  • the name of the list_* and read_* methods on that class

  • whether the kind is namespaced or cluster-scoped

  • a readiness predicate evaluated against a live API object

Adding a new typed kind is one entry in _KIND_REGISTRY plus its public CRUD functions on kubernetesmod. Before this registry existed the kind→method mapping lived as a duplicated literal dict in _wait_for_resource_status() (twice — once for the “deleted” path’s read_* lookup, once for the “created/ready” path’s list_* lookup).

class saltext.kubernetes.utils._kinds.KindOps(api_class_attr: str, list_method: str, read_method: str, namespaced: bool, ready_predicate: Callable[[object], bool])[source]

Per-kind metadata for the wait subsystem.

api_class_attr: str

Attribute name on kubernetes.client (e.g. "AppsV1Api").

list_method: str

Method on the API class used by Watch.stream (e.g. "list_namespaced_deployment").

read_method: str

Method on the API class used for existence checks (e.g. "read_namespaced_deployment").

namespaced: bool

False for cluster-scoped kinds (Node, StorageClass, Namespace, …).

ready_predicate: Callable[[object], bool]

Returns True when an API object is considered Ready.

saltext.kubernetes.utils._kinds.match_condition(obj, condition_type, expected_status='True')[source]

Match obj.status.conditions[?type == condition_type].status.

Mirrors kubectl wait --for=condition=Ready=true semantics.

Returns True when a condition with the given type is present and its status matches expected_status (case-insensitive).

saltext.kubernetes.utils._kinds.match_jsonpath(obj, path, value=None, regex=None)[source]

Match obj against a kubectl-style jsonpath.

Returns True when:

  • value is given and the resolved value equals value, OR

  • regex is given and the stringified value matches re.search, OR

  • neither is given and the resolved value is truthy (existence test).

Returns False if the path does not resolve.

saltext.kubernetes.utils._kinds.build_predicate(condition=None, status='True', jsonpath=None, value=None, regex=None)[source]

Build a predicate callable from user-supplied wait criteria.

Exactly one of condition or jsonpath must be set. The returned callable accepts a live API object and returns a bool.

saltext.kubernetes.utils._kinds.get_kind(resource_type: str) KindOps[source]

Return the KindOps for resource_type.

Raised exception type matches the legacy CommandExecutionError("Unsupported resource type for wait operation: ...") behaviour so existing callers and tests are not surprised.