@@ -42,25 +42,25 @@ type namespacedCloudProfile struct {
4242
4343// Validate validates the given NamespacedCloudProfile objects.
4444func (p * namespacedCloudProfile ) Validate (ctx context.Context , newObj , _ client.Object ) error {
45- profile , ok := newObj .(* core.NamespacedCloudProfile )
45+ cloudProfile , ok := newObj .(* core.NamespacedCloudProfile )
4646 if ! ok {
4747 return fmt .Errorf ("wrong object type %T" , newObj )
4848 }
4949
50- if profile .DeletionTimestamp != nil {
50+ if cloudProfile .DeletionTimestamp != nil {
5151 return nil
5252 }
5353
54- cpConfig := & api.CloudProfileConfig {}
55- if profile .Spec .ProviderConfig != nil {
54+ cloudProfileConfig := & api.CloudProfileConfig {}
55+ if cloudProfile .Spec .ProviderConfig != nil {
5656 var err error
57- cpConfig , err = decodeCloudProfileConfig (p .decoder , profile .Spec .ProviderConfig )
57+ cloudProfileConfig , err = decodeCloudProfileConfig (p .decoder , cloudProfile .Spec .ProviderConfig )
5858 if err != nil {
59- return err
59+ return fmt . Errorf ( "could not decode providerConfig of NamespacedCloudProfile for '%s': %w" , cloudProfile . Name , err )
6060 }
6161 }
6262
63- parentCloudProfile := profile .Spec .Parent
63+ parentCloudProfile := cloudProfile .Spec .Parent
6464 if parentCloudProfile .Kind != constants .CloudProfileReferenceKindCloudProfile {
6565 return fmt .Errorf ("parent reference must be of kind CloudProfile (unsupported kind: %s)" , parentCloudProfile .Kind )
6666 }
@@ -69,16 +69,7 @@ func (p *namespacedCloudProfile) Validate(ctx context.Context, newObj, _ client.
6969 return err
7070 }
7171
72- return p .validateNamespacedCloudProfileProviderConfig (cpConfig , profile .Spec , parentProfile .Spec ).ToAggregate ()
73- }
74-
75- // validateNamespacedCloudProfileProviderConfig validates the CloudProfileConfig passed with a NamespacedCloudProfile.
76- func (p * namespacedCloudProfile ) validateNamespacedCloudProfileProviderConfig (providerConfig * api.CloudProfileConfig , profileSpec core.NamespacedCloudProfileSpec , parentSpec gardencorev1beta1.CloudProfileSpec ) field.ErrorList {
77- allErrs := field.ErrorList {}
78-
79- allErrs = append (allErrs , p .validateMachineImages (providerConfig , profileSpec .MachineImages , parentSpec )... )
80-
81- return allErrs
72+ return p .validateMachineImages (cloudProfileConfig , cloudProfile .Spec .MachineImages , parentProfile .Spec ).ToAggregate ()
8273}
8374
8475func (p * namespacedCloudProfile ) validateMachineImages (providerConfig * api.CloudProfileConfig , machineImages []core.MachineImage , parentSpec gardencorev1beta1.CloudProfileSpec ) field.ErrorList {
@@ -87,7 +78,7 @@ func (p *namespacedCloudProfile) validateMachineImages(providerConfig *api.Cloud
8778 machineImagesPath := field .NewPath ("spec.providerConfig.machineImages" )
8879 for i , machineImage := range providerConfig .MachineImages {
8980 idxPath := machineImagesPath .Index (i )
90- allErrs = append (allErrs , validation .ValidateProviderMachineImage (idxPath , machineImage , parentSpec .MachineCapabilities )... )
81+ allErrs = append (allErrs , validation .ValidateProviderMachineImage (machineImage , parentSpec .MachineCapabilities , idxPath )... )
9182 }
9283
9384 profileImages := gutil .NewCoreImagesContext (machineImages )
0 commit comments