mirror of https://github.com/kubernetes/kops.git
Use AWS SDK list of enum values for api validation
This commit is contained in:
parent
cf0bb8d2fd
commit
5f1e9bc962
|
|
@ -25,6 +25,7 @@ go_library(
|
|||
"//upup/pkg/fi:go_default_library",
|
||||
"//upup/pkg/fi/cloudup/awsup:go_default_library",
|
||||
"//vendor/github.com/aws/aws-sdk-go/aws/arn:go_default_library",
|
||||
"//vendor/github.com/aws/aws-sdk-go/service/ec2:go_default_library",
|
||||
"//vendor/github.com/blang/semver/v4:go_default_library",
|
||||
"//vendor/golang.org/x/net/ipv4:go_default_library",
|
||||
"//vendor/golang.org/x/net/ipv6:go_default_library",
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import (
|
|||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
"k8s.io/kops/pkg/apis/kops"
|
||||
|
|
@ -104,9 +105,8 @@ func awsValidateSpotDurationInMinute(fieldPath *field.Path, ig *kops.InstanceGro
|
|||
func awsValidateInstanceInterruptionBehavior(fieldPath *field.Path, ig *kops.InstanceGroup) field.ErrorList {
|
||||
allErrs := field.ErrorList{}
|
||||
if ig.Spec.InstanceInterruptionBehavior != nil {
|
||||
validInterruptionBehaviors := []string{"terminate", "hibernate", "stop"}
|
||||
instanceInterruptionBehavior := *ig.Spec.InstanceInterruptionBehavior
|
||||
allErrs = append(allErrs, IsValidValue(fieldPath, &instanceInterruptionBehavior, validInterruptionBehaviors)...)
|
||||
allErrs = append(allErrs, IsValidValue(fieldPath, &instanceInterruptionBehavior, ec2.InstanceInterruptionBehavior_Values())...)
|
||||
}
|
||||
return allErrs
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import (
|
|||
"k8s.io/kops/pkg/nodeidentity/aws"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws/arn"
|
||||
"github.com/aws/aws-sdk-go/service/ec2"
|
||||
"k8s.io/apimachinery/pkg/util/validation/field"
|
||||
"k8s.io/kops/pkg/apis/kops"
|
||||
"k8s.io/kops/upup/pkg/fi"
|
||||
|
|
@ -55,7 +56,7 @@ func ValidateInstanceGroup(g *kops.InstanceGroup, cloud fi.Cloud) field.ErrorLis
|
|||
}
|
||||
|
||||
if g.Spec.Tenancy != "" {
|
||||
allErrs = append(allErrs, IsValidValue(field.NewPath("spec", "tenancy"), &g.Spec.Tenancy, []string{"default", "dedicated", "host"})...)
|
||||
allErrs = append(allErrs, IsValidValue(field.NewPath("spec", "tenancy"), &g.Spec.Tenancy, ec2.Tenancy_Values())...)
|
||||
}
|
||||
|
||||
if g.Spec.MaxSize != nil && g.Spec.MinSize != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue