Skip to content

Commit 1309241

Browse files
committed
chore: modernize code
1 parent 2b0bd4a commit 1309241

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ require (
3232
k8s.io/apimachinery v0.35.1
3333
k8s.io/client-go v0.35.1
3434
k8s.io/kubectl v0.35.1
35-
k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2
3635
)
3736

3837
require (
@@ -149,6 +148,7 @@ require (
149148
k8s.io/cli-runtime v0.35.1 // indirect
150149
k8s.io/klog/v2 v2.130.1 // indirect
151150
k8s.io/kube-openapi v0.0.0-20250910181357-589584f1c912 // indirect
151+
k8s.io/utils v0.0.0-20260210185600-b8788abfbbc2 // indirect
152152
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 // indirect
153153
sigs.k8s.io/randfill v1.0.0 // indirect
154154
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect

internal/tui/table.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package tui
22

33
import (
4+
"slices"
5+
46
"github.com/charmbracelet/lipgloss"
57
"github.com/charmbracelet/lipgloss/table"
68
)
@@ -15,10 +17,8 @@ func (t *Table) Row(row ...string) *Table {
1517
}
1618

1719
func (t *Table) RowIfNotEmpty(row ...string) *Table {
18-
for _, cell := range row {
19-
if cell == "" {
20-
return t
21-
}
20+
if slices.Contains(row, "") {
21+
return t
2222
}
2323
t.Table.Row(row...)
2424
return t

internal/util/cmd_setup.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030
"k8s.io/apimachinery/pkg/util/intstr"
3131
"k8s.io/apimachinery/pkg/util/wait"
3232
"k8s.io/kubectl/pkg/cmd/util/podcmd"
33-
"k8s.io/utils/ptr"
3433
)
3534

3635
//nolint:gocognit,cyclop,funlen
@@ -273,9 +272,9 @@ func createJob(ctx context.Context, conf *conftypes.Global, actionName string) e
273272
Labels: standardLabels,
274273
},
275274
Spec: batchv1.JobSpec{
276-
ActiveDeadlineSeconds: ptr.To(int64(24 * time.Hour.Seconds())),
277-
TTLSecondsAfterFinished: ptr.To(int32(time.Hour.Seconds())),
278-
BackoffLimit: ptr.To(int32(0)),
275+
ActiveDeadlineSeconds: new(int64(24 * time.Hour.Seconds())),
276+
TTLSecondsAfterFinished: new(int32(time.Hour.Seconds())),
277+
BackoffLimit: new(int32(0)),
279278
Template: corev1.PodTemplateSpec{
280279
ObjectMeta: metav1.ObjectMeta{
281280
Annotations: map[string]string{
@@ -285,7 +284,7 @@ func createJob(ctx context.Context, conf *conftypes.Global, actionName string) e
285284
},
286285
Spec: corev1.PodSpec{
287286
RestartPolicy: corev1.RestartPolicyNever,
288-
TerminationGracePeriodSeconds: ptr.To(int64(0)),
287+
TerminationGracePeriodSeconds: new(int64(0)),
289288
Affinity: &corev1.Affinity{
290289
PodAffinity: &corev1.PodAffinity{
291290
PreferredDuringSchedulingIgnoredDuringExecution: []corev1.WeightedPodAffinityTerm{
@@ -361,12 +360,12 @@ func createJob(ctx context.Context, conf *conftypes.Global, actionName string) e
361360
Egress: []networkingv1.NetworkPolicyEgressRule{
362361
{
363362
To: []networkingv1.NetworkPolicyPeer{{
364-
NamespaceSelector: ptr.To(metav1.LabelSelector{MatchLabels: map[string]string{
363+
NamespaceSelector: new(metav1.LabelSelector{MatchLabels: map[string]string{
365364
"kubernetes.io/metadata.name": conf.Client.Namespace,
366365
}}),
367366
}},
368367
Ports: []networkingv1.NetworkPolicyPort{{
369-
Port: ptr.To(intstr.FromInt32(int32(conf.Port))),
368+
Port: new(intstr.FromInt32(int32(conf.Port))),
370369
}},
371370
},
372371
},

internal/util/cmd_teardown.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ import (
88
"github.com/clevyr/kubedb/internal/config"
99
"github.com/clevyr/kubedb/internal/config/conftypes"
1010
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
11-
"k8s.io/utils/ptr"
1211
)
1312

1413
func Teardown(conf *conftypes.Global) {
1514
if conf.Job != nil {
1615
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
1716
defer cancel()
1817

19-
opts := metav1.DeleteOptions{PropagationPolicy: ptr.To(metav1.DeletePropagationForeground)}
18+
foreground := metav1.DeletePropagationForeground
19+
opts := metav1.DeleteOptions{PropagationPolicy: &foreground}
2020

2121
jobLog := slog.With("name", conf.Job.Name)
2222
jobLog.Info("Cleaning up job")

0 commit comments

Comments
 (0)