Skip to content

Commit 43c65ba

Browse files
committed
Don't use pointers for string.
1 parent 48d5575 commit 43c65ba

File tree

3 files changed

+10
-32
lines changed

3 files changed

+10
-32
lines changed

pkg/apis/mysql/v1alpha1/cluster.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -287,25 +287,21 @@ func (ql *QueryLimits) GetOptions() []string {
287287
"--busy-time", fmt.Sprintf("%d", ql.MaxQueryTime),
288288
}
289289

290-
if ql.KillMode != nil {
291-
switch *ql.KillMode {
292-
case "connection":
293-
options = append(options, "--kill")
294-
case "query":
295-
options = append(options, "--kill-query")
296-
default:
297-
options = append(options, "--kill-query")
298-
}
299-
} else {
290+
switch ql.KillMode {
291+
case "connection":
292+
options = append(options, "--kill")
293+
case "query":
294+
options = append(options, "--kill-query")
295+
default:
300296
options = append(options, "--kill-query")
301297
}
302298

303299
if ql.MaxIdleTime != nil {
304300
options = append(options, "--idle-time", fmt.Sprintf("%d", *ql.MaxIdleTime))
305301
}
306302

307-
if ql.Kill != nil {
308-
options = append(options, "--victims", *ql.Kill)
303+
if len(ql.Kill) != 0 {
304+
options = append(options, "--victims", ql.Kill)
309305
}
310306

311307
if len(ql.IgnoreDb) > 0 {

pkg/apis/mysql/v1alpha1/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,14 @@ type QueryLimits struct {
182182
// By default, the matching query with the highest Time value is killed (the
183183
// oldest query.
184184
// +optional
185-
Kill *string `json:"kill,omitempty"`
185+
Kill string `json:"kill,omitempty"`
186186

187187
// KillMode can be: `connection` or `query`, when it's used `connection`
188188
// means that when a query is matched the connection is killed (using --kill
189189
// flag) and if it's used `query` means that the query is killed (using
190190
// --kill-query flag)
191191
// +optional
192-
KillMode *string `json:"killMode,omitempty"`
192+
KillMode string `json:"killMode,omitempty"`
193193

194194
// IgnoreDb is the list of database that are ignored by pt-kill (--ignore-db
195195
// flag).

pkg/apis/mysql/v1alpha1/zz_generated.deepcopy.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -393,24 +393,6 @@ func (in *QueryLimits) DeepCopyInto(out *QueryLimits) {
393393
**out = **in
394394
}
395395
}
396-
if in.Kill != nil {
397-
in, out := &in.Kill, &out.Kill
398-
if *in == nil {
399-
*out = nil
400-
} else {
401-
*out = new(string)
402-
**out = **in
403-
}
404-
}
405-
if in.KillMode != nil {
406-
in, out := &in.KillMode, &out.KillMode
407-
if *in == nil {
408-
*out = nil
409-
} else {
410-
*out = new(string)
411-
**out = **in
412-
}
413-
}
414396
if in.IgnoreDb != nil {
415397
in, out := &in.IgnoreDb, &out.IgnoreDb
416398
*out = make([]string, len(*in))

0 commit comments

Comments
 (0)