Documentation
¶
Index ¶
- type CreateOperation
- type DeleteOperation
- type NamespacedPatchCollector
- func (c *NamespacedPatchCollector) Create(obj runtime.Object)
- func (c *NamespacedPatchCollector) CreateIfNotExists(obj runtime.Object)
- func (c *NamespacedPatchCollector) CreateOrUpdate(obj runtime.Object)
- func (c *NamespacedPatchCollector) Delete(apiVersion, kind, name string)
- func (c *NamespacedPatchCollector) DeleteInBackground(apiVersion, kind, name string)
- func (c *NamespacedPatchCollector) DeleteNonCascading(apiVersion, kind, name string)
- func (c *NamespacedPatchCollector) Operations() []pkg.PatchCollectorOperation
- func (c *NamespacedPatchCollector) PatchWithJQ(jqfilter, apiVersion, kind, name string, opts ...pkg.PatchCollectorOption)
- func (c *NamespacedPatchCollector) PatchWithJSON(jsonPatch any, apiVersion, kind, name string, opts ...pkg.PatchCollectorOption)
- func (c *NamespacedPatchCollector) PatchWithMerge(mergePatch any, apiVersion, kind, name string, ...)
- func (c *NamespacedPatchCollector) WriteOutput(w io.Writer) error
- type Patch
- type PatchCollector
- func (c *PatchCollector) Create(obj any)
- func (c *PatchCollector) CreateIfNotExists(obj any)
- func (c *PatchCollector) CreateOrUpdate(obj any)
- func (c *PatchCollector) Delete(apiVersion string, kind string, namespace string, name string)
- func (c *PatchCollector) DeleteInBackground(apiVersion string, kind string, namespace string, name string)
- func (c *PatchCollector) DeleteNonCascading(apiVersion string, kind string, namespace string, name string)
- func (c *PatchCollector) JQFilter(filter string, apiVersion string, kind string, namespace string, name string, ...)
- func (c *PatchCollector) JSONPatch(patch any, apiVersion string, kind string, namespace string, name string, ...)
- func (c *PatchCollector) MergePatch(patch any, apiVersion string, kind string, namespace string, name string, ...)
- func (c *PatchCollector) Operations() []pkg.PatchCollectorOperation
- func (c *PatchCollector) PatchWithJQ(jqfilter string, apiVersion string, kind string, namespace string, name string, ...)
- func (c *PatchCollector) PatchWithJSON(jsonPatch any, apiVersion string, kind string, namespace string, name string, ...)
- func (c *PatchCollector) PatchWithMerge(mergePatch any, apiVersion string, kind string, namespace string, name string, ...)
- func (c *PatchCollector) WriteOutput(w io.Writer) error
- type PatchOperation
- type Snapshot
- type Snapshots
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateOperation ¶
type CreateOperation string
CreateOperation defines object creation strategies.
const ( Create CreateOperation = "Create" // Always create (fails if exists) CreateOrUpdate CreateOperation = "CreateOrUpdate" // Create or update if exists CreateIfNotExists CreateOperation = "CreateIfNotExists" // Create only if not exists )
type DeleteOperation ¶
type DeleteOperation string
DeleteOperation defines object deletion propagation policies.
const ( // Delete uses foreground propagation: waits for dependents to be deleted first. Delete DeleteOperation = "Delete" // DeleteInBackground uses background propagation: deletes object immediately, // garbage collector handles dependents asynchronously. DeleteInBackground DeleteOperation = "DeleteInBackground" // DeleteNonCascading orphans dependents: removes owner references without deletion. DeleteNonCascading DeleteOperation = "DeleteNonCascading" )
type NamespacedPatchCollector ¶
type NamespacedPatchCollector struct {
// contains filtered or unexported fields
}
NamespacedPatchCollector wraps PatchCollector to automatically inject namespace into all operations. Used for application hooks where the namespace is fixed and should not be specified by the caller. Note: This collector is not thread-safe; do not use concurrently.
func NewNamespacedCollector ¶
func NewNamespacedCollector(namespace string, logger *log.Logger) *NamespacedPatchCollector
func (*NamespacedPatchCollector) Create ¶
func (c *NamespacedPatchCollector) Create(obj runtime.Object)
Create creates the object in the cluster.
func (*NamespacedPatchCollector) CreateIfNotExists ¶
func (c *NamespacedPatchCollector) CreateIfNotExists(obj runtime.Object)
CreateIfNotExists creates the object only if it does not already exist.
func (*NamespacedPatchCollector) CreateOrUpdate ¶
func (c *NamespacedPatchCollector) CreateOrUpdate(obj runtime.Object)
CreateOrUpdate creates the object if it does not exist, or updates it if it does.
func (*NamespacedPatchCollector) Delete ¶
func (c *NamespacedPatchCollector) Delete(apiVersion, kind, name string)
Delete removes the object using foreground cascading deletion.
func (*NamespacedPatchCollector) DeleteInBackground ¶
func (c *NamespacedPatchCollector) DeleteInBackground(apiVersion, kind, name string)
DeleteInBackground removes the object immediately while the garbage collector deletes dependents in the background.
func (*NamespacedPatchCollector) DeleteNonCascading ¶
func (c *NamespacedPatchCollector) DeleteNonCascading(apiVersion, kind, name string)
DeleteNonCascading removes the object without deleting its dependents (orphans them).
func (*NamespacedPatchCollector) Operations ¶
func (c *NamespacedPatchCollector) Operations() []pkg.PatchCollectorOperation
Operations returns all collected operations
func (*NamespacedPatchCollector) PatchWithJQ ¶
func (c *NamespacedPatchCollector) PatchWithJQ(jqfilter, apiVersion, kind, name string, opts ...pkg.PatchCollectorOption)
PatchWithJQ mutates the object using a jq filter expression.
func (*NamespacedPatchCollector) PatchWithJSON ¶
func (c *NamespacedPatchCollector) PatchWithJSON(jsonPatch any, apiVersion, kind, name string, opts ...pkg.PatchCollectorOption)
PatchWithJSON applies a RFC6902 JSON Patch to the object.
func (*NamespacedPatchCollector) PatchWithMerge ¶
func (c *NamespacedPatchCollector) PatchWithMerge(mergePatch any, apiVersion, kind, name string, opts ...pkg.PatchCollectorOption)
PatchWithMerge applies a RFC7396 JSON Merge Patch to the object.
func (*NamespacedPatchCollector) WriteOutput ¶
func (c *NamespacedPatchCollector) WriteOutput(w io.Writer) error
WriteOutput serializes all collected operations as newline-delimited JSON.
type Patch ¶
type Patch struct {
// contains filtered or unexported fields
}
Patch represents a single patch operation with its parameters stored as a map. The patchValues map is serialized to JSON when sent to the shell-operator.
func (*Patch) Description ¶
Description returns a human-readable description of the patch operation. Returns "unknown" if operation type is missing or invalid.
func (*Patch) WithIgnoreHookError ¶
WithIgnoreHookError continues execution even if this patch fails.
func (*Patch) WithIgnoreMissingObject ¶
WithIgnoreMissingObject prevents errors when the target object doesn't exist.
func (*Patch) WithSubresource ¶
WithSubresource sets the subresource to patch (e.g., "status", "scale").
type PatchCollector ¶
type PatchCollector struct {
// contains filtered or unexported fields
}
PatchCollector collects Kubernetes object patch operations to be applied after hook execution. Supports create, delete, and various patch operations (JSON Patch, Merge Patch, JQ filter). Note: This collector is not thread-safe; do not use concurrently.
func NewCollector ¶
func NewCollector(logger *log.Logger) *PatchCollector
NewCollector creates an empty collector ready to accumulate patch operations.
func (*PatchCollector) Create ¶
func (c *PatchCollector) Create(obj any)
func (*PatchCollector) CreateIfNotExists ¶
func (c *PatchCollector) CreateIfNotExists(obj any)
func (*PatchCollector) CreateOrUpdate ¶
func (c *PatchCollector) CreateOrUpdate(obj any)
func (*PatchCollector) Delete ¶
func (c *PatchCollector) Delete(apiVersion string, kind string, namespace string, name string)
func (*PatchCollector) DeleteInBackground ¶
func (c *PatchCollector) DeleteInBackground(apiVersion string, kind string, namespace string, name string)
func (*PatchCollector) DeleteNonCascading ¶
func (c *PatchCollector) DeleteNonCascading(apiVersion string, kind string, namespace string, name string)
func (*PatchCollector) JQFilter ¶
func (c *PatchCollector) JQFilter(filter string, apiVersion string, kind string, namespace string, name string, opts ...pkg.PatchCollectorOption)
func (*PatchCollector) JSONPatch ¶
func (c *PatchCollector) JSONPatch(patch any, apiVersion string, kind string, namespace string, name string, opts ...pkg.PatchCollectorOption)
func (*PatchCollector) MergePatch ¶
func (c *PatchCollector) MergePatch(patch any, apiVersion string, kind string, namespace string, name string, opts ...pkg.PatchCollectorOption)
func (*PatchCollector) Operations ¶
func (c *PatchCollector) Operations() []pkg.PatchCollectorOperation
Operations returns all collected operations
func (*PatchCollector) PatchWithJQ ¶
func (c *PatchCollector) PatchWithJQ(jqfilter string, apiVersion string, kind string, namespace string, name string, opts ...pkg.PatchCollectorOption)
func (*PatchCollector) PatchWithJSON ¶
func (c *PatchCollector) PatchWithJSON(jsonPatch any, apiVersion string, kind string, namespace string, name string, opts ...pkg.PatchCollectorOption)
func (*PatchCollector) PatchWithMerge ¶
func (c *PatchCollector) PatchWithMerge(mergePatch any, apiVersion string, kind string, namespace string, name string, opts ...pkg.PatchCollectorOption)
func (*PatchCollector) WriteOutput ¶
func (c *PatchCollector) WriteOutput(w io.Writer) error
WriteOutput serializes all collected operations as newline-delimited JSON.
type PatchOperation ¶
type PatchOperation string
PatchOperation defines how patches are applied to objects.
const ( MergePatch PatchOperation = "MergePatch" // RFC7396 JSON Merge Patch JQPatch PatchOperation = "JQPatch" // Mutate object with jq expression JSONPatch PatchOperation = "JSONPatch" // RFC6902 JSON Patch (op/path/value) )