Skip to content

Commit 0c498e5

Browse files
authored
Merge pull request #213 from acekingke/fix_with_gofumpt
*: format the code with gofumpt #212
2 parents cf87776 + 421fb55 commit 0c498e5

File tree

14 files changed

+54
-59
lines changed

14 files changed

+54
-59
lines changed

api/v1alpha1/cluster_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ type Persistence struct {
236236
// +optional
237237
StorageClass *string `json:"storageClass,omitempty"`
238238

239-
//Size of persistent volume claim.
239+
// Size of persistent volume claim.
240240
// +optional
241241
// +kubebuilder:default:="10Gi"
242242
Size string `json:"size,omitempty"`

cluster/cluster_test.go

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func TestUnwrap(t *testing.T) {
6161
}
6262

6363
func TestGetLabel(t *testing.T) {
64-
//when the instance label exist
64+
// when the instance label exist.
6565
{
6666
testMysqlCluster := mysqlCluster
6767
testMysqlCluster.Annotations = map[string]string{
@@ -80,7 +80,7 @@ func TestGetLabel(t *testing.T) {
8080
}
8181
assert.Equal(t, want, testCase.GetLabels())
8282
}
83-
//when the component label exist
83+
// when the component label exist.
8484
{
8585
testMysqlCluster := mysqlCluster
8686
testMysqlCluster.Annotations = map[string]string{
@@ -99,7 +99,7 @@ func TestGetLabel(t *testing.T) {
9999
}
100100
assert.Equal(t, want, testCase.GetLabels())
101101
}
102-
//when the part-of label exist
102+
// when the part-of label exist.
103103
{
104104
testMysqlCluster := mysqlCluster
105105
testMysqlCluster.Annotations = map[string]string{
@@ -131,7 +131,7 @@ func TestGetSelectorLabels(t *testing.T) {
131131
}
132132

133133
func TestGetMySQLVersion(t *testing.T) {
134-
//other 8.0 -> 5.7.33
134+
// other 8.0 -> 5.7.33
135135
{
136136
testMysqlCluster := mysqlCluster
137137
testMysqlCluster.Spec.MysqlVersion = "8.0"
@@ -141,7 +141,7 @@ func TestGetMySQLVersion(t *testing.T) {
141141
want := "5.7.33"
142142
assert.Equal(t, want, testCase.GetMySQLVersion())
143143
}
144-
//MySQLTagsToSemVer 5.7 -> 5.7.33
144+
// MySQLTagsToSemVer 5.7 -> 5.7.33
145145
{
146146
testMysqlCluster := mysqlCluster
147147
testMysqlCluster.Spec.MysqlVersion = "5.7"
@@ -151,7 +151,7 @@ func TestGetMySQLVersion(t *testing.T) {
151151
want := "5.7.33"
152152
assert.Equal(t, want, testCase.GetMySQLVersion())
153153
}
154-
//MysqlImageVersions 5.7.33 -> 5.7.33
154+
// MysqlImageVersions 5.7.33 -> 5.7.33
155155
{
156156
testMysqlCluster := mysqlCluster
157157
testMysqlCluster.Spec.MysqlVersion = "5.7.33"
@@ -284,7 +284,7 @@ func TestEnsureVolumes(t *testing.T) {
284284
},
285285
},
286286
}
287-
//when disable Persistence
287+
// when disable Persistence
288288
{
289289
testMysql := mysqlCluster
290290
testMysql.Spec.Persistence.Enabled = false
@@ -302,7 +302,7 @@ func TestEnsureVolumes(t *testing.T) {
302302
want = append(want, volume...)
303303
assert.Equal(t, want, testCase.EnsureVolumes())
304304
}
305-
//when enable tokudb
305+
// when enable tokudb
306306
{
307307
testMysql := mysqlCluster
308308
testMysql.Spec.Persistence.Enabled = true
@@ -323,7 +323,7 @@ func TestEnsureVolumes(t *testing.T) {
323323
want = append(want, volume...)
324324
assert.Equal(t, want, testCase.EnsureVolumes())
325325
}
326-
//default(Persistence is turned on by default)
326+
// default(Persistence is turned on by default)
327327
{
328328
testMysql := mysqlCluster
329329
testMysql.Spec.Persistence.Enabled = true
@@ -336,14 +336,14 @@ func TestEnsureVolumes(t *testing.T) {
336336

337337
func TestEnsureVolumeClaimTemplates(t *testing.T) {
338338
var scheme runtime.Scheme
339-
//when disable persistence
339+
// when disable persistence
340340
{
341341
result, err := testCluster.EnsureVolumeClaimTemplates(&scheme)
342342
assert.Nil(t, result)
343343
assert.Nil(t, err)
344344
}
345345

346-
//when enable persistence
346+
// when enable persistence
347347
{
348348
var cluster *Cluster
349349
storageClass := "ssd"
@@ -400,7 +400,7 @@ func TestEnsureVolumeClaimTemplates(t *testing.T) {
400400
assert.Nil(t, err)
401401
}
402402

403-
//when the StorageClass is "-"
403+
// when the StorageClass is "-"
404404
{
405405
storageClass := "-"
406406
testMysql := mysqlCluster
@@ -420,7 +420,7 @@ func TestEnsureVolumeClaimTemplates(t *testing.T) {
420420
assert.Nil(t, err)
421421
}
422422

423-
//when SetControllerReference error
423+
// when SetControllerReference error
424424
{
425425
testMysql := mysqlCluster
426426
testMysql.Spec.Persistence.Enabled = true
@@ -440,29 +440,29 @@ func TestEnsureVolumeClaimTemplates(t *testing.T) {
440440
}
441441

442442
func TestGetNameForResource(t *testing.T) {
443-
//statefulset configMap headlessSvc
443+
// statefulset configMap headlessSvc
444444
{
445445
want := "sample-mysql"
446446
assert.Equal(t, want, testCluster.GetNameForResource(utils.StatefulSet))
447447
assert.Equal(t, want, testCluster.GetNameForResource(utils.ConfigMap))
448448
assert.Equal(t, want, testCluster.GetNameForResource(utils.HeadlessSVC))
449449
}
450-
//leaderSvc
450+
// leaderSvc
451451
{
452452
want := "sample-leader"
453453
assert.Equal(t, want, testCluster.GetNameForResource(utils.LeaderService))
454454
}
455-
//folloerSvc
455+
// folloerSvc
456456
{
457457
want := "sample-follower"
458458
assert.Equal(t, want, testCluster.GetNameForResource(utils.FollowerService))
459459
}
460-
//secret
460+
// secret
461461
{
462462
want := "sample-secret"
463463
assert.Equal(t, want, testCluster.GetNameForResource(utils.Secret))
464464
}
465-
//others
465+
// others
466466
{
467467
want := "sample"
468468
assert.Equal(t, want, testCluster.GetNameForResource("others"))
@@ -496,7 +496,7 @@ func TestEnsureMysqlConf(t *testing.T) {
496496
},
497497
},
498498
}
499-
//cpu 1 corev1s,memory 1 gb,innodb_buffer_pool_size not set
499+
// cpu 1 corev1s,memory 1 gb,innodb_buffer_pool_size not set
500500
{
501501
testMysqlCase := testMysql
502502
testCase := Cluster{
@@ -508,7 +508,7 @@ func TestEnsureMysqlConf(t *testing.T) {
508508
assert.Equal(t, wantSize, testCase.Spec.MysqlOpts.MysqlConf["innodb_buffer_pool_size"])
509509
assert.Equal(t, wantInstance, testCase.Spec.MysqlOpts.MysqlConf["innodb_buffer_pool_instances"])
510510
}
511-
//cpu 1 corev1s,memory 1 gb,innodb_buffer_pool_size 600 mb
511+
// cpu 1 corev1s,memory 1 gb,innodb_buffer_pool_size 600 mb
512512
{
513513
guard := Patch(sizeToBytes, func(s string) (uint64, error) {
514514
return uint64(600 * mb), nil
@@ -526,7 +526,7 @@ func TestEnsureMysqlConf(t *testing.T) {
526526
assert.Equal(t, wantSize, testCase.Spec.MysqlOpts.MysqlConf["innodb_buffer_pool_size"])
527527
assert.Equal(t, wantInstance, testCase.Spec.MysqlOpts.MysqlConf["innodb_buffer_pool_instances"])
528528
}
529-
//cpu 1 corev1s,memory 2 gb,innodb_buffer_pool_size 1.7 gb
529+
// cpu 1 corev1s,memory 2 gb,innodb_buffer_pool_size 1.7 gb
530530
{
531531
guard := Patch(sizeToBytes, func(s string) (uint64, error) {
532532
return uint64(1700 * mb), nil
@@ -546,7 +546,7 @@ func TestEnsureMysqlConf(t *testing.T) {
546546
assert.Equal(t, wantSize, testCase.Spec.MysqlOpts.MysqlConf["innodb_buffer_pool_size"])
547547
assert.Equal(t, wantInstance, testCase.Spec.MysqlOpts.MysqlConf["innodb_buffer_pool_instances"])
548548
}
549-
//cpu 1 corev1s,memory 2 gb,innodb_buffer_pool_size 1.7 gb, sizeToBytes error
549+
// cpu 1 corev1s,memory 2 gb,innodb_buffer_pool_size 1.7 gb, sizeToBytes error
550550
{
551551
guard := Patch(sizeToBytes, func(s string) (uint64, error) {
552552
return uint64(1700 * mb), fmt.Errorf("error")
@@ -565,7 +565,7 @@ func TestEnsureMysqlConf(t *testing.T) {
565565
assert.Equal(t, wantSize, testCase.Spec.MysqlOpts.MysqlConf["innodb_buffer_pool_size"])
566566
assert.Equal(t, wantInstance, testCase.Spec.MysqlOpts.MysqlConf["innodb_buffer_pool_instances"])
567567
}
568-
//cpu 8 corev1s,memory 16 gb,innodb_buffer_pool_size 2 gb
568+
// cpu 8 corev1s,memory 16 gb,innodb_buffer_pool_size 2 gb
569569
{
570570
guard := Patch(sizeToBytes, func(s string) (uint64, error) {
571571
return uint64(2 * gb), nil
@@ -594,31 +594,31 @@ func TestSizeToBytes(t *testing.T) {
594594
mb int64 = 1 << 20
595595
kb int64 = 1 << 10
596596
)
597-
//kb
597+
// kb
598598
{
599599
testCase := "1000k"
600600
want := uint64(1000 * kb)
601601
result, err := sizeToBytes(testCase)
602602
assert.Equal(t, want, result)
603603
assert.Nil(t, err)
604604
}
605-
//mb
605+
// mb
606606
{
607607
testCase := "1000m"
608608
want := uint64(1000 * mb)
609609
result, err := sizeToBytes(testCase)
610610
assert.Equal(t, want, result)
611611
assert.Nil(t, err)
612612
}
613-
//gb
613+
// gb
614614
{
615615
testCase := "1000g"
616616
want := uint64(1000 * gb)
617617
result, err := sizeToBytes(testCase)
618618
assert.Equal(t, want, result)
619619
assert.Nil(t, err)
620620
}
621-
//others
621+
// others
622622
{
623623
testCase := "1000a"
624624
want := uint64(0)
@@ -627,7 +627,7 @@ func TestSizeToBytes(t *testing.T) {
627627
assert.Equal(t, want, result)
628628
assert.Equal(t, wantError, err)
629629
}
630-
//it will return the result of ParseUint() when the parameter without unit
630+
// it will return the result of ParseUint() when the parameter without unit
631631
{
632632
guard := Patch(strconv.ParseUint, func(s string, base int, bitSize int) (uint64, error) {
633633
return uint64(666), nil
@@ -640,7 +640,7 @@ func TestSizeToBytes(t *testing.T) {
640640
assert.Equal(t, want, result)
641641
assert.Nil(t, err)
642642
}
643-
//ParseUint error
643+
// ParseUint error
644644
{
645645
guard := Patch(strconv.ParseUint, func(s string, base int, bitSize int) (uint64, error) {
646646
return uint64(777), fmt.Errorf("error")

cluster/container/backup.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func (c *backupSidecar) getEnvVars() []corev1.EnvVar {
6363
Name: "REPLICAS",
6464
Value: fmt.Sprintf("%d", *c.Spec.Replicas),
6565
},
66-
//backup user password for sidecar http server
66+
// backup user password for sidecar http server
6767
getEnvVarFromSecret(sctName, "BACKUP_USER", "backup-user", true),
6868
getEnvVarFromSecret(sctName, "BACKUP_PASSWORD", "backup-password", true),
6969
}
@@ -142,5 +142,4 @@ func (c *backupSidecar) getVolumeMounts() []corev1.VolumeMount {
142142
MountPath: utils.LogsVolumeMountPath,
143143
},
144144
}
145-
146145
}

cluster/container/init_mysql_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ func TestGetInitMysqlCommand(t *testing.T) {
113113
}
114114

115115
func TestGetInitMysqlEnvVar(t *testing.T) {
116-
//base env
116+
// base env
117117
{
118118
assert.Equal(t, initMysqlEnvs, initMysqlCase.Env)
119119
}
120-
//initTokuDB
120+
// initTokuDB
121121
{
122122
testToKuDBMysqlCluster := initMysqlMysqlCluster
123123
testToKuDBMysqlCluster.Spec.MysqlOpts.InitTokuDB = true

cluster/container/init_sidecar.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ func (c *initSidecar) getEnvVars() []corev1.EnvVar {
111111
getEnvVarFromSecret(sctName, "OPERATOR_USER", "operator-user", true),
112112
getEnvVarFromSecret(sctName, "OPERATOR_PASSWORD", "operator-password", true),
113113

114-
//backup user password for sidecar http server
114+
// backup user password for sidecar http server
115115
getEnvVarFromSecret(sctName, "BACKUP_USER", "backup-user", true),
116116
getEnvVarFromSecret(sctName, "BACKUP_PASSWORD", "backup-password", true),
117117
}

cluster/container/init_sidecar_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,11 @@ func TestGetInitSidecarCommand(t *testing.T) {
292292
}
293293

294294
func TestGetInitSidecarEnvVar(t *testing.T) {
295-
//default
295+
// default
296296
{
297297
assert.Equal(t, defaultInitSidecarEnvs, initSidecarCase.Env)
298298
}
299-
//initTokuDB
299+
// initTokuDB
300300
{
301301
testToKuDBMysqlCluster := initSidecarMysqlCluster
302302
testToKuDBMysqlCluster.Spec.MysqlOpts.InitTokuDB = true
@@ -338,11 +338,11 @@ func TestGetInitSidecarReadinessProbe(t *testing.T) {
338338
}
339339

340340
func TestGetInitSidecarVolumeMounts(t *testing.T) {
341-
//default
341+
// default
342342
{
343343
assert.Equal(t, defaultInitsidecarVolumeMounts, initSidecarCase.VolumeMounts)
344344
}
345-
//init tokudb
345+
// init tokudb
346346
{
347347
testToKuDBMysqlCluster := initSidecarMysqlCluster
348348
testToKuDBMysqlCluster.Spec.MysqlOpts.InitTokuDB = true
@@ -358,7 +358,7 @@ func TestGetInitSidecarVolumeMounts(t *testing.T) {
358358
})
359359
assert.Equal(t, tokuDBVolumeMounts, tokudbCase.VolumeMounts)
360360
}
361-
//enable persistence
361+
// enable persistence
362362
{
363363
testPersistenceMysqlCluster := initSidecarMysqlCluster
364364
testPersistenceMysqlCluster.Spec.Persistence.Enabled = true

cluster/container/mysql_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ func TestGetMysqlCommand(t *testing.T) {
6060
}
6161

6262
func TestGetMysqlEnvVar(t *testing.T) {
63-
//base env
63+
// base env
6464
{
6565
assert.Nil(t, mysqlCase.Env)
6666
}
67-
//initTokuDB
67+
// initTokuDB
6868
{
6969
volumeMounts := []corev1.EnvVar{
7070
{

cluster/syncer/metrics_service.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ func NewMetricsSVCSyncer(cli client.Client, c *cluster.Cluster) syncer.Interface
5151
service.Spec.Ports[0].Name = utils.MetricsPortName
5252
service.Spec.Ports[0].Port = utils.MetricsPort
5353
service.Spec.Ports[0].TargetPort = intstr.FromInt(utils.MetricsPort)
54-
5554
return nil
5655
})
5756
}

cluster/syncer/secret.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func NewSecretSyncer(cli client.Client, c *cluster.Cluster) syncer.Interface {
5757
return err
5858
}
5959

60-
//xtrabackup http server user and password
60+
// xtrabackup http server user and password
6161
secret.Data["backup-user"] = []byte(utils.BackupUser)
6262
if err := addRandomPassword(secret.Data, "backup-password"); err != nil {
6363
return err

cluster/syncer/statefulset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ func xenonHttpRequest(host, method, url string, rootPasswd []byte, body io.Reade
576576
return resp.Body, nil
577577
}
578578

579-
//check the backup is exist and running
579+
// check the backup is exist and running
580580
func (s *StatefulSetSyncer) backupIsRunning(ctx context.Context) (bool, error) {
581581
backuplist := apiv1alpha1.BackupList{}
582582
if err := s.cli.List(ctx,

0 commit comments

Comments
 (0)