diff --git a/pkg/api/vlabs/validate.go b/pkg/api/vlabs/validate.go index bf5d293952..978a61cf4e 100644 --- a/pkg/api/vlabs/validate.go +++ b/pkg/api/vlabs/validate.go @@ -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 { @@ -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: @@ -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)") } } } @@ -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)