Skip to content
This repository has been archived by the owner on Jun 25, 2024. It is now read-only.

Implement validation webhook call forwarding to IpSet #257

Open
gibizer opened this issue Jun 30, 2023 · 1 comment
Open

Implement validation webhook call forwarding to IpSet #257

gibizer opened this issue Jun 30, 2023 · 1 comment

Comments

@gibizer
Copy link
Contributor

gibizer commented Jun 30, 2023

The IpSet CR has validation webhook implemented. The DataPlaneRole and Node includes a list of infranetworkv1.IPSetNetwork in its definition. So the DataPlaneRole and Node validation webhook needs to call the parts of the IPSet validation webhook logic so that the user can get immediate feedback during the DataPlaneRole / Node creation in case the input is invalid.

nets := node.Spec.Node.Networks
if len(nets) == 0 {
nets = instance.Spec.NodeTemplate.Networks
}
if len(nets) > 0 {
util.LogForObject(helper, "Reconciling IPSet", instance)
ipSet := &infranetworkv1.IPSet{
ObjectMeta: metav1.ObjectMeta{
Namespace: instance.Namespace,
Name: node.Name,
},
}
_, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), ipSet, func() error {
ipSet.Spec.Networks = nets
// Set controller reference to the DataPlaneNode object
err := controllerutil.SetControllerReference(
helper.GetBeforeObject(), ipSet, helper.GetScheme())
return err
})
if err != nil {
return nil, err
}
allIPSets[node.Name] = *ipSet

@gibizer
Copy link
Contributor Author

gibizer commented Jun 30, 2023

Please note that this might requires changes in the validation webhook implementation in IPSec too.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant