@@ -315,7 +315,7 @@ func getDNS() (*osconfigv1.DNS, error) {
315
315
return dns , nil
316
316
}
317
317
318
- type machineAdmissionFn func (m , mOld * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList )
318
+ type machineAdmissionFn func (m * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList )
319
319
320
320
type admissionConfig struct {
321
321
clusterID string
@@ -396,7 +396,7 @@ func getMachineValidatorOperation(platform osconfigv1.PlatformType) machineAdmis
396
396
return validateNutanix
397
397
default :
398
398
// just no-op
399
- return func (m , mOld * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
399
+ return func (m * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
400
400
return true , []string {}, nil
401
401
}
402
402
}
@@ -441,7 +441,7 @@ func getMachineDefaulterOperation(platformStatus *osconfigv1.PlatformStatus) mac
441
441
return defaultNutanix
442
442
default :
443
443
// just no-op
444
- return func (m , mOld * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
444
+ return func (m * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
445
445
return true , []string {}, nil
446
446
}
447
447
}
@@ -462,7 +462,7 @@ func (h *machineValidatorHandler) validateMachine(m, oldM *machinev1beta1.Machin
462
462
463
463
errs := validateMachineLifecycleHooks (m , oldM )
464
464
465
- ok , warnings , opErrs := h .webhookOperations (m , oldM , h .admissionConfig )
465
+ ok , warnings , opErrs := h .webhookOperations (m , h .admissionConfig )
466
466
if ! ok {
467
467
errs = append (errs , opErrs ... )
468
468
}
@@ -549,7 +549,7 @@ func (h *machineDefaulterHandler) Default(ctx context.Context, obj runtime.Objec
549
549
m .Labels [machinev1beta1 .MachineClusterIDLabel ] = h .clusterID
550
550
}
551
551
552
- ok , _ , errs := h .webhookOperations (m , nil , h .admissionConfig )
552
+ ok , _ , errs := h .webhookOperations (m , h .admissionConfig )
553
553
if ! ok {
554
554
return errs .ToAggregate ()
555
555
}
@@ -561,7 +561,7 @@ type awsDefaulter struct {
561
561
region string
562
562
}
563
563
564
- func (a awsDefaulter ) defaultAWS (m , mOld * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
564
+ func (a awsDefaulter ) defaultAWS (m * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
565
565
klog .V (3 ).Infof ("Defaulting AWS providerSpec" )
566
566
567
567
var errs field.ErrorList
@@ -633,7 +633,7 @@ func validateUnknownFields(m *machinev1beta1.Machine, providerSpec interface{})
633
633
return nil
634
634
}
635
635
636
- func validateAWS (m , mOld * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
636
+ func validateAWS (m * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
637
637
klog .V (3 ).Infof ("Validating AWS providerSpec" )
638
638
639
639
var errs field.ErrorList
@@ -803,7 +803,7 @@ func getDuplicatedTags(tagSpecs []machinev1beta1.TagSpecification) []string {
803
803
return duplicatedTags
804
804
}
805
805
806
- func defaultAzure (m , mOld * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
806
+ func defaultAzure (m * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
807
807
klog .V (3 ).Infof ("Defaulting Azure providerSpec" )
808
808
809
809
var errs field.ErrorList
@@ -864,7 +864,7 @@ func defaultAzure(m, mOld *machinev1beta1.Machine, config *admissionConfig) (boo
864
864
return true , warnings , nil
865
865
}
866
866
867
- func validateAzure (m , mOld * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
867
+ func validateAzure (m * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
868
868
klog .V (3 ).Infof ("Validating Azure providerSpec" )
869
869
870
870
var errs field.ErrorList
@@ -931,18 +931,6 @@ func validateAzure(m, mOld *machinev1beta1.Machine, config *admissionConfig) (bo
931
931
fmt .Sprintf ("osDisk.diskSettings.ephemeralStorageLocation can either be omitted or set to %s" , azureEphemeralStorageLocationLocal )))
932
932
}
933
933
934
- if mOld != nil {
935
- oldProviderSpec := new (machinev1beta1.AzureMachineProviderSpec )
936
- if err := unmarshalInto (mOld , oldProviderSpec ); err != nil {
937
- errs = append (errs , err )
938
- return false , warnings , errs
939
- }
940
- if providerSpec .CapacityReservationGroupID != "" && ! validateAzureImmutabilityForCapacityReservationGroupID (oldProviderSpec .CapacityReservationGroupID , providerSpec .CapacityReservationGroupID ) {
941
- errs = append (errs , field .Invalid (field .NewPath ("providerSpec" , "capacityReservationGroupID" ),
942
- providerSpec .CapacityReservationGroupID , "capacityReservationGroupID is immutable" ))
943
- }
944
- }
945
-
946
934
if providerSpec .CapacityReservationGroupID != "" {
947
935
err := validateAzureCapacityReservationGroupID (providerSpec .CapacityReservationGroupID )
948
936
if err != nil {
@@ -1043,7 +1031,7 @@ func validateAzureDiagnostics(diagnosticsSpec machinev1beta1.AzureDiagnostics, p
1043
1031
return errs
1044
1032
}
1045
1033
1046
- func defaultGCP (m , mOld * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
1034
+ func defaultGCP (m * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
1047
1035
klog .V (3 ).Infof ("Defaulting GCP providerSpec" )
1048
1036
1049
1037
var errs field.ErrorList
@@ -1131,7 +1119,7 @@ func defaultGCPDisks(disks []*machinev1beta1.GCPDisk, clusterID string) []*machi
1131
1119
return disks
1132
1120
}
1133
1121
1134
- func validateGCP (m , mOld * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
1122
+ func validateGCP (m * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
1135
1123
klog .V (3 ).Infof ("Validating GCP providerSpec" )
1136
1124
1137
1125
var errs field.ErrorList
@@ -1366,7 +1354,7 @@ func validateGCPServiceAccounts(serviceAccounts []machinev1beta1.GCPServiceAccou
1366
1354
return errs
1367
1355
}
1368
1356
1369
- func defaultVSphere (m , mOld * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
1357
+ func defaultVSphere (m * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
1370
1358
klog .V (3 ).Infof ("Defaulting vSphere providerSpec" )
1371
1359
1372
1360
var errs field.ErrorList
@@ -1398,7 +1386,7 @@ func defaultVSphere(m, mOld *machinev1beta1.Machine, config *admissionConfig) (b
1398
1386
return true , warnings , nil
1399
1387
}
1400
1388
1401
- func validateVSphere (m , mOld * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
1389
+ func validateVSphere (m * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
1402
1390
klog .V (3 ).Infof ("Validating vSphere providerSpec" )
1403
1391
1404
1392
var errs field.ErrorList
@@ -1514,7 +1502,7 @@ func validateVSphereNetwork(network machinev1beta1.NetworkSpec, parentPath *fiel
1514
1502
return errs
1515
1503
}
1516
1504
1517
- func defaultNutanix (m , mOld * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
1505
+ func defaultNutanix (m * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
1518
1506
klog .V (3 ).Infof ("Defaulting nutanix providerSpec" )
1519
1507
1520
1508
var errs field.ErrorList
@@ -1546,7 +1534,7 @@ func defaultNutanix(m, mOld *machinev1beta1.Machine, config *admissionConfig) (b
1546
1534
return true , warnings , nil
1547
1535
}
1548
1536
1549
- func validateNutanix (m , mOld * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
1537
+ func validateNutanix (m * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
1550
1538
klog .V (3 ).Infof ("Validating nutanix providerSpec" )
1551
1539
1552
1540
var errs field.ErrorList
@@ -1855,7 +1843,7 @@ func validateAzureDataDisks(machineName string, spec *machinev1beta1.AzureMachin
1855
1843
return errs
1856
1844
}
1857
1845
1858
- func defaultPowerVS (m , mOld * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
1846
+ func defaultPowerVS (m * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
1859
1847
klog .V (3 ).Infof ("Defaulting PowerVS providerSpec" )
1860
1848
1861
1849
var errs field.ErrorList
@@ -1902,7 +1890,7 @@ func defaultPowerVS(m, mOld *machinev1beta1.Machine, config *admissionConfig) (b
1902
1890
return true , warnings , nil
1903
1891
}
1904
1892
1905
- func validatePowerVS (m , mOld * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
1893
+ func validatePowerVS (m * machinev1beta1.Machine , config * admissionConfig ) (bool , []string , field.ErrorList ) {
1906
1894
klog .V (3 ).Infof ("Validating PowerVS providerSpec" )
1907
1895
1908
1896
var errs field.ErrorList
@@ -2081,10 +2069,6 @@ func validateGVK(gvk schema.GroupVersionKind, platform osconfigv1.PlatformType)
2081
2069
}
2082
2070
}
2083
2071
2084
- func validateAzureImmutabilityForCapacityReservationGroupID (oldID string , newID string ) bool {
2085
- return oldID == newID
2086
- }
2087
-
2088
2072
func validateAzureCapacityReservationGroupID (capacityReservationGroupID string ) error {
2089
2073
id := strings .TrimPrefix (capacityReservationGroupID , azureProviderIDPrefix )
2090
2074
err := parseAzureResourceID (id )
0 commit comments