Skip to content

Commit 4c53a9c

Browse files
committed
test: update credentials proivider api version to v1
1 parent 9922b3c commit 4c53a9c

File tree

7 files changed

+319
-198
lines changed

7 files changed

+319
-198
lines changed

api/v1alpha1/clusterconfig_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ func (ImageCredentials) VariableSchema() clusterv1.VariableSchema {
263263
"namespace": {
264264
Description: "The namespace of the Secret containing the registry credentials. " +
265265
"Defaults to the namespace of the KubeadmControlPlaneTemplate and KubeadmConfigTemplate" +
266-
" that reference this variable.",
266+
"that reference this variable.",
267267
Type: "string",
268268
},
269269
},

common/pkg/testutils/capitest/request/items.go

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import (
2121

2222
const (
2323
ClusterName = "test-cluster"
24-
KubeadmConfigTemplateRequestObjectName = "test-kubeadmconfigtemplate"
25-
KubeadmControlPlaneTemplateRequestObjectName = "test-kubeadmcontrolplanetemplate"
24+
kubeadmConfigTemplateRequestObjectName = "test-kubeadmconfigtemplate"
25+
kubeadmControlPlaneTemplateRequestObjectName = "test-kubeadmcontrolplanetemplate"
2626
Namespace = corev1.NamespaceDefault
2727
)
2828

@@ -45,15 +45,24 @@ func NewRequestItem(
4545
}
4646
}
4747

48-
func NewKubeadmConfigTemplateRequestItem(uid types.UID) runtimehooksv1.GeneratePatchesRequestItem {
48+
func NewKubeadmConfigTemplateRequestItem(
49+
uid types.UID,
50+
) runtimehooksv1.GeneratePatchesRequestItem {
51+
return NewKubeadmConfigTemplateRequest(uid, kubeadmConfigTemplateRequestObjectName)
52+
}
53+
54+
func NewKubeadmConfigTemplateRequest(
55+
uid types.UID,
56+
name string,
57+
) runtimehooksv1.GeneratePatchesRequestItem {
4958
return NewRequestItem(
5059
&bootstrapv1.KubeadmConfigTemplate{
5160
TypeMeta: metav1.TypeMeta{
5261
APIVersion: bootstrapv1.GroupVersion.String(),
5362
Kind: "KubeadmConfigTemplate",
5463
},
5564
ObjectMeta: metav1.ObjectMeta{
56-
Name: KubeadmConfigTemplateRequestObjectName,
65+
Name: name,
5766
Namespace: Namespace,
5867
},
5968
Spec: bootstrapv1.KubeadmConfigTemplateSpec{
@@ -75,8 +84,9 @@ func NewKubeadmConfigTemplateRequestItem(uid types.UID) runtimehooksv1.GenerateP
7584
)
7685
}
7786

78-
func NewKubeadmControlPlaneTemplateRequestItem(
87+
func NewKubeadmControlPlaneTemplateRequest(
7988
uid types.UID,
89+
name string,
8090
) runtimehooksv1.GeneratePatchesRequestItem {
8191
return NewRequestItem(
8292
&controlplanev1.KubeadmControlPlaneTemplate{
@@ -85,7 +95,7 @@ func NewKubeadmControlPlaneTemplateRequestItem(
8595
Kind: "KubeadmControlPlaneTemplate",
8696
},
8797
ObjectMeta: metav1.ObjectMeta{
88-
Name: KubeadmControlPlaneTemplateRequestObjectName,
98+
Name: name,
8999
Namespace: Namespace,
90100
},
91101
Spec: controlplanev1.KubeadmControlPlaneTemplateSpec{
@@ -113,6 +123,12 @@ func NewKubeadmControlPlaneTemplateRequestItem(
113123
)
114124
}
115125

126+
func NewKubeadmControlPlaneTemplateRequestItem(
127+
uid types.UID,
128+
) runtimehooksv1.GeneratePatchesRequestItem {
129+
return NewKubeadmControlPlaneTemplateRequest(uid, kubeadmControlPlaneTemplateRequestObjectName)
130+
}
131+
116132
func NewAWSClusterTemplateRequestItem(
117133
uid types.UID,
118134
existingSpec ...capav1.AWSClusterTemplateSpec,

pkg/handlers/aws/mutation/metapatch_handler_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,14 @@ func TestGeneratePatches(t *testing.T) {
156156
imageregistries.VariableName,
157157
)
158158

159+
imageregistrycredentialstests.TestGenerateMirrorPatches(
160+
t,
161+
metaPatchGeneratorFunc(mgr),
162+
mgr.GetClient(),
163+
clusterconfig.MetaVariableName,
164+
imageregistries.VariableName,
165+
)
166+
159167
amitests.TestControlPlaneGeneratePatches(
160168
t,
161169
metaPatchGeneratorFunc(mgr),

pkg/handlers/docker/mutation/metapatch_handler_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,12 @@ func TestGeneratePatches(t *testing.T) {
112112
clusterconfig.MetaVariableName,
113113
imageregistries.VariableName,
114114
)
115+
116+
imageregistrycredentialstests.TestGenerateMirrorPatches(
117+
t,
118+
metaPatchGeneratorFunc(mgr),
119+
mgr.GetClient(),
120+
clusterconfig.MetaVariableName,
121+
imageregistries.VariableName,
122+
)
115123
}

pkg/handlers/generic/mutation/imageregistries/credentials/credential_provider_config_files_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ mirror:
208208
credentialsStrategy: "MirrorCredentialsOnly"
209209
credentialProviderPluginBinDir: /etc/kubernetes/image-credential-provider/
210210
credentialProviders:
211-
apiVersion: kubelet.config.k8s.io/v1beta1
211+
apiVersion: kubelet.config.k8s.io/v1
212212
kind: CredentialProviderConfig
213213
providers:
214214
- name: ecr-credential-provider
@@ -217,7 +217,7 @@ credentialProviders:
217217
matchImages:
218218
- "123456789.dkr.ecr.us-east-1.amazonaws.com"
219219
defaultCacheDuration: "0s"
220-
apiVersion: credentialprovider.kubelet.k8s.io/v1alpha1
220+
apiVersion: credentialprovider.kubelet.k8s.io/v1
221221
`,
222222
},
223223
},
@@ -244,7 +244,7 @@ mirror:
244244
credentialsStrategy: "MirrorCredentialsOnly"
245245
credentialProviderPluginBinDir: /etc/kubernetes/image-credential-provider/
246246
credentialProviders:
247-
apiVersion: kubelet.config.k8s.io/v1beta1
247+
apiVersion: kubelet.config.k8s.io/v1
248248
kind: CredentialProviderConfig
249249
providers:
250250
- name: static-credential-provider
@@ -253,7 +253,7 @@ credentialProviders:
253253
matchImages:
254254
- "myregistry.com"
255255
defaultCacheDuration: "0s"
256-
apiVersion: credentialprovider.kubelet.k8s.io/v1beta1
256+
apiVersion: credentialprovider.kubelet.k8s.io/v1
257257
`,
258258
},
259259
},

0 commit comments

Comments
 (0)