mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-23 12:47:48 +00:00
chore: remove KeyName requirement
This commit is contained in:
@@ -60,10 +60,6 @@ func ValidateRunInstancesInput(input *ec2.RunInstancesInput) (err error) {
|
||||
return errors.New(awserrors.ErrorMissingParameter)
|
||||
}
|
||||
|
||||
if input.KeyName == nil || *input.KeyName == "" {
|
||||
return errors.New(awserrors.ErrorMissingParameter)
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(*input.ImageId, "ami-") {
|
||||
return errors.New(awserrors.ErrorInvalidAMIIDMalformed)
|
||||
}
|
||||
|
||||
@@ -191,22 +191,14 @@ func TestParseRunInstances(t *testing.T) {
|
||||
},
|
||||
want: errors.New(awserrors.ErrorMissingParameter),
|
||||
},
|
||||
|
||||
{
|
||||
name: "MissingKeyName",
|
||||
input: &ec2.RunInstancesInput{
|
||||
ImageId: defaults.ImageId,
|
||||
InstanceType: defaults.InstanceType,
|
||||
MinCount: aws.Int64(1),
|
||||
MaxCount: aws.Int64(1),
|
||||
KeyName: nil,
|
||||
SecurityGroupIds: defaults.SecurityGroupIds,
|
||||
SubnetId: defaults.SubnetId,
|
||||
},
|
||||
want: errors.New(awserrors.ErrorMissingParameter),
|
||||
},
|
||||
}
|
||||
|
||||
t.Run("MissingKeyNameIsValid", func(t *testing.T) {
|
||||
input := defaults
|
||||
input.KeyName = nil
|
||||
assert.NoError(t, ValidateRunInstancesInput(&input))
|
||||
})
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
// For validation tests, we can pass nil conn since validation happens before NATS call
|
||||
|
||||
@@ -44,10 +44,6 @@ func ValidateRequestSpotInstancesInput(input *ec2.RequestSpotInstancesInput) err
|
||||
if aws.StringValue(spec.InstanceType) == "" {
|
||||
return errors.New(awserrors.ErrorMissingParameter)
|
||||
}
|
||||
if aws.StringValue(spec.KeyName) == "" {
|
||||
return errors.New(awserrors.ErrorMissingParameter)
|
||||
}
|
||||
|
||||
if input.InstanceCount != nil && *input.InstanceCount < 1 {
|
||||
return errors.New(awserrors.ErrorInvalidParameterValue)
|
||||
}
|
||||
|
||||
@@ -69,14 +69,6 @@ func TestValidateRequestSpotInstancesInput(t *testing.T) {
|
||||
}},
|
||||
want: errors.New(awserrors.ErrorMissingParameter),
|
||||
},
|
||||
{
|
||||
name: "MissingKeyName",
|
||||
input: &ec2.RequestSpotInstancesInput{LaunchSpecification: &ec2.RequestSpotLaunchSpecification{
|
||||
ImageId: aws.String("ami-0abcdef1234567890"),
|
||||
InstanceType: aws.String("t2.micro"),
|
||||
}},
|
||||
want: errors.New(awserrors.ErrorMissingParameter),
|
||||
},
|
||||
{
|
||||
name: "InstanceCountZero",
|
||||
input: &ec2.RequestSpotInstancesInput{
|
||||
@@ -101,6 +93,14 @@ func TestValidateRequestSpotInstancesInput(t *testing.T) {
|
||||
},
|
||||
want: errors.New(awserrors.ErrorInvalidParameterValue),
|
||||
},
|
||||
{
|
||||
name: "MissingKeyNameIsValid",
|
||||
input: &ec2.RequestSpotInstancesInput{LaunchSpecification: &ec2.RequestSpotLaunchSpecification{
|
||||
ImageId: aws.String("ami-0abcdef1234567890"),
|
||||
InstanceType: aws.String("t2.micro"),
|
||||
}},
|
||||
want: nil,
|
||||
},
|
||||
{
|
||||
name: "PersistentTypeAccepted",
|
||||
input: &ec2.RequestSpotInstancesInput{
|
||||
|
||||
Reference in New Issue
Block a user