Skip to content

Commit be01874

Browse files
authored
Merge pull request #7180 from k8s-infra-cherrypick-robot/cherry-pick-6586-to-release-1.1
[release-1.1] ✨ Make KCP's patches option mutable
2 parents 46706c5 + 0836d77 commit be01874

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ const (
113113
initConfiguration = "initConfiguration"
114114
joinConfiguration = "joinConfiguration"
115115
nodeRegistration = "nodeRegistration"
116+
patches = "patches"
117+
directory = "directory"
116118
preKubeadmCommands = "preKubeadmCommands"
117119
postKubeadmCommands = "postKubeadmCommands"
118120
files = "files"
@@ -140,7 +142,9 @@ func (in *KubeadmControlPlane) ValidateUpdate(old runtime.Object) error {
140142
{spec, kubeadmConfigSpec, clusterConfiguration, controllerManager, "*"},
141143
{spec, kubeadmConfigSpec, clusterConfiguration, scheduler, "*"},
142144
{spec, kubeadmConfigSpec, initConfiguration, nodeRegistration, "*"},
145+
{spec, kubeadmConfigSpec, initConfiguration, patches, directory},
143146
{spec, kubeadmConfigSpec, joinConfiguration, nodeRegistration, "*"},
147+
{spec, kubeadmConfigSpec, joinConfiguration, patches, directory},
144148
{spec, kubeadmConfigSpec, preKubeadmCommands},
145149
{spec, kubeadmConfigSpec, postKubeadmCommands},
146150
{spec, kubeadmConfigSpec, files},

controlplane/kubeadm/api/v1beta1/kubeadm_control_plane_webhook_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,16 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
594594
validIgnitionConfigurationAfter := validIgnitionConfigurationBefore.DeepCopy()
595595
validIgnitionConfigurationAfter.Spec.KubeadmConfigSpec.Ignition.ContainerLinuxConfig.AdditionalConfig = "foo: bar"
596596

597+
updateInitConfigurationPatches := before.DeepCopy()
598+
updateInitConfigurationPatches.Spec.KubeadmConfigSpec.InitConfiguration.Patches = &bootstrapv1.Patches{
599+
Directory: "/tmp/patches",
600+
}
601+
602+
updateJoinConfigurationPatches := before.DeepCopy()
603+
updateJoinConfigurationPatches.Spec.KubeadmConfigSpec.InitConfiguration.Patches = &bootstrapv1.Patches{
604+
Directory: "/tmp/patches",
605+
}
606+
597607
tests := []struct {
598608
name string
599609
enableIgnitionFeature bool
@@ -900,6 +910,18 @@ func TestKubeadmControlPlaneValidateUpdate(t *testing.T) {
900910
before: before,
901911
kcp: disableNTPServers,
902912
},
913+
{
914+
name: "should allow changes to initConfiguration.patches",
915+
expectErr: false,
916+
before: before,
917+
kcp: updateInitConfigurationPatches,
918+
},
919+
{
920+
name: "should allow changes to joinConfiguration.patches",
921+
expectErr: false,
922+
before: before,
923+
kcp: updateJoinConfigurationPatches,
924+
},
903925
{
904926
name: "should return error when Ignition configuration is invalid",
905927
enableIgnitionFeature: true,

0 commit comments

Comments
 (0)