@@ -2,14 +2,12 @@ package controller
22
33import (
44 "context"
5- "encoding/json"
65 "fmt"
76 "strings"
87
98 v1 "k8s.io/api/core/v1"
109 apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
1110 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
12- "k8s.io/apimachinery/pkg/types"
1311 "k8s.io/apimachinery/pkg/util/wait"
1412
1513 acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
@@ -65,15 +63,9 @@ func (c *Controller) createOperatorCRD(desiredCrd *apiextv1.CustomResourceDefini
6563 }
6664 if crd != nil {
6765 c .logger .Infof ("customResourceDefinition %q is already registered and will only be updated" , crd .Name )
68- // copy annotations and labels from existing CRD since we do not define them
69- desiredCrd .Annotations = crd .Annotations
70- desiredCrd .Labels = crd .Labels
71- patch , err := json .Marshal (desiredCrd )
66+ crd .Spec = desiredCrd .Spec
67+ _ , err := c .KubeClient .CustomResourceDefinitions ().Update (context .TODO (), crd , metav1.UpdateOptions {})
7268 if err != nil {
73- return fmt .Errorf ("could not marshal new customResourceDefintion %q: %v" , desiredCrd .Name , err )
74- }
75- if _ , err := c .KubeClient .CustomResourceDefinitions ().Patch (
76- context .TODO (), crd .Name , types .MergePatchType , patch , metav1.PatchOptions {}); err != nil {
7769 return fmt .Errorf ("could not update customResourceDefinition %q: %v" , crd .Name , err )
7870 }
7971 }
0 commit comments