From 70d361b24665c56b3925a3f564ac586e2f2b4884 Mon Sep 17 00:00:00 2001 From: Steve Boardwell Date: Thu, 5 Aug 2021 21:47:31 +0200 Subject: [PATCH] Add optional annotations --- pkg/apis/db/v1alpha1/postgresuser_types.go | 2 ++ pkg/controller/postgresuser/postgresuser_controller.go | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/apis/db/v1alpha1/postgresuser_types.go b/pkg/apis/db/v1alpha1/postgresuser_types.go index 6eb7120e..de20372b 100644 --- a/pkg/apis/db/v1alpha1/postgresuser_types.go +++ b/pkg/apis/db/v1alpha1/postgresuser_types.go @@ -15,6 +15,8 @@ type PostgresUserSpec struct { SecretName string `json:"secretName"` // +optional Privileges string `json:"privileges"` + // +optional + Annotations map[string]string `json:"annotations,omitempty"` } // PostgresUserStatus defines the observed state of PostgresUser diff --git a/pkg/controller/postgresuser/postgresuser_controller.go b/pkg/controller/postgresuser/postgresuser_controller.go index c425bf54..7223454f 100644 --- a/pkg/controller/postgresuser/postgresuser_controller.go +++ b/pkg/controller/postgresuser/postgresuser_controller.go @@ -4,6 +4,7 @@ import ( "context" goerr "errors" "fmt" + "github.com/movetokube/postgres-operator/pkg/config" "github.com/go-logr/logr" @@ -266,11 +267,14 @@ func (r *ReconcilePostgresUser) newSecretForCR(cr *dbv1alpha1.PostgresUser, role labels := map[string]string{ "app": cr.Name, } + annotations := cr.Spec.Annotations + return &corev1.Secret{ ObjectMeta: metav1.ObjectMeta{ - Name: fmt.Sprintf("%s-%s", cr.Spec.SecretName, cr.Name), - Namespace: cr.Namespace, - Labels: labels, + Name: fmt.Sprintf("%s-%s", cr.Spec.SecretName, cr.Name), + Namespace: cr.Namespace, + Labels: labels, + Annotations: annotations, }, Data: map[string][]byte{ "POSTGRES_URL": []byte(pgUserUrl),