@@ -48,18 +48,17 @@ func (r *CloudStackMachineTemplate) Default() {
4848 // No defaulted values supported yet.
4949}
5050
51- //+kubebuilder:webhook:path=/validate-infrastructure-cluster-x-k8s-io-v1beta2-cloudstackmachinetemplate,mutating=false,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=cloudstackmachinetemplates,verbs=create;update,versions=v1beta2,name=vcloudstackmachinetemplate.kb.io,admissionReviewVersions=v1beta1
52-
51+ // +kubebuilder:webhook:path=/validate-infrastructure-cluster-x-k8s-io-v1beta2-cloudstackmachinetemplate,mutating=false,failurePolicy=fail,sideEffects=None,groups=infrastructure.cluster.x-k8s.io,resources=cloudstackmachinetemplates,verbs=create;update,versions=v1beta2,name=vcloudstackmachinetemplate.kb.io,admissionReviewVersions=v1beta1
5352var _ webhook.Validator = & CloudStackMachineTemplate {}
5453
5554// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
5655func (r * CloudStackMachineTemplate ) ValidateCreate () error {
5756 cloudstackmachinetemplatelog .V (1 ).Info ("entered validate create webhook" , "api resource name" , r .Name )
5857
59- var (
60- errorList field. ErrorList
61- spec = r . Spec . Spec . Spec // CloudStackMachineTemplateSpec.CloudStackMachineTemplateResource.CloudStackMachineSpec
62- )
58+ var errorList field. ErrorList
59+
60+ // CloudStackMachineTemplateSpec.CloudStackMachineTemplateResource.CloudStackMachineSpec
61+ spec := r . Spec . Spec . Spec
6362
6463 affinity := strings .ToLower (spec .Affinity )
6564 if ! (affinity == "" || affinity == "no" || affinity == "pro" || affinity == "anti" ) {
@@ -91,12 +90,15 @@ func (r *CloudStackMachineTemplate) ValidateUpdate(old runtime.Object) error {
9190 oldSpec := oldMachineTemplate .Spec .Spec .Spec
9291
9392 errorList := field .ErrorList (nil )
94- errorList = webhookutil .EnsureBothFieldsAreEqual (spec .Offering .ID , spec .Offering .Name , oldSpec .Offering .ID , oldSpec .Offering .Name , "offering" , errorList )
95- errorList = webhookutil .EnsureBothFieldsAreEqual (spec .DiskOffering .ID , spec .DiskOffering .Name , oldSpec .DiskOffering .ID , oldSpec .DiskOffering .Name , "diskOffering" , errorList )
96- errorList = webhookutil .EnsureStringFieldsAreEqual (spec .SSHKey , oldSpec .SSHKey , "sshkey" , errorList )
97- errorList = webhookutil .EnsureBothFieldsAreEqual (spec .Template .ID , spec .Template .Name , oldSpec .Template .ID , oldSpec .Template .Name , "template" , errorList )
98- errorList = webhookutil .EnsureStringStringMapFieldsAreEqual (& spec .Details , & oldSpec .Details , "details" , errorList )
99- errorList = webhookutil .EnsureStringFieldsAreEqual (spec .Affinity , oldSpec .Affinity , "affinity" , errorList )
93+ errorList = webhookutil .EnsureEqualStrings (spec .Offering .ID , oldSpec .Offering .ID , "offering" , errorList )
94+ errorList = webhookutil .EnsureEqualStrings (spec .Offering .Name , oldSpec .Offering .Name , "offering" , errorList )
95+ errorList = webhookutil .EnsureEqualStrings (spec .DiskOffering .ID , oldSpec .DiskOffering .ID , "diskOffering" , errorList )
96+ errorList = webhookutil .EnsureEqualStrings (spec .DiskOffering .Name , oldSpec .DiskOffering .Name , "diskOffering" , errorList )
97+ errorList = webhookutil .EnsureEqualStrings (spec .SSHKey , oldSpec .SSHKey , "sshkey" , errorList )
98+ errorList = webhookutil .EnsureEqualStrings (spec .Template .ID , oldSpec .Template .ID , "template" , errorList )
99+ errorList = webhookutil .EnsureEqualStrings (spec .Template .Name , oldSpec .Template .Name , "template" , errorList )
100+ errorList = webhookutil .EnsureEqualMapStringString (& spec .Details , & oldSpec .Details , "details" , errorList )
101+ errorList = webhookutil .EnsureEqualStrings (spec .Affinity , oldSpec .Affinity , "affinity" , errorList )
100102
101103 if ! reflect .DeepEqual (spec .AffinityGroupIDs , oldSpec .AffinityGroupIDs ) { // Equivalent to other Ensure funcs.
102104 errorList = append (errorList , field .Forbidden (field .NewPath ("spec" , "AffinityGroupIDs" ), "AffinityGroupIDs" ))
0 commit comments