Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Validation for WindowsProfile #2798

Merged
merged 8 commits into from
May 17, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions pkg/api/vlabs/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,10 @@ func (a *AgentPoolProfile) Validate(orchestratorType string) error {
return e
}

if e := validatePoolOSType(a.OSType); e != nil {
return e
}

// for Kubernetes, we don't support AgentPoolProfile.DNSPrefix
if orchestratorType == Kubernetes {
if e := validate.Var(a.DNSPrefix, "len=0"); e != nil {
Expand Down Expand Up @@ -490,9 +494,6 @@ func (a *Properties) Validate(isUpdate bool) error {
return fmt.Errorf("VirtualMachineScaleSets are not supported with Kubernetes since Kubernetes requires the ability to attach/detach disks. To fix specify \"AvailabilityProfile\":\"%s\"", AvailabilitySet)
}
if agentPoolProfile.OSType == Windows {
if e := validate.Var(a.WindowsProfile, "required"); e != nil {
return fmt.Errorf("WindowsProfile must not be empty since agent pool '%s' specifies windows", agentPoolProfile.Name)
}
switch a.OrchestratorProfile.OrchestratorType {
case DCOS:
case Swarm:
Expand Down Expand Up @@ -521,8 +522,12 @@ func (a *Properties) Validate(isUpdate bool) error {
default:
return fmt.Errorf("Orchestrator %s does not support Windows", a.OrchestratorProfile.OrchestratorType)
}
if e := a.WindowsProfile.Validate(); e != nil {
return e
if a.WindowsProfile != nil {
if e := a.WindowsProfile.Validate(); e != nil {
return e
}
} else {
return fmt.Errorf("WindowsProfile is required when the cluster definition contains Windows agent pool(s)")
}
}
}
Expand Down Expand Up @@ -818,6 +823,13 @@ func validatePoolName(poolName string) error {
return nil
}

func validatePoolOSType(os OSType) error {
if os != Linux && os != Windows && os != "" {
return fmt.Errorf("AgentPoolProfile.osType must be either Linux or Windows")
}
return nil
}

func validateDNSName(dnsName string) error {
dnsNameRegex := `^([A-Za-z][A-Za-z0-9-]{1,43}[A-Za-z0-9])$`
re, err := regexp.Compile(dnsNameRegex)
Expand Down