Skip to content

Commit

Permalink
feat: Validate network domain name if set
Browse files Browse the repository at this point in the history
  • Loading branch information
hrak committed May 16, 2024
1 parent d863285 commit c341cee
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion api/v1beta3/cloudstackcluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ func (r *CloudStackCluster) ValidateCreate() (admission.Warnings, error) {
field.NewPath("spec", "failureDomains", "ACSEndpoint"),
"Name and Namespace are required"))
}
if fdSpec.Domain != "" {
for _, errMsg := range validation.IsDNS1123Subdomain(fdSpec.Domain) {
errorList = append(errorList, field.Invalid(
field.NewPath("spec", "failureDomains", "domain"), fdSpec.Domain, errMsg))
}
}
}
}

Expand Down Expand Up @@ -155,7 +161,8 @@ func FailureDomainsEqual(fd1, fd2 CloudStackFailureDomainSpec) bool {
fd1.Zone.ID == fd2.Zone.ID &&
fd1.Zone.Network.Name == fd2.Zone.Network.Name &&
fd1.Zone.Network.ID == fd2.Zone.Network.ID &&
fd1.Zone.Network.Type == fd2.Zone.Network.Type
fd1.Zone.Network.Type == fd2.Zone.Network.Type &&
fd1.Zone.Network.Domain == fd2.Zone.Network.Domain
}

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

0 comments on commit c341cee

Please sign in to comment.