{"modulePath":"github.com/deckhouse/module-sdk","version":"v0.14.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package objectpatch\n\n## Types\n\n```go\ntype CreateOperation string\n```\nCreateOperation defines object creation strategies.\n\n```go\nconst (\n\tCreate            CreateOperation = \"Create\"            // Always create (fails if exists)\n\tCreateOrUpdate    CreateOperation = \"CreateOrUpdate\"    // Create or update if exists\n\tCreateIfNotExists CreateOperation = \"CreateIfNotExists\" // Create only if not exists\n)\n```\n\n```go\ntype DeleteOperation string\n```\nDeleteOperation defines object deletion propagation policies.\n\n```go\nconst (\n\t// Delete uses foreground propagation: waits for dependents to be deleted first.\n\tDelete DeleteOperation = \"Delete\"\n\t// DeleteInBackground uses background propagation: deletes object immediately,\n\t// garbage collector handles dependents asynchronously.\n\tDeleteInBackground DeleteOperation = \"DeleteInBackground\"\n\t// DeleteNonCascading orphans dependents: removes owner references without deletion.\n\tDeleteNonCascading DeleteOperation = \"DeleteNonCascading\"\n)\n```\n\n```go\ntype NamespacedPatchCollector struct {\n\t// contains filtered or unexported fields\n}\n```\nNamespacedPatchCollector 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.\n\n```go\nfunc NewNamespacedCollector(namespace string, logger *log.Logger) *NamespacedPatchCollector\n```\n\n```go\nfunc (c *NamespacedPatchCollector) Create(obj runtime.Object)\n```\nCreate creates the object in the cluster.\n\n```go\nfunc (c *NamespacedPatchCollector) CreateIfNotExists(obj runtime.Object)\n```\nCreateIfNotExists creates the object only if it does not already exist.\n\n```go\nfunc (c *NamespacedPatchCollector) CreateOrUpdate(obj runtime.Object)\n```\nCreateOrUpdate creates the object if it does not exist, or updates it if it does.\n\n```go\nfunc (c *NamespacedPatchCollector) Delete(apiVersion, kind, name string)\n```\nDelete removes the object using foreground cascading deletion.\n\n```go\nfunc (c *NamespacedPatchCollector) DeleteInBackground(apiVersion, kind, name string)\n```\nDeleteInBackground removes the object immediately while the garbage collector deletes dependents in the background.\n\n```go\nfunc (c *NamespacedPatchCollector) DeleteNonCascading(apiVersion, kind, name string)\n```\nDeleteNonCascading removes the object without deleting its dependents (orphans them).\n\n```go\nfunc (c *NamespacedPatchCollector) Operations() []pkg.PatchCollectorOperation\n```\nOperations returns all collected operations\n\n```go\nfunc (c *NamespacedPatchCollector) PatchWithJQ(jqfilter, apiVersion, kind, name string, opts ...pkg.PatchCollectorOption)\n```\nPatchWithJQ mutates the object using a jq filter expression.\n\n```go\nfunc (c *NamespacedPatchCollector) PatchWithJSON(jsonPatch any, apiVersion, kind, name string, opts ...pkg.PatchCollectorOption)\n```\nPatchWithJSON applies a RFC6902 JSON Patch to the object.\n\n```go\nfunc (c *NamespacedPatchCollector) PatchWithMerge(mergePatch any, apiVersion, kind, name string, opts ...pkg.PatchCollectorOption)\n```\nPatchWithMerge applies a RFC7396 JSON Merge Patch to the object.\n\n```go\nfunc (c *NamespacedPatchCollector) WriteOutput(w io.Writer) error\n```\nWriteOutput serializes all collected operations as newline-delimited JSON.\n\n```go\ntype Patch struct {\n\t// contains filtered or unexported fields\n}\n```\nPatch 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.\n\n```go\nfunc (p *Patch) Description() string\n```\nDescription returns a human-readable description of the patch operation. Returns \"unknown\" if operation type is missing or invalid.\n\n```go\nfunc (p *Patch) SetObjectPrefix(prefix string)\n```\nSetObjectPrefix sets prefix for object name.\n\n```go\nfunc (p *Patch) WithIgnoreHookError(ignore bool)\n```\nWithIgnoreHookError continues execution even if this patch fails.\n\n```go\nfunc (p *Patch) WithIgnoreMissingObject(ignore bool)\n```\nWithIgnoreMissingObject prevents errors when the target object doesn't exist.\n\n```go\nfunc (p *Patch) WithSubresource(subresource string)\n```\nWithSubresource sets the subresource to patch (e.g., \"status\", \"scale\").\n\n```go\ntype PatchCollector struct {\n\t// contains filtered or unexported fields\n}\n```\nPatchCollector 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.\n\n```go\nfunc NewCollector(logger *log.Logger) *PatchCollector\n```\nNewCollector creates an empty collector ready to accumulate patch operations.\n\n```go\nfunc (c *PatchCollector) Create(obj any)\n```\n\n```go\nfunc (c *PatchCollector) CreateIfNotExists(obj any)\n```\n\n```go\nfunc (c *PatchCollector) CreateOrUpdate(obj any)\n```\n\n```go\nfunc (c *PatchCollector) Delete(apiVersion string, kind string, namespace string, name string)\n```\n\n```go\nfunc (c *PatchCollector) DeleteInBackground(apiVersion string, kind string, namespace string, name string)\n```\n\n```go\nfunc (c *PatchCollector) DeleteNonCascading(apiVersion string, kind string, namespace string, name string)\n```\n\n```go\nfunc (c *PatchCollector) JQFilter(filter string, apiVersion string, kind string, namespace string, name string, opts ...pkg.PatchCollectorOption)\n```\n\n```go\nfunc (c *PatchCollector) JSONPatch(patch any, apiVersion string, kind string, namespace string, name string, opts ...pkg.PatchCollectorOption)\n```\n\n```go\nfunc (c *PatchCollector) MergePatch(patch any, apiVersion string, kind string, namespace string, name string, opts ...pkg.PatchCollectorOption)\n```\n\n```go\nfunc (c *PatchCollector) Operations() []pkg.PatchCollectorOperation\n```\nOperations returns all collected operations\n\n```go\nfunc (c *PatchCollector) PatchWithJQ(jqfilter string, apiVersion string, kind string, namespace string, name string, opts ...pkg.PatchCollectorOption)\n```\n\n```go\nfunc (c *PatchCollector) PatchWithJSON(jsonPatch any, apiVersion string, kind string, namespace string, name string, opts ...pkg.PatchCollectorOption)\n```\n\n```go\nfunc (c *PatchCollector) PatchWithMerge(mergePatch any, apiVersion string, kind string, namespace string, name string, opts ...pkg.PatchCollectorOption)\n```\n\n```go\nfunc (c *PatchCollector) WriteOutput(w io.Writer) error\n```\nWriteOutput serializes all collected operations as newline-delimited JSON.\n\n```go\ntype PatchOperation string\n```\nPatchOperation defines how patches are applied to objects.\n\n```go\nconst (\n\tMergePatch PatchOperation = \"MergePatch\" // RFC7396 JSON Merge Patch\n\tJQPatch    PatchOperation = \"JQPatch\"    // Mutate object with jq expression\n\tJSONPatch  PatchOperation = \"JSONPatch\"  // RFC6902 JSON Patch (op/path/value)\n)\n```\n\n```go\ntype Snapshot json.RawMessage\n```\n\n```go\nfunc (snap Snapshot) String() string\n```\n\n```go\nfunc (snap Snapshot) UnmarshalTo(v any) error\n```\n\n```go\ntype Snapshots map[string][]pkg.Snapshot\n```\ninside json.RawMessage is array of json objects\n\n```go\nfunc (s Snapshots) Get(key string) []pkg.Snapshot\n```\n\n","path":"github.com/deckhouse/module-sdk/internal/objectpatch","name":"objectpatch","synopsis":"","isRedistributable":true}
