Documentation
¶
Overview ¶
pkg/resources/namespace/namespace.go
Index ¶
- func Create(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, ...) error
- func Delete(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, ...) error
- func DeleteIfOwned(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, ...) error
- func Update(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, ...) error
- type ResolvedNamespaceSpec
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Create ¶
func Create(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, spec ResolvedNamespaceSpec) error
Create creates a Namespace if it does not already exist. Idempotent — skips if the Namespace exists. Owner reference set so Namespace is garbage collected when CR is deleted.
Namespaces have no meaningful spec fields that can drift after creation. There is no Update function — Create is called from both onCreate and onReconcile paths. If it exists, it stays. If it was deleted, it is recreated.
func Delete ¶
func Delete(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, spec ResolvedNamespaceSpec) error
Delete deletes the Namespace if it exists. For most cases owner references handle cleanup automatically — only use this when explicit cleanup control is needed.
func DeleteIfOwned ¶
func DeleteIfOwned(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, name string) error
DeleteIfOwned deletes the Namespace if it exists and is owned by the CR.
func Update ¶
func Update(ctx context.Context, kube kubeclient.KubeClient, owner domain.Object, spec ResolvedNamespaceSpec) error
Update reconciles an existing Namespace to match the resolved spec. Handles drift — if replicas or image have changed, patches the Namespace. If the Namespace does not exist, creates it.
Types ¶
type ResolvedNamespaceSpec ¶
type ResolvedNamespaceSpec struct {
// Name — name. Required.
Name string
// Labels — applied to Namespace metadata.
Labels map[string]string
// Finalizers is an opaque list of values that must be empty to permanently remove object from storage.
// optional
Finalizers []string
// Sleep injects an artificial delay into the reconcile of this resource.
// Useful for autoscale testing, latency simulation, and chaos engineering.
// Accepts extended duration units (s, m, h, d, w, mo, y).
Sleep string
}
ResolvedNamespaceSpec is the fully resolved Namespace specification.
func Resolve ¶
func Resolve(src orktypes.NamespaceTemplateSource, ownerName string) ResolvedNamespaceSpec
Resolve builds a ResolvedNamespaceSpec from a NamespaceTemplateSource. Template expressions must already be evaluated by template.Resolver before calling.