Skip to content

Commit

Permalink
fix(azure): Fix validation of target properties
Browse files Browse the repository at this point in the history
  • Loading branch information
asalkeld committed Feb 18, 2022
1 parent 9586ec2 commit b652a9c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/provider/pulumi/azure/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,23 @@ func (a *azureProvider) SupportedRegions() []string {
func (a *azureProvider) Validate() error {
errList := utils.NewErrorList()

if !sliceutil.Contains(a.SupportedRegions(), a.t.Region) {
if a.t.Region == "" {
errList.Add(fmt.Errorf("target %s requires \"region\"", a.t.Provider))
} else if !sliceutil.Contains(a.SupportedRegions(), a.t.Region) {
errList.Add(utils.NewNotSupportedErr(fmt.Sprintf("region %s not supported on provider %s", a.t.Region, a.t.Provider)))
}

if _, ok := a.t.Extra["org"]; !ok {
errList.Add(fmt.Errorf("target %s requires \"org\"", a.t.Provider))
} else {
a.org = a.t.Extra["org"].(string)
}
a.org = a.t.Extra["org"].(string)

if _, ok := a.t.Extra["adminemail"]; !ok {
errList.Add(fmt.Errorf("target %s requires \"adminemail\"", a.t.Provider))
} else {
a.adminEmail = a.t.Extra["adminemail"].(string)
}
a.adminEmail = a.t.Extra["adminemail"].(string)

return errList.Aggregate()
}
Expand Down

0 comments on commit b652a9c

Please sign in to comment.