Skip to content

Commit 0d8545d

Browse files
author
Per Goncalves da Silva
committed
Update webhook configuration naming
Signed-off-by: Per Goncalves da Silva <[email protected]>
1 parent 165086d commit 0d8545d

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

internal/operator-controller/rukpak/render/generators/generators_test.go

+8-8
Original file line numberDiff line numberDiff line change
@@ -1547,8 +1547,8 @@ func Test_BundleValidatingWebhookResourceGenerator_Succeeds(t *testing.T) {
15471547
APIVersion: admissionregistrationv1.SchemeGroupVersion.String(),
15481548
},
15491549
ObjectMeta: metav1.ObjectMeta{
1550-
GenerateName: "my-webhook-",
1551-
Namespace: "install-namespace",
1550+
Name: "my-webhook",
1551+
Namespace: "install-namespace",
15521552
},
15531553
Webhooks: []admissionregistrationv1.ValidatingWebhook{
15541554
{
@@ -1616,8 +1616,8 @@ func Test_BundleValidatingWebhookResourceGenerator_Succeeds(t *testing.T) {
16161616
APIVersion: admissionregistrationv1.SchemeGroupVersion.String(),
16171617
},
16181618
ObjectMeta: metav1.ObjectMeta{
1619-
GenerateName: "my-webhook-",
1620-
Namespace: "install-namespace",
1619+
Name: "my-webhook",
1620+
Namespace: "install-namespace",
16211621
Annotations: map[string]string{
16221622
"cert-provider": "annotation",
16231623
},
@@ -1719,8 +1719,8 @@ func Test_BundleMutatingWebhookResourceGenerator_Succeeds(t *testing.T) {
17191719
APIVersion: admissionregistrationv1.SchemeGroupVersion.String(),
17201720
},
17211721
ObjectMeta: metav1.ObjectMeta{
1722-
GenerateName: "my-webhook-",
1723-
Namespace: "install-namespace",
1722+
Name: "my-webhook",
1723+
Namespace: "install-namespace",
17241724
},
17251725
Webhooks: []admissionregistrationv1.MutatingWebhook{
17261726
{
@@ -1789,8 +1789,8 @@ func Test_BundleMutatingWebhookResourceGenerator_Succeeds(t *testing.T) {
17891789
APIVersion: admissionregistrationv1.SchemeGroupVersion.String(),
17901790
},
17911791
ObjectMeta: metav1.ObjectMeta{
1792-
GenerateName: "my-webhook-",
1793-
Namespace: "install-namespace",
1792+
Name: "my-webhook",
1793+
Namespace: "install-namespace",
17941794
Annotations: map[string]string{
17951795
"cert-provider": "annotation",
17961796
},

internal/operator-controller/rukpak/render/generators/resources.go

+11-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package generators
22

33
import (
4-
"fmt"
5-
64
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
75
appsv1 "k8s.io/api/apps/v1"
86
corev1 "k8s.io/api/core/v1"
@@ -217,36 +215,41 @@ func CreateDeploymentResource(name string, namespace string, opts ...ResourceCre
217215
).(*appsv1.Deployment)
218216
}
219217

220-
func CreateValidatingWebhookConfigurationResource(generateName string, namespace string, opts ...ResourceCreatorOption) *admissionregistrationv1.ValidatingWebhookConfiguration {
218+
// CreateValidatingWebhookConfigurationResource creates a ValidatingWebhookConfiguration resource with name 'name',
219+
// namespace 'namespace', and applying any ValidatingWebhookConfiguration related options in opts
220+
func CreateValidatingWebhookConfigurationResource(name string, namespace string, opts ...ResourceCreatorOption) *admissionregistrationv1.ValidatingWebhookConfiguration {
221221
return ResourceCreatorOptions(opts).ApplyTo(
222222
&admissionregistrationv1.ValidatingWebhookConfiguration{
223223
TypeMeta: metav1.TypeMeta{
224224
Kind: "ValidatingWebhookConfiguration",
225225
APIVersion: admissionregistrationv1.SchemeGroupVersion.String(),
226226
},
227227
ObjectMeta: metav1.ObjectMeta{
228-
GenerateName: fmt.Sprintf("%s-", generateName),
229-
Namespace: namespace,
228+
Name: name,
229+
Namespace: namespace,
230230
},
231231
},
232232
).(*admissionregistrationv1.ValidatingWebhookConfiguration)
233233
}
234234

235-
func CreateMutatingWebhookConfigurationResource(generateName string, namespace string, opts ...ResourceCreatorOption) *admissionregistrationv1.MutatingWebhookConfiguration {
235+
// CreateMutatingWebhookConfigurationResource creates a MutatingWebhookConfiguration resource with name 'name',
236+
// namespace 'namespace', and applying any MutatingWebhookConfiguration related options in opts
237+
func CreateMutatingWebhookConfigurationResource(name string, namespace string, opts ...ResourceCreatorOption) *admissionregistrationv1.MutatingWebhookConfiguration {
236238
return ResourceCreatorOptions(opts).ApplyTo(
237239
&admissionregistrationv1.MutatingWebhookConfiguration{
238240
TypeMeta: metav1.TypeMeta{
239241
Kind: "MutatingWebhookConfiguration",
240242
APIVersion: admissionregistrationv1.SchemeGroupVersion.String(),
241243
},
242244
ObjectMeta: metav1.ObjectMeta{
243-
GenerateName: fmt.Sprintf("%s-", generateName),
244-
Namespace: namespace,
245+
Name: name,
246+
Namespace: namespace,
245247
},
246248
},
247249
).(*admissionregistrationv1.MutatingWebhookConfiguration)
248250
}
249251

252+
// CreateServiceResource creates a Service resource with name 'name', namespace 'namespace', and applying any Service related options in opts
250253
func CreateServiceResource(name string, namespace string, opts ...ResourceCreatorOption) *corev1.Service {
251254
return ResourceCreatorOptions(opts).ApplyTo(&corev1.Service{
252255
TypeMeta: metav1.TypeMeta{

internal/operator-controller/rukpak/render/generators/resources_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,14 @@ func Test_CreateService(t *testing.T) {
8585
func Test_CreateValidatingWebhookConfiguration(t *testing.T) {
8686
wh := generators.CreateValidatingWebhookConfigurationResource("my-validating-webhook-configuration", "my-namespace")
8787
require.NotNil(t, wh)
88-
require.Equal(t, "my-validating-webhook-configuration-", wh.GenerateName)
88+
require.Equal(t, "my-validating-webhook-configuration", wh.Name)
8989
require.Equal(t, "my-namespace", wh.Namespace)
9090
}
9191

9292
func Test_CreateMutatingWebhookConfiguration(t *testing.T) {
9393
wh := generators.CreateMutatingWebhookConfigurationResource("my-mutating-webhook-configuration", "my-namespace")
9494
require.NotNil(t, wh)
95-
require.Equal(t, "my-mutating-webhook-configuration-", wh.GenerateName)
95+
require.Equal(t, "my-mutating-webhook-configuration", wh.Name)
9696
require.Equal(t, "my-namespace", wh.Namespace)
9797
}
9898

0 commit comments

Comments
 (0)