From 047c24c86561a184fde30444ca2c61584e16aa8d Mon Sep 17 00:00:00 2001 From: Marko Mikulicic Date: Thu, 26 Mar 2020 16:17:23 +0100 Subject: [PATCH] Tag Status field as omitempty Checked that nobody depends on the Status field since we're technically breaking source backward compat https://pkg.go.dev/github.com/bitnami-labs/sealed-secrets@v0.11.0/pkg/apis/sealed-secrets/v1alpha1?tab=doc#SealedSecretStatus --- cmd/controller/controller.go | 6 +++++- pkg/apis/sealed-secrets/v1alpha1/types.go | 7 ++++--- pkg/apis/sealed-secrets/v1alpha1/zz_generated.deepcopy.go | 6 +++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/cmd/controller/controller.go b/cmd/controller/controller.go index fa08908d9c..4303a4977f 100644 --- a/cmd/controller/controller.go +++ b/cmd/controller/controller.go @@ -288,7 +288,11 @@ func (c *Controller) unseal(key string) (unsealErr error) { func (c *Controller) updateSealedSecretStatus(ssecret *ssv1alpha1.SealedSecret, unsealError error) error { ssecret = ssecret.DeepCopy() - st := &ssecret.Status + st := ssecret.Status + if st == nil { + st = &ssv1alpha1.SealedSecretStatus{} + } + ssecret.Status = st st.ObservedGeneration = ssecret.ObjectMeta.Generation updateSealedSecretsStatusConditions(st, unsealError) diff --git a/pkg/apis/sealed-secrets/v1alpha1/types.go b/pkg/apis/sealed-secrets/v1alpha1/types.go index 8ae0bb4bde..b93c2ad642 100644 --- a/pkg/apis/sealed-secrets/v1alpha1/types.go +++ b/pkg/apis/sealed-secrets/v1alpha1/types.go @@ -24,7 +24,7 @@ const ( // SealedSecretManagedAnnotation is the name for the annotation for // flaging the existing secrets be managed by SealedSecret controller. - SealedSecretManagedAnnotation = annoNs + "managed" + SealedSecretManagedAnnotation = annoNs + "managed" ) // SecretTemplateSpec describes the structure a Secret should have @@ -101,8 +101,9 @@ type SealedSecret struct { metav1.TypeMeta `json:",inline"` metav1.ObjectMeta `json:"metadata,omitempty"` - Spec SealedSecretSpec `json:"spec"` - Status SealedSecretStatus `json:"status"` + Spec SealedSecretSpec `json:"spec"` + // +optional + Status *SealedSecretStatus `json:"status,omitempty"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/pkg/apis/sealed-secrets/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/sealed-secrets/v1alpha1/zz_generated.deepcopy.go index ab69a12cb6..0e066b0608 100644 --- a/pkg/apis/sealed-secrets/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/sealed-secrets/v1alpha1/zz_generated.deepcopy.go @@ -36,7 +36,11 @@ func (in *SealedSecret) DeepCopyInto(out *SealedSecret) { out.TypeMeta = in.TypeMeta in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) + if in.Status != nil { + in, out := &in.Status, &out.Status + *out = new(SealedSecretStatus) + (*in).DeepCopyInto(*out) + } return }