Skip to content

Commit e258791

Browse files
committed
Use core type instead of string serviceType representation
1 parent 7277eb5 commit e258791

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

pkg/apis/mysql/v1alpha1/mysqlcluster_defaults.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ func SetDefaults_MysqlCluster(c *MysqlCluster) {
5656
if len(c.Spec.MinAvailable) == 0 && *c.Spec.Replicas > 1 {
5757
c.Spec.MinAvailable = defaultMinAvailable
5858
}
59+
60+
// set default service type
61+
if c.Spec.ServiceSpec.ServiceType == "" {
62+
c.Spec.ServiceSpec.ServiceType = corev1.ServiceTypeClusterIP
63+
}
5964
}
6065

6166
// SetDefaults for PodSpec

pkg/apis/mysql/v1alpha1/mysqlcluster_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ type VolumeSpec struct {
249249
type ServiceSpec struct {
250250
// ServiceType defines a type for Services: ClusterIP, Loadbalancer, etc.
251251
// +optional
252-
ServiceType string `json:"type,omitempty"`
252+
ServiceType core.ServiceType `json:"type,omitempty"`
253253

254254
// Additional annotations to append to MysqlCluster's services
255255
// +optional

pkg/internal/mysqlcluster/defaults.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func (cluster *MysqlCluster) SetDefaults(opt *options.Options) {
8181

8282
// set default service type
8383
if cluster.Spec.ServiceSpec.ServiceType == "" {
84-
cluster.Spec.ServiceSpec.ServiceType = "ClusterIP"
84+
cluster.Spec.ServiceSpec.ServiceType = core.ServiceTypeClusterIP
8585
}
8686

8787
// configure mysql based on:

pkg/internal/mysqlcluster/mysqlcluster_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ var _ = Describe("Test MySQL cluster wrapper", func() {
7676
Expect(cluster.Spec.MysqlConf).To(HaveKey(Equal("innodb-log-file-size")))
7777
Expect(cluster.Spec.MysqlConf).NotTo(HaveKey(Equal("max-binlog-size")))
7878

79-
Expect(cluster.Spec.ServiceSpec.ServiceType).To(Equal("ClusterIP"))
79+
Expect(cluster.Spec.ServiceSpec.ServiceType).To(Equal(corev1.ServiceTypeClusterIP))
8080
})
8181

8282
It("should use init MySQL container", func() {

0 commit comments

Comments
 (0)