From 85947c49ef47b2aaf995a8b1b874f42630e730e1 Mon Sep 17 00:00:00 2001 From: rabi Date: Tue, 17 Sep 2024 17:22:16 +0530 Subject: [PATCH] Set defaulted values in spec Range copies the values from the slice. Signed-off-by: rabi --- apis/network/v1beta1/netconfig_webhook.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apis/network/v1beta1/netconfig_webhook.go b/apis/network/v1beta1/netconfig_webhook.go index e884e5c8..b9ff2180 100644 --- a/apis/network/v1beta1/netconfig_webhook.go +++ b/apis/network/v1beta1/netconfig_webhook.go @@ -51,12 +51,11 @@ var _ webhook.Defaulter = &NetConfig{} // Default implements webhook.Defaulter so a webhook will be registered for the type func (r *NetConfig) Default() { - for _, net := range r.Spec.Networks { + for idx, net := range r.Spec.Networks { if net.ServiceNetwork == "" { - net.ServiceNetwork = ToDefaultServiceNetwork(net.Name) + r.Spec.Networks[idx].ServiceNetwork = ToDefaultServiceNetwork(net.Name) } } - } //+kubebuilder:webhook:path=/validate-network-openstack-org-v1beta1-netconfig,mutating=false,failurePolicy=fail,sideEffects=None,groups=network.openstack.org,resources=netconfigs,verbs=create;update;delete,versions=v1beta1,name=vnetconfig.kb.io,admissionReviewVersions=v1