Skip to content

Commit 74f1355

Browse files
committed
feat: Validate network domain name if set
1 parent d863285 commit 74f1355

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

api/v1beta3/cloudstackcluster_webhook.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ func (r *CloudStackCluster) ValidateCreate() (admission.Warnings, error) {
7979
field.NewPath("spec", "failureDomains", "ACSEndpoint"),
8080
"Name and Namespace are required"))
8181
}
82+
if fdSpec.Zone.Network.Domain != "" {
83+
for _, errMsg := range validation.IsDNS1123Subdomain(fdSpec.Zone.Network.Domain) {
84+
errorList = append(errorList, field.Invalid(
85+
field.NewPath("spec", "failureDomains", "Zone", "Network"), fdSpec.Zone.Network.Domain, errMsg))
86+
}
87+
}
8288
}
8389
}
8490

@@ -155,7 +161,8 @@ func FailureDomainsEqual(fd1, fd2 CloudStackFailureDomainSpec) bool {
155161
fd1.Zone.ID == fd2.Zone.ID &&
156162
fd1.Zone.Network.Name == fd2.Zone.Network.Name &&
157163
fd1.Zone.Network.ID == fd2.Zone.Network.ID &&
158-
fd1.Zone.Network.Type == fd2.Zone.Network.Type
164+
fd1.Zone.Network.Type == fd2.Zone.Network.Type &&
165+
fd1.Zone.Network.Domain == fd2.Zone.Network.Domain
159166
}
160167

161168
// ValidateDelete implements webhook.Validator so a webhook will be registered for the type

0 commit comments

Comments
 (0)