mirror of
https://github.com/mulgadc/spinifex.git
synced 2026-10-21 19:56:33 +00:00
fix: change "attached" to "available" in igw to match aws + add describe instance types filtering for TF
This commit is contained in:
@@ -113,6 +113,14 @@ func DescribeInstanceTypes(input *ec2.DescribeInstanceTypesInput, natsConn *nats
|
||||
}
|
||||
}
|
||||
|
||||
// Build set of requested instance type names (if any) for filtering.
|
||||
requestedTypes := make(map[string]bool)
|
||||
for _, it := range input.InstanceTypes {
|
||||
if it != nil {
|
||||
requestedTypes[*it] = true
|
||||
}
|
||||
}
|
||||
|
||||
var finalInstanceTypes []*ec2.InstanceTypeInfo
|
||||
if showCapacity {
|
||||
finalInstanceTypes = allInstanceTypes
|
||||
@@ -128,6 +136,17 @@ func DescribeInstanceTypes(input *ec2.DescribeInstanceTypesInput, natsConn *nats
|
||||
}
|
||||
}
|
||||
|
||||
// Filter by requested instance type names if specified.
|
||||
if len(requestedTypes) > 0 {
|
||||
var filtered []*ec2.InstanceTypeInfo
|
||||
for _, it := range finalInstanceTypes {
|
||||
if it != nil && it.InstanceType != nil && requestedTypes[*it.InstanceType] {
|
||||
filtered = append(filtered, it)
|
||||
}
|
||||
}
|
||||
finalInstanceTypes = filtered
|
||||
}
|
||||
|
||||
// Build final aggregated response
|
||||
output := &ec2.DescribeInstanceTypesOutput{
|
||||
InstanceTypes: finalInstanceTypes,
|
||||
|
||||
@@ -252,7 +252,7 @@ func (s *IGWServiceImpl) AttachInternetGateway(input *ec2.AttachInternetGatewayI
|
||||
}
|
||||
|
||||
record.VpcId = vpcID
|
||||
record.State = "attached"
|
||||
record.State = "available"
|
||||
|
||||
data, err := json.Marshal(record)
|
||||
if err != nil {
|
||||
|
||||
@@ -210,7 +210,7 @@ func TestAttachInternetGateway(t *testing.T) {
|
||||
require.Len(t, desc.InternetGateways, 1)
|
||||
require.Len(t, desc.InternetGateways[0].Attachments, 1)
|
||||
assert.Equal(t, "vpc-test123", *desc.InternetGateways[0].Attachments[0].VpcId)
|
||||
assert.Equal(t, "attached", *desc.InternetGateways[0].Attachments[0].State)
|
||||
assert.Equal(t, "available", *desc.InternetGateways[0].Attachments[0].State)
|
||||
}
|
||||
|
||||
func TestAttachInternetGateway_NotFound(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user