diff --git a/controller/runnable.go b/controller/runnable.go index fb9ef29..9ef86c7 100644 --- a/controller/runnable.go +++ b/controller/runnable.go @@ -2,6 +2,7 @@ package controller import ( "context" + "encoding/json" "fmt" "reflect" "strings" @@ -221,16 +222,21 @@ func Restructure[T any](obj any) (any, error) { if !ok { return nil, fmt.Errorf("unexpected object type: %T", obj) } - o := *new(T) - if err := runtime.DefaultUnstructuredConverter.FromUnstructured(unstructuredObj.UnstructuredContent(), &o); err != nil { + j, err := unstructuredObj.MarshalJSON() + if err != nil { + return nil, err + } + o := new(T) + if err := json.Unmarshal(j, o); err != nil { return nil, err } return o, nil } func Destruct[T any](obj T) (*unstructured.Unstructured, error) { - u, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&obj) - if err != nil { + j, _ := json.Marshal(obj) + var u map[string]interface{} + if err := json.Unmarshal(j, &u); err != nil { return nil, err } return &unstructured.Unstructured{Object: u}, nil