func()

in api/v1beta1/cloudstackcluster_webhook.go [55:74]


func (r *CloudStackCluster) ValidateCreate() error {
	cloudstackclusterlog.Info("validate create", "name", r.Name)

	var errorList field.ErrorList

	// IdentityRefs must be Secrets.
	if r.Spec.IdentityRef != nil && r.Spec.IdentityRef.Kind != defaultIdentityRefKind {
		errorList = append(errorList, field.Forbidden(field.NewPath("spec", "identityRef", "kind"), "must be a Secret"))
	}

	if (r.Spec.Account != "") && (r.Spec.Domain == "") {
		errorList = append(errorList, field.Required(field.NewPath("spec", "account"), "specifying account requires additionally specifying domain"))
	}

	// Zone and Network are required fields
	errorList = webhook_utilities.EnsureFieldExists(r.Spec.Zone, "Zone", errorList)
	errorList = webhook_utilities.EnsureFieldExists(r.Spec.Network, "Network", errorList)

	return webhook_utilities.AggregateObjErrors(r.GroupVersionKind().GroupKind(), r.Name, errorList)
}