-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor nodegroup validation, check IAM attrs
- Loading branch information
1 parent
3d4f452
commit d449a7f
Showing
2 changed files
with
38 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package v1alpha3 | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
func ValidateNodeGroup(i int, ng *NodeGroup) error { | ||
path := fmt.Errorf("nodegroups[%d]", i) | ||
if ng.Name == "" { | ||
return fmt.Errorf("%s.name must be set", path) | ||
} | ||
|
||
if ng.IAM.InstanceRoleARN != "" { | ||
p := fmt.Sprintf("%s.iam.instanceRoleARN and %s.iam", path, path) | ||
if ng.IAM.InstanceRoleName != "" { | ||
return fmt.Errorf("%s.instanceRoleName cannot be set at the same time", p) | ||
} | ||
if len(ng.IAM.AttachPolicyARNs) != 0 { | ||
return fmt.Errorf("%s.attachPolicyARNs cannot be set at the same time", p) | ||
} | ||
if ng.IAM.WithAddonPolicies.AutoScaler { | ||
return fmt.Errorf("%s.withAddonPolicies.autoScaler cannot be set at the same time", p) | ||
} | ||
if ng.IAM.WithAddonPolicies.ExternalDNS { | ||
return fmt.Errorf("%s.withAddonPolicies.externalDNS cannot be set at the same time", p) | ||
} | ||
if ng.IAM.WithAddonPolicies.ImageBuilder { | ||
return fmt.Errorf("%s.imageBuilder cannot be set at the same time", p) | ||
} | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters