From fce29237fbf1c64ee3e585ef2f14433816cce0ac Mon Sep 17 00:00:00 2001 From: Sinelnikov Michail Date: Wed, 4 Feb 2026 16:07:53 +0300 Subject: [PATCH 1/3] update interface Signed-off-by: Sinelnikov Michail --- pkg/patch.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/patch.go b/pkg/patch.go index 2302bec..b57ccbf 100644 --- a/pkg/patch.go +++ b/pkg/patch.go @@ -93,6 +93,10 @@ type NamespacedPatchCollector interface { // - filterOperation to modify object via Get-filter-Update process type PatchCollectorOperation interface { Description() string + GetName() string + SetName(name string) + SetNamePrefix(prefix string) + GetNamespace() string } type PatchCollectorOption interface { From e60815bb7453ec483df47316052b43389f8d4920 Mon Sep 17 00:00:00 2001 From: Sinelnikov Michail Date: Wed, 4 Feb 2026 16:27:53 +0300 Subject: [PATCH 2/3] fix Signed-off-by: Sinelnikov Michail --- internal/objectpatch/patch.go | 42 +++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/internal/objectpatch/patch.go b/internal/objectpatch/patch.go index 071bfa2..67327e3 100644 --- a/internal/objectpatch/patch.go +++ b/internal/objectpatch/patch.go @@ -27,6 +27,48 @@ func (p *Patch) Description() string { return fmt.Sprintf("%v", op) } +// GetName returns the name of the object to patch. +func (p *Patch) GetName() string { + name, ok := p.patchValues["name"] + if !ok { + return "" + } + + // Handle both string and typed names + return fmt.Sprintf("%v", name) +} + +// GetNamespace returns the namespace of the object to patch. +func (p *Patch) GetNamespace() string { + ns, ok := p.patchValues["namespace"] + if !ok { + return "" + } + + // Handle both string and typed namespaces + return fmt.Sprintf("%v", ns) +} + +// SetPrifixName sets the name for the patch operation with a prefix. +func (p *Patch) SetNamePrefix(prefix string) { + // Set the name for the patch operation with a prefix. + // This is used to identify the target object in Kubernetes. + if p.patchValues == nil { + p.patchValues = make(map[string]any) + } + p.patchValues["name"] = fmt.Sprintf("%s-%s", prefix, p.GetName()) +} + +// SetName sets the name for the patch operation. +func (p *Patch) SetName(name string) { + // Set the name for the patch operation. + // This is used to identify the target object in Kubernetes. + if p.patchValues == nil { + p.patchValues = make(map[string]any) + } + p.patchValues["name"] = p.GetName() +} + // WithSubresource sets the subresource to patch (e.g., "status", "scale"). func (p *Patch) WithSubresource(subresource string) { p.patchValues["subresource"] = subresource From 6f5e71891fa46e83f5afb5aee819a4397bd07b38 Mon Sep 17 00:00:00 2001 From: Sinelnikov Michail Date: Mon, 16 Feb 2026 12:05:41 +0300 Subject: [PATCH 3/3] fix Signed-off-by: Sinelnikov Michail --- internal/objectpatch/patch.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/objectpatch/patch.go b/internal/objectpatch/patch.go index 67327e3..470a986 100644 --- a/internal/objectpatch/patch.go +++ b/internal/objectpatch/patch.go @@ -66,7 +66,7 @@ func (p *Patch) SetName(name string) { if p.patchValues == nil { p.patchValues = make(map[string]any) } - p.patchValues["name"] = p.GetName() + p.patchValues["name"] = name } // WithSubresource sets the subresource to patch (e.g., "status", "scale").