Skip to content

Commit 0fe38ef

Browse files
committed
feat: add v1beta2 validation webhooks
Signed-off-by: Bharath Nallapeta <nr.bharath97@gmail.com>
1 parent 67b7359 commit 0fe38ef

12 files changed

Lines changed: 2329 additions & 23 deletions

config/webhook/manifests.yaml

Lines changed: 84 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/webhooks/openstackcluster_webhook.go

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,10 @@ func (*openStackClusterWebhook) ValidateCreate(_ context.Context, objRaw runtime
5656
}
5757

5858
if newObj.Spec.ManagedSecurityGroups != nil {
59-
for _, rule := range newObj.Spec.ManagedSecurityGroups.AllNodesSecurityGroupRules {
60-
if rule.RemoteManagedGroups != nil && (rule.RemoteGroupID != nil || rule.RemoteIPPrefix != nil) {
61-
allErrs = append(allErrs, field.Forbidden(field.NewPath("spec", "managedSecurityGroups", "allNodesSecurityGroupRules"), "remoteManagedGroups cannot be used with remoteGroupID or remoteIPPrefix"))
62-
}
63-
if rule.RemoteGroupID != nil && (rule.RemoteManagedGroups != nil || rule.RemoteIPPrefix != nil) {
64-
allErrs = append(allErrs, field.Forbidden(field.NewPath("spec", "managedSecurityGroups", "allNodesSecurityGroupRules"), "remoteGroupID cannot be used with remoteManagedGroups or remoteIPPrefix"))
65-
}
66-
if rule.RemoteIPPrefix != nil && (rule.RemoteManagedGroups != nil || rule.RemoteGroupID != nil) {
67-
allErrs = append(allErrs, field.Forbidden(field.NewPath("spec", "managedSecurityGroups", "allNodesSecurityGroupRules"), "remoteIPPrefix cannot be used with remoteManagedGroups or remoteGroupID"))
68-
}
69-
}
59+
allErrs = append(allErrs, validateSecurityGroupRulesRemoteMutualExclusionV1Beta1(
60+
newObj.Spec.ManagedSecurityGroups.AllNodesSecurityGroupRules,
61+
field.NewPath("spec", "managedSecurityGroups", "allNodesSecurityGroupRules"),
62+
)...)
7063
}
7164

7265
return aggregateObjErrors(newObj.GroupVersionKind().GroupKind(), newObj.Name, allErrs)

0 commit comments

Comments
 (0)