From 0f1bbe62e942fed3a7658c457633dd3362d04086 Mon Sep 17 00:00:00 2001 From: Owain Lewis Date: Tue, 9 Jan 2018 11:00:12 +0000 Subject: [PATCH] Replace custom struct with a local object reference --- pkg/apis/mysql/v1/cluster.go | 9 +-------- pkg/apis/mysql/v1/zz_generated.deepcopy.go | 18 +----------------- pkg/resources/statefulsets/statefulset_test.go | 6 +++--- 3 files changed, 5 insertions(+), 28 deletions(-) diff --git a/pkg/apis/mysql/v1/cluster.go b/pkg/apis/mysql/v1/cluster.go index 9cc3b111b..8c1de14ff 100644 --- a/pkg/apis/mysql/v1/cluster.go +++ b/pkg/apis/mysql/v1/cluster.go @@ -36,13 +36,6 @@ var validVersions = []string{ defaultVersion, } -// MySQLSecretRef holds reference to a custom secret -// which enables configuration of things like the -// MYSQL_ROOT_PASSWORD in a cluster -type MySQLSecretRef struct { - Name string `json:"name"` -} - // MySQLClusterSpec defines the attributes a user can specify when creating a cluster type MySQLClusterSpec struct { // Version defines the MySQL Docker image version. @@ -73,7 +66,7 @@ type MySQLClusterSpec struct { // If defined, we use this secret for configuring the MYSQL_ROOT_PASSWORD // If it is not set we generate a secret dynamically // +optional - SecretRef *MySQLSecretRef `json:"secretRef,omitempty"` + SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty"` } // MySQLClusterPhase describes the state of the cluster. diff --git a/pkg/apis/mysql/v1/zz_generated.deepcopy.go b/pkg/apis/mysql/v1/zz_generated.deepcopy.go index 2bba4640a..593a669b8 100644 --- a/pkg/apis/mysql/v1/zz_generated.deepcopy.go +++ b/pkg/apis/mysql/v1/zz_generated.deepcopy.go @@ -372,7 +372,7 @@ func (in *MySQLClusterSpec) DeepCopyInto(out *MySQLClusterSpec) { if *in == nil { *out = nil } else { - *out = new(MySQLSecretRef) + *out = new(core_v1.LocalObjectReference) **out = **in } } @@ -484,22 +484,6 @@ func (in *MySQLRestoreList) DeepCopyObject() runtime.Object { } } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MySQLSecretRef) DeepCopyInto(out *MySQLSecretRef) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MySQLSecretRef. -func (in *MySQLSecretRef) DeepCopy() *MySQLSecretRef { - if in == nil { - return nil - } - out := new(MySQLSecretRef) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RestoreSpec) DeepCopyInto(out *RestoreSpec) { *out = *in diff --git a/pkg/resources/statefulsets/statefulset_test.go b/pkg/resources/statefulsets/statefulset_test.go index 9978e4786..c7d8ff858 100644 --- a/pkg/resources/statefulsets/statefulset_test.go +++ b/pkg/resources/statefulsets/statefulset_test.go @@ -40,7 +40,7 @@ func TestMySQLRootPasswordNoSecretRef(t *testing.T) { func TestMySQLRootPasswordWithSecretRef(t *testing.T) { cluster := &api.MySQLCluster{ Spec: api.MySQLClusterSpec{ - SecretRef: &api.MySQLSecretRef{Name: "secret"}, + SecretRef: &v1.LocalObjectReference{Name: "secret"}, }, } @@ -54,7 +54,7 @@ func TestMySQLRootPasswordWithSecretRef(t *testing.T) { func TestClusterWithoutPVCHasBackupContainerAndVolumes(t *testing.T) { cluster := &api.MySQLCluster{ Spec: api.MySQLClusterSpec{ - SecretRef: &api.MySQLSecretRef{Name: "secret"}, + SecretRef: &v1.LocalObjectReference{Name: "secret"}, }, } @@ -73,7 +73,7 @@ func TestClusterWithoutPVCHasBackupContainerAndVolumes(t *testing.T) { func TestClusterWithPVCHasBackupContainerAndVolumes(t *testing.T) { cluster := &api.MySQLCluster{ Spec: api.MySQLClusterSpec{ - SecretRef: &api.MySQLSecretRef{Name: "secret"}, + SecretRef: &v1.LocalObjectReference{Name: "secret"}, VolumeClaimTemplate: &v1.PersistentVolumeClaim{}, BackupVolumeClaimTemplate: &v1.PersistentVolumeClaim{}, },