Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ require (
replace github.com/go-openapi/validate => github.com/flant/go-openapi-validate v0.19.12-flant.0

require (
github.com/deckhouse/module-sdk v0.9.1
github.com/deckhouse/module-sdk v0.9.2-0.20260216091911-6f5e71891fa4
github.com/gojuno/minimock/v3 v3.4.7
github.com/itchyny/gojq v0.12.17
github.com/muesli/termenv v0.16.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ github.com/deckhouse/deckhouse/pkg/log v0.1.0 h1:2aPfyiHHSIJlX4x7ysyPOaIb7CLmyY+
github.com/deckhouse/deckhouse/pkg/log v0.1.0/go.mod h1:pbAxTSDcPmwyl3wwKDcEB3qdxHnRxqTV+J0K+sha8bw=
github.com/deckhouse/deckhouse/pkg/metrics-storage v0.3.0 h1:xZvbKuexrSQGEw6CB4n3UC7XbOb9QNLbm8UhcGZ2R1I=
github.com/deckhouse/deckhouse/pkg/metrics-storage v0.3.0/go.mod h1:Rz++SzCLkFW03WGgftnn91TimGU2shiKb5S/YuxcBuE=
github.com/deckhouse/module-sdk v0.9.1 h1:UTzSWD4EorLWEIGtimjuFSuAJZxadULd1c+ZhZTlH4Q=
github.com/deckhouse/module-sdk v0.9.1/go.mod h1:7mgyfIJHzzEknMZCiwQbPq+JfcBguLje1ZBKQU+y9fk=
github.com/deckhouse/module-sdk v0.9.2-0.20260216091911-6f5e71891fa4 h1:Y5q9U/jm9or0B1x0iRHqTgZocjc/IMbXm08mbVR9uaY=
github.com/deckhouse/module-sdk v0.9.2-0.20260216091911-6f5e71891fa4/go.mod h1:7mgyfIJHzzEknMZCiwQbPq+JfcBguLje1ZBKQU+y9fk=
github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g=
github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
Expand Down
70 changes: 69 additions & 1 deletion pkg/kube/object_patch/operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,43 @@ type createOperation struct {
}

func (op *createOperation) Description() string {
return "Create object"
u, err := toUnstructured(op.object)
if err != nil {
return "Create object (unknown)"
}
return fmt.Sprintf("Create object %s/%s/%s/%s", u.GetAPIVersion(), u.GetKind(), u.GetNamespace(), u.GetName())
}

func (op *createOperation) GetName() string {
u, err := toUnstructured(op.object)
if err != nil {
return ""
}
return u.GetName()
}

func (op *createOperation) SetName(name string) {
u, err := toUnstructured(op.object)
if err != nil {
return
}
u.SetName(name)
op.object = u
}

func (op *createOperation) SetNamePrefix(prefix string) {
name := op.GetName()
if name != "" {
op.SetName(prefix + name)
}
}

func (op *createOperation) GetNamespace() string {
u, err := toUnstructured(op.object)
if err != nil {
return ""
}
return u.GetNamespace()
}

func (op *createOperation) WithSubresource(subresource string) {
Expand Down Expand Up @@ -127,6 +163,22 @@ func (op *deleteOperation) WithSubresource(subresource string) {
op.subresource = subresource
}

func (op *deleteOperation) GetName() string {
return op.name
}

func (op *deleteOperation) SetName(name string) {
op.name = name
}

func (op *deleteOperation) SetNamePrefix(prefix string) {
op.name = prefix + op.name
}

func (op *deleteOperation) GetNamespace() string {
return op.namespace
}

type patchOperation struct {
// Object coordinates for patch and delete.
apiVersion string
Expand All @@ -146,6 +198,22 @@ type patchOperation struct {
ignoreHookError bool
}

func (op *patchOperation) GetName() string {
return op.name
}

func (op *patchOperation) SetName(name string) {
op.name = name
}

func (op *patchOperation) SetNamePrefix(prefix string) {
op.name = prefix + op.name
}

func (op *patchOperation) GetNamespace() string {
return op.namespace
}

func (op *patchOperation) Description() string {
return fmt.Sprintf("Filter object %s/%s/%s/%s", op.apiVersion, op.kind, op.namespace, op.name)
}
Expand Down
7 changes: 7 additions & 0 deletions pkg/kube/object_patch/patch_collector.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package object_patch

import (
"io"

sdkpkg "github.com/deckhouse/module-sdk/pkg"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
)
Expand Down Expand Up @@ -151,3 +153,8 @@ func (dop *PatchCollector) PatchWithJSON(jsonPatch any, apiVersion string, kind
func (dop *PatchCollector) PatchWithMerge(mergePatch any, apiVersion string, kind string, namespace string, name string, opts ...sdkpkg.PatchCollectorOption) {
dop.add(NewMergePatchOperation(mergePatch, apiVersion, kind, namespace, name, opts...))
}

func (dop *PatchCollector) WriteOutput(_ io.Writer) error {
// TODO implement me
return nil
}
Loading