@@ -94,15 +94,15 @@ func ClusterClassTemplateAreCompatible(current, desired clusterv1.ClusterClassTe
94
94
95
95
if currentGK .Group != desiredGK .Group {
96
96
allErrs = append (allErrs , field .Forbidden (
97
- pathPrefix .Child ("ref" , " apiVersion" ),
98
- fmt .Sprintf ("apiVersion. group cannot be changed from %q to %q to prevent incompatible changes in the Clusters" ,
97
+ pathPrefix .Child ("apiVersion" ),
98
+ fmt .Sprintf ("group of apiVersion cannot be changed from %q to %q to prevent incompatible changes in the Clusters" ,
99
99
currentGK .Group , desiredGK .Group ),
100
100
))
101
101
}
102
102
if currentGK .Kind != desiredGK .Kind {
103
103
allErrs = append (allErrs , field .Forbidden (
104
- pathPrefix .Child ("ref" , " kind" ),
105
- fmt .Sprintf ("apiVersion. kind cannot be changed from %q to %q to prevent incompatible changes in the Clusters" ,
104
+ pathPrefix .Child ("kind" ),
105
+ fmt .Sprintf ("kind cannot be changed from %q to %q to prevent incompatible changes in the Clusters" ,
106
106
currentGK .Kind , desiredGK .Kind ),
107
107
))
108
108
}
@@ -174,14 +174,14 @@ func ClusterClassesAreCompatible(current, desired *clusterv1.ClusterClass) field
174
174
175
175
// Validate InfrastructureClusterTemplate changes desired a compatible way.
176
176
allErrs = append (allErrs , ClusterClassTemplateAreCompatible (current .Spec .Infrastructure .TemplateRef , desired .Spec .Infrastructure .TemplateRef ,
177
- field .NewPath ("spec" , "infrastructure" ))... )
177
+ field .NewPath ("spec" , "infrastructure" , "templateRef" ))... )
178
178
179
179
// Validate control plane changes desired a compatible way.
180
180
allErrs = append (allErrs , ClusterClassTemplateAreCompatible (current .Spec .ControlPlane .TemplateRef , desired .Spec .ControlPlane .TemplateRef ,
181
- field .NewPath ("spec" , "controlPlane" ))... )
181
+ field .NewPath ("spec" , "controlPlane" , "templateRef" ))... )
182
182
if desired .Spec .ControlPlane .MachineInfrastructure .TemplateRef .IsDefined () && current .Spec .ControlPlane .MachineInfrastructure .TemplateRef .IsDefined () {
183
183
allErrs = append (allErrs , ClusterClassTemplateAreCompatible (current .Spec .ControlPlane .MachineInfrastructure .TemplateRef , desired .Spec .ControlPlane .MachineInfrastructure .TemplateRef ,
184
- field .NewPath ("spec" , "controlPlane" , "machineInfrastructure" ))... )
184
+ field .NewPath ("spec" , "controlPlane" , "machineInfrastructure" , "templateRef" ))... )
185
185
}
186
186
187
187
// Validate changes to MachineDeployments.
@@ -199,16 +199,16 @@ func MachineDeploymentClassesAreCompatible(current, desired *clusterv1.ClusterCl
199
199
var allErrs field.ErrorList
200
200
201
201
// Ensure previous MachineDeployment class was modified in a compatible way.
202
- for _ , class := range desired .Spec .Workers .MachineDeployments {
203
- for i , oldClass := range current .Spec .Workers .MachineDeployments {
202
+ for i , class := range desired .Spec .Workers .MachineDeployments {
203
+ for _ , oldClass := range current .Spec .Workers .MachineDeployments {
204
204
if class .Class == oldClass .Class {
205
205
// NOTE: class.Template.Metadata and class.Template.Bootstrap are allowed to change;
206
206
207
207
// class.Template.Bootstrap is ensured syntactically correct by LocalObjectTemplateIsValid.
208
208
209
209
// Validates class.Template.Infrastructure template changes in a compatible way
210
210
allErrs = append (allErrs , ClusterClassTemplateAreCompatible (oldClass .Infrastructure .TemplateRef , class .Infrastructure .TemplateRef ,
211
- field .NewPath ("spec" , "workers" , "machineDeployments" ).Index (i ))... )
211
+ field .NewPath ("spec" , "workers" , "machineDeployments" ).Index (i ). Child ( "infrastructure" , "templateRef" ) )... )
212
212
}
213
213
}
214
214
}
@@ -240,16 +240,16 @@ func MachinePoolClassesAreCompatible(current, desired *clusterv1.ClusterClass) f
240
240
var allErrs field.ErrorList
241
241
242
242
// Ensure previous MachinePool class was modified in a compatible way.
243
- for _ , class := range desired .Spec .Workers .MachinePools {
244
- for i , oldClass := range current .Spec .Workers .MachinePools {
243
+ for i , class := range desired .Spec .Workers .MachinePools {
244
+ for _ , oldClass := range current .Spec .Workers .MachinePools {
245
245
if class .Class == oldClass .Class {
246
246
// NOTE: class.Template.Metadata and class.Template.Bootstrap are allowed to change;
247
247
248
248
// class.Template.Bootstrap is ensured syntactically correct by LocalObjectTemplateIsValid.
249
249
250
250
// Validates class.Template.Infrastructure template changes in a compatible way
251
251
allErrs = append (allErrs , ClusterClassTemplateAreCompatible (oldClass .Infrastructure .TemplateRef , class .Infrastructure .TemplateRef ,
252
- field .NewPath ("spec" , "workers" , "machinePools" ).Index (i ))... )
252
+ field .NewPath ("spec" , "workers" , "machinePools" ).Index (i ). Child ( "infrastructure" , "templateRef" ) )... )
253
253
}
254
254
}
255
255
}
0 commit comments