mockec2: allow elastic ip tagging

This commit is contained in:
Justin Santa Barbara 2018-03-25 00:01:41 -04:00
parent 4d10cc82e9
commit e81e53b5b2
3 changed files with 6 additions and 3 deletions

View File

@ -71,7 +71,7 @@ func (m *MockEC2) AllocateAddressWithId(request *ec2.AllocateAddressInput, id st
func (m *MockEC2) AllocateAddress(request *ec2.AllocateAddressInput) (*ec2.AllocateAddressOutput, error) {
glog.Infof("AllocateAddress: %v", request)
id := m.allocateId("eip")
id := m.allocateId("eipalloc")
return m.AllocateAddressWithId(request, id)
}

View File

@ -29,6 +29,7 @@ import (
// Not (yet?) in aws-sdk-go
const ResourceTypeNatGateway = "nat-gateway"
const ResourceTypeAddress = "elastic-ip"
func (m *MockEC2) CreateTagsRequest(*ec2.CreateTagsInput) (*request.Request, *ec2.CreateTagsOutput) {
panic("Not implemented")
@ -74,6 +75,8 @@ func (m *MockEC2) addTag(resourceId string, tag *ec2.Tag) {
resourceType = ec2.ResourceTypeDhcpOptions
} else if strings.HasPrefix(resourceId, "rtb-") {
resourceType = ec2.ResourceTypeRouteTable
} else if strings.HasPrefix(resourceId, "eipalloc-") {
resourceType = ResourceTypeAddress
} else {
glog.Fatalf("Unknown resource-type in create tags: %v", resourceId)
}

View File

@ -172,11 +172,11 @@ func (h *IntegrationTestHarness) SetupMockAWS() *awsup.MockAWSCloud {
mockEC2.AllocateAddressWithId(&ec2.AllocateAddressInput{
Address: aws.String("123.45.67.8"),
}, "eip-12345678")
}, "eipalloc-12345678")
mockEC2.CreateNatGatewayWithId(&ec2.CreateNatGatewayInput{
SubnetId: aws.String("subnet-12345678"),
AllocationId: aws.String("eip-12345678"),
AllocationId: aws.String("eipalloc-12345678"),
}, "nat-12345678")
return cloud