Skip to content

Commit 175b291

Browse files
committed
use meta.GenerateName for steak names
1 parent 2b1e100 commit 175b291

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

controllers/steakfulset_controller.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import (
2121
"math/rand"
2222

2323
"k8s.io/apimachinery/pkg/runtime"
24-
krand "k8s.io/apimachinery/pkg/util/rand"
2524
ref "k8s.io/client-go/tools/reference"
2625

2726
ctrl "sigs.k8s.io/controller-runtime"
@@ -105,10 +104,8 @@ func (r *SteakfulSetReconciler) Reconcile(ctx context.Context, req ctrl.Request)
105104
for actualSteakCount < desiredSteakCount {
106105
steak := foodv1alpha1.Steak{
107106
ObjectMeta: metav1.ObjectMeta{
108-
Labels: make(map[string]string),
109-
Annotations: make(map[string]string),
110-
Name: fmt.Sprintf("%s-%s", steakfulSet.Name, krand.String(6)),
111-
Namespace: steakfulSet.Namespace,
107+
GenerateName: fmt.Sprintf("%s-", steakfulSet.Name),
108+
Namespace: steakfulSet.Namespace,
112109
},
113110
Spec: *steakfulSet.Spec.Steak.Spec.DeepCopy(),
114111
}

0 commit comments

Comments
 (0)