...

Source file src/edge-infra.dev/pkg/edge/datasync/controllers/couchctl/resource_manager.go

Documentation: edge-infra.dev/pkg/edge/datasync/controllers/couchctl

     1  package couchctl
     2  
     3  import (
     4  	"edge-infra.dev/pkg/k8s/object"
     5  	"edge-infra.dev/pkg/k8s/runtime/sap"
     6  	unstructuredutil "edge-infra.dev/pkg/k8s/unstructured"
     7  
     8  	kobject "sigs.k8s.io/cli-utils/pkg/object"
     9  	"sigs.k8s.io/controller-runtime/pkg/client"
    10  )
    11  
    12  // ExistingChangeSetEntry used for backward compatibility
    13  func ExistingChangeSetEntry(obj client.Object) (*sap.ChangeSetEntry, error) {
    14  	return ChangeSetEntry(sap.UnchangedAction, obj)
    15  }
    16  
    17  func ChangeSetEntry(action sap.Action, obj client.Object) (*sap.ChangeSetEntry, error) {
    18  	o, err := unstructuredutil.ToUnstructured(obj)
    19  	if err != nil {
    20  		return nil, err
    21  	}
    22  	return &sap.ChangeSetEntry{
    23  		ObjMetadata:  kobject.UnstructuredToObjMetadata(o),
    24  		GroupVersion: o.GroupVersionKind().Version,
    25  		Subject:      object.FmtUnstructured(o),
    26  		Action:       string(action),
    27  	}, nil
    28  }
    29  

View as plain text