More mocks - sufficient for privatecalico to roundtrip

This commit is contained in:
Justin Santa Barbara 2018-03-11 15:19:04 -04:00
parent 994a348cb4
commit ab7439b360
19 changed files with 575 additions and 62 deletions

View File

@ -4,6 +4,7 @@ go_library(
name = "go_default_library",
srcs = [
"api.go",
"attach.go",
"group.go",
"launchconfigurations.go",
"unimplemented.go",

View File

@ -0,0 +1,52 @@
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package mockautoscaling
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/autoscaling"
"github.com/golang/glog"
)
func (m *MockAutoscaling) AttachLoadBalancers(request *autoscaling.AttachLoadBalancersInput) (*autoscaling.AttachLoadBalancersOutput, error) {
m.mutex.Lock()
defer m.mutex.Unlock()
glog.Infof("AttachLoadBalancers: %v", request)
name := *request.AutoScalingGroupName
asg := m.Groups[name]
if asg == nil {
return nil, fmt.Errorf("Group %q not found", name)
}
asg.LoadBalancerNames = request.LoadBalancerNames
return &autoscaling.AttachLoadBalancersOutput{}, nil
}
func (m *MockAutoscaling) AttachLoadBalancersWithContext(aws.Context, *autoscaling.AttachLoadBalancersInput, ...request.Option) (*autoscaling.AttachLoadBalancersOutput, error) {
glog.Fatalf("Not implemented")
return nil, nil
}
func (m *MockAutoscaling) AttachLoadBalancersRequest(*autoscaling.AttachLoadBalancersInput) (*request.Request, *autoscaling.AttachLoadBalancersOutput) {
glog.Fatalf("Not implemented")
return nil, nil
}

View File

@ -190,6 +190,7 @@ func (m *MockAutoscaling) DescribeAutoScalingGroupsPages(request *autoscaling.De
return nil
}
func (m *MockAutoscaling) DescribeAutoScalingGroupsPagesWithContext(aws.Context, *autoscaling.DescribeAutoScalingGroupsInput, func(*autoscaling.DescribeAutoScalingGroupsOutput, bool) bool, ...request.Option) error {
glog.Fatalf("Not implemented")
return nil

View File

@ -45,19 +45,6 @@ func (m *MockAutoscaling) AttachLoadBalancerTargetGroupsRequest(*autoscaling.Att
return nil, nil
}
func (m *MockAutoscaling) AttachLoadBalancers(*autoscaling.AttachLoadBalancersInput) (*autoscaling.AttachLoadBalancersOutput, error) {
glog.Fatalf("Not implemented")
return nil, nil
}
func (m *MockAutoscaling) AttachLoadBalancersWithContext(aws.Context, *autoscaling.AttachLoadBalancersInput, ...request.Option) (*autoscaling.AttachLoadBalancersOutput, error) {
glog.Fatalf("Not implemented")
return nil, nil
}
func (m *MockAutoscaling) AttachLoadBalancersRequest(*autoscaling.AttachLoadBalancersInput) (*request.Request, *autoscaling.AttachLoadBalancersOutput) {
glog.Fatalf("Not implemented")
return nil, nil
}
func (m *MockAutoscaling) CompleteLifecycleAction(*autoscaling.CompleteLifecycleActionInput) (*autoscaling.CompleteLifecycleActionOutput, error) {
glog.Fatalf("Not implemented")
return nil, nil

View File

@ -10,6 +10,7 @@ go_library(
"images.go",
"internetgateways.go",
"keypairs.go",
"natgateway.go",
"routetable.go",
"securitygroups.go",
"subnets.go",

View File

@ -54,6 +54,8 @@ type MockEC2 struct {
internetGatewayNumber int
InternetGateways map[string]*internetGatewayInfo
NatGateways map[string]*ec2.NatGateway
ids map[string]*idAllocator
}

View File

@ -93,6 +93,9 @@ func (m *MockEC2) DescribeInternetGatewaysWithContext(aws.Context, *ec2.Describe
}
func (m *MockEC2) DescribeInternetGateways(request *ec2.DescribeInternetGatewaysInput) (*ec2.DescribeInternetGatewaysOutput, error) {
m.mutex.Lock()
defer m.mutex.Unlock()
glog.Infof("DescribeInternetGateways: %v", request)
var internetGateways []*ec2.InternetGateway

View File

@ -0,0 +1,174 @@
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package mockec2
import (
"fmt"
"strings"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/golang/glog"
)
func (m *MockEC2) CreateNatGateway(request *ec2.CreateNatGatewayInput) (*ec2.CreateNatGatewayOutput, error) {
m.mutex.Lock()
defer m.mutex.Unlock()
glog.Infof("CreateNatGateway: %v", request)
id := m.allocateId("ngw")
ngw := &ec2.NatGateway{
NatGatewayId: s(id),
SubnetId: request.SubnetId,
}
if request.AllocationId != nil {
var eip *ec2.Address
for _, address := range m.Addresses {
if aws.StringValue(address.AllocationId) == *request.AllocationId {
eip = address
}
}
if eip == nil {
return nil, fmt.Errorf("AllocationId %q not found", *request.AllocationId)
}
ngw.NatGatewayAddresses = append(ngw.NatGatewayAddresses, &ec2.NatGatewayAddress{
AllocationId: eip.AllocationId,
PrivateIp: eip.PrivateIpAddress,
PublicIp: eip.PublicIp,
})
}
if m.NatGateways == nil {
m.NatGateways = make(map[string]*ec2.NatGateway)
}
m.NatGateways[*ngw.NatGatewayId] = ngw
copy := *ngw
return &ec2.CreateNatGatewayOutput{
NatGateway: &copy,
ClientToken: request.ClientToken,
}, nil
}
func (m *MockEC2) WaitUntilNatGatewayAvailable(request *ec2.DescribeNatGatewaysInput) error {
m.mutex.Lock()
defer m.mutex.Unlock()
glog.Infof("WaitUntilNatGatewayAvailable: %v", request)
if len(request.NatGatewayIds) != 1 {
return fmt.Errorf("we only support WaitUntilNatGatewayAvailable with one NatGatewayId")
}
ngw := m.NatGateways[*request.NatGatewayIds[0]]
if ngw == nil {
return fmt.Errorf("NatGateway not found")
}
// We just immediately mark it ready
ngw.State = aws.String("Available")
return nil
}
func (m *MockEC2) WaitUntilNatGatewayAvailableWithContext(aws.Context, *ec2.DescribeNatGatewaysInput, ...request.WaiterOption) error {
panic("Not implemented")
return nil
}
func (m *MockEC2) CreateNatGatewayWithContext(aws.Context, *ec2.CreateNatGatewayInput, ...request.Option) (*ec2.CreateNatGatewayOutput, error) {
panic("Not implemented")
return nil, nil
}
func (m *MockEC2) CreateNatGatewayRequest(*ec2.CreateNatGatewayInput) (*request.Request, *ec2.CreateNatGatewayOutput) {
panic("Not implemented")
return nil, nil
}
func (m *MockEC2) DescribeNatGateways(request *ec2.DescribeNatGatewaysInput) (*ec2.DescribeNatGatewaysOutput, error) {
m.mutex.Lock()
defer m.mutex.Unlock()
glog.Infof("DescribeNatGateways: %v", request)
var ngws []*ec2.NatGateway
if len(request.NatGatewayIds) != 0 {
request.Filter = append(request.Filter, &ec2.Filter{Name: s("nat-gateway-id"), Values: request.NatGatewayIds})
}
for id, ngw := range m.NatGateways {
allFiltersMatch := true
for _, filter := range request.Filter {
match := false
switch *filter.Name {
case "nat-gateway-id":
for _, v := range filter.Values {
if *ngw.NatGatewayId == *v {
match = true
}
}
default:
if strings.HasPrefix(*filter.Name, "tag:") {
match = m.hasTag(ResourceTypeNatGateway, *ngw.NatGatewayId, filter)
} else {
return nil, fmt.Errorf("unknown filter name: %q", *filter.Name)
}
}
if !match {
allFiltersMatch = false
break
}
}
if !allFiltersMatch {
continue
}
copy := *ngw
copy.Tags = m.getTags(ResourceTypeNatGateway, id)
ngws = append(ngws, &copy)
}
response := &ec2.DescribeNatGatewaysOutput{
NatGateways: ngws,
}
return response, nil
}
func (m *MockEC2) DescribeNatGatewaysWithContext(aws.Context, *ec2.DescribeNatGatewaysInput, ...request.Option) (*ec2.DescribeNatGatewaysOutput, error) {
panic("Not implemented")
return nil, nil
}
func (m *MockEC2) DescribeNatGatewaysRequest(*ec2.DescribeNatGatewaysInput) (*request.Request, *ec2.DescribeNatGatewaysOutput) {
panic("Not implemented")
return nil, nil
}
func (m *MockEC2) DescribeNatGatewaysPages(*ec2.DescribeNatGatewaysInput, func(*ec2.DescribeNatGatewaysOutput, bool) bool) error {
panic("Not implemented")
return nil
}
func (m *MockEC2) DescribeNatGatewaysPagesWithContext(aws.Context, *ec2.DescribeNatGatewaysInput, func(*ec2.DescribeNatGatewaysOutput, bool) bool, ...request.Option) error {
panic("Not implemented")
return nil
}

View File

@ -27,6 +27,9 @@ import (
"github.com/golang/glog"
)
// Not (yet?) in aws-sdk-go
const ResourceTypeNatGateway = "nat-gateway"
func (m *MockEC2) CreateTagsRequest(*ec2.CreateTagsInput) (*request.Request, *ec2.CreateTagsOutput) {
panic("Not implemented")
return nil, nil
@ -62,6 +65,8 @@ func (m *MockEC2) addTag(resourceId string, tag *ec2.Tag) {
resourceType = ec2.ResourceTypeVolume
} else if strings.HasPrefix(resourceId, "igw-") {
resourceType = ec2.ResourceTypeInternetGateway
} else if strings.HasPrefix(resourceId, "ngw-") {
resourceType = ResourceTypeNatGateway
} else if strings.HasPrefix(resourceId, "dopt-") {
resourceType = ec2.ResourceTypeDhcpOptions
} else if strings.HasPrefix(resourceId, "rtb-") {

View File

@ -399,19 +399,6 @@ func (m *MockEC2) CreateInstanceExportTaskRequest(*ec2.CreateInstanceExportTaskI
return nil, nil
}
func (m *MockEC2) CreateNatGateway(*ec2.CreateNatGatewayInput) (*ec2.CreateNatGatewayOutput, error) {
panic("Not implemented")
return nil, nil
}
func (m *MockEC2) CreateNatGatewayWithContext(aws.Context, *ec2.CreateNatGatewayInput, ...request.Option) (*ec2.CreateNatGatewayOutput, error) {
panic("Not implemented")
return nil, nil
}
func (m *MockEC2) CreateNatGatewayRequest(*ec2.CreateNatGatewayInput) (*request.Request, *ec2.CreateNatGatewayOutput) {
panic("Not implemented")
return nil, nil
}
func (m *MockEC2) CreateNetworkAcl(*ec2.CreateNetworkAclInput) (*ec2.CreateNetworkAclOutput, error) {
panic("Not implemented")
return nil, nil
@ -1223,28 +1210,6 @@ func (m *MockEC2) DescribeMovingAddressesRequest(*ec2.DescribeMovingAddressesInp
return nil, nil
}
func (m *MockEC2) DescribeNatGateways(*ec2.DescribeNatGatewaysInput) (*ec2.DescribeNatGatewaysOutput, error) {
panic("Not implemented")
return nil, nil
}
func (m *MockEC2) DescribeNatGatewaysWithContext(aws.Context, *ec2.DescribeNatGatewaysInput, ...request.Option) (*ec2.DescribeNatGatewaysOutput, error) {
panic("Not implemented")
return nil, nil
}
func (m *MockEC2) DescribeNatGatewaysRequest(*ec2.DescribeNatGatewaysInput) (*request.Request, *ec2.DescribeNatGatewaysOutput) {
panic("Not implemented")
return nil, nil
}
func (m *MockEC2) DescribeNatGatewaysPages(*ec2.DescribeNatGatewaysInput, func(*ec2.DescribeNatGatewaysOutput, bool) bool) error {
panic("Not implemented")
return nil
}
func (m *MockEC2) DescribeNatGatewaysPagesWithContext(aws.Context, *ec2.DescribeNatGatewaysInput, func(*ec2.DescribeNatGatewaysOutput, bool) bool, ...request.Option) error {
panic("Not implemented")
return nil
}
func (m *MockEC2) DescribeNetworkAcls(*ec2.DescribeNetworkAclsInput) (*ec2.DescribeNetworkAclsOutput, error) {
panic("Not implemented")
return nil, nil
@ -2725,15 +2690,6 @@ func (m *MockEC2) WaitUntilKeyPairExistsWithContext(aws.Context, *ec2.DescribeKe
return nil
}
func (m *MockEC2) WaitUntilNatGatewayAvailable(*ec2.DescribeNatGatewaysInput) error {
panic("Not implemented")
return nil
}
func (m *MockEC2) WaitUntilNatGatewayAvailableWithContext(aws.Context, *ec2.DescribeNatGatewaysInput, ...request.WaiterOption) error {
panic("Not implemented")
return nil
}
func (m *MockEC2) WaitUntilNetworkInterfaceAvailable(*ec2.DescribeNetworkInterfacesInput) error {
panic("Not implemented")
return nil

View File

@ -2,11 +2,18 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = ["api.go"],
srcs = [
"api.go",
"attributes.go",
"healthcheck.go",
"tags.go",
],
importpath = "k8s.io/kops/cloudmock/aws/mockelb",
visibility = ["//visibility:public"],
deps = [
"//vendor/github.com/aws/aws-sdk-go/aws:go_default_library",
"//vendor/github.com/aws/aws-sdk-go/service/elb:go_default_library",
"//vendor/github.com/aws/aws-sdk-go/service/elb/elbiface:go_default_library",
"//vendor/github.com/golang/glog:go_default_library",
],
)

View File

@ -17,14 +17,126 @@ limitations under the License.
package mockelb
import (
"sync"
"time"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/elb"
"github.com/aws/aws-sdk-go/service/elb/elbiface"
"github.com/golang/glog"
)
const elbZoneID = "FAKEZONE-CLOUDMOCK-ELB"
type MockELB struct {
elbiface.ELBAPI
mutex sync.Mutex
LoadBalancers map[string]*loadBalancer
}
func (*MockELB) DescribeLoadBalancersPages(input *elb.DescribeLoadBalancersInput, fn func(p *elb.DescribeLoadBalancersOutput, lastPage bool) (shouldContinue bool)) error {
type loadBalancer struct {
description elb.LoadBalancerDescription
attributes elb.LoadBalancerAttributes
tags map[string]string
}
func (m *MockELB) DescribeLoadBalancers(request *elb.DescribeLoadBalancersInput) (*elb.DescribeLoadBalancersOutput, error) {
m.mutex.Lock()
defer m.mutex.Unlock()
glog.V(2).Infof("DescribeLoadBalancers %v", request)
if request.PageSize != nil {
glog.Warningf("PageSize not implemented")
}
if request.Marker != nil {
glog.Fatalf("Marker not implemented")
}
var elbs []*elb.LoadBalancerDescription
for _, elb := range m.LoadBalancers {
match := false
if len(request.LoadBalancerNames) > 0 {
for _, name := range request.LoadBalancerNames {
if aws.StringValue(elb.description.LoadBalancerName) == aws.StringValue(name) {
match = true
}
}
} else {
match = true
}
if match {
elbs = append(elbs, &elb.description)
}
}
return &elb.DescribeLoadBalancersOutput{
LoadBalancerDescriptions: elbs,
}, nil
}
func (m *MockELB) DescribeLoadBalancersPages(request *elb.DescribeLoadBalancersInput, callback func(p *elb.DescribeLoadBalancersOutput, lastPage bool) (shouldContinue bool)) error {
// For the mock, we just send everything in one page
page, err := m.DescribeLoadBalancers(request)
if err != nil {
return err
}
callback(page, false)
return nil
}
func (m *MockELB) CreateLoadBalancer(request *elb.CreateLoadBalancerInput) (*elb.CreateLoadBalancerOutput, error) {
m.mutex.Lock()
defer m.mutex.Unlock()
glog.V(2).Infof("CreateLoadBalancer %v", request)
createdTime := time.Now().UTC()
dnsName := *request.LoadBalancerName + ".elb.cloudmock.com"
lb := &loadBalancer{
description: elb.LoadBalancerDescription{
AvailabilityZones: request.AvailabilityZones,
CreatedTime: &createdTime,
LoadBalancerName: request.LoadBalancerName,
Scheme: request.Scheme,
SecurityGroups: request.SecurityGroups,
Subnets: request.Subnets,
DNSName: aws.String(dnsName),
CanonicalHostedZoneNameID: aws.String(elbZoneID),
},
tags: make(map[string]string),
}
for _, listener := range request.Listeners {
lb.description.ListenerDescriptions = append(lb.description.ListenerDescriptions, &elb.ListenerDescription{
Listener: listener,
})
}
// for _, tag := range input.Tags {
// g.Tags = append(g.Tags, &autoscaling.TagDescription{
// Key: tag.Key,
// PropagateAtLaunch: tag.PropagateAtLaunch,
// ResourceId: tag.ResourceId,
// ResourceType: tag.ResourceType,
// Value: tag.Value,
// })
// }
if m.LoadBalancers == nil {
m.LoadBalancers = make(map[string]*loadBalancer)
}
m.LoadBalancers[*request.LoadBalancerName] = lb
return &elb.CreateLoadBalancerOutput{
DNSName: aws.String(dnsName),
}, nil
}

View File

@ -0,0 +1,64 @@
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package mockelb
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/elb"
"github.com/golang/glog"
)
func (m *MockELB) ModifyLoadBalancerAttributes(request *elb.ModifyLoadBalancerAttributesInput) (*elb.ModifyLoadBalancerAttributesOutput, error) {
m.mutex.Lock()
defer m.mutex.Unlock()
glog.Infof("ModifyLoadBalancerAttributes: %v", request)
lb := m.LoadBalancers[aws.StringValue(request.LoadBalancerName)]
if lb == nil {
return nil, fmt.Errorf("LoadBalancer not found")
}
lb.attributes = *request.LoadBalancerAttributes
copy := lb.attributes
return &elb.ModifyLoadBalancerAttributesOutput{
LoadBalancerName: request.LoadBalancerName,
LoadBalancerAttributes: &copy,
}, nil
}
func (m *MockELB) DescribeLoadBalancerAttributes(request *elb.DescribeLoadBalancerAttributesInput) (*elb.DescribeLoadBalancerAttributesOutput, error) {
m.mutex.Lock()
defer m.mutex.Unlock()
glog.Infof("DescribeLoadBalancerAttributes: %v", request)
lb := m.LoadBalancers[aws.StringValue(request.LoadBalancerName)]
if lb == nil {
return nil, fmt.Errorf("LoadBalancer not found")
}
copy := lb.attributes
return &elb.DescribeLoadBalancerAttributesOutput{
LoadBalancerAttributes: &copy,
}, nil
}

View File

@ -0,0 +1,45 @@
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package mockelb
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/elb"
"github.com/golang/glog"
)
func (m *MockELB) ConfigureHealthCheck(request *elb.ConfigureHealthCheckInput) (*elb.ConfigureHealthCheckOutput, error) {
m.mutex.Lock()
defer m.mutex.Unlock()
glog.Infof("ConfigureHealthCheck: %v", request)
lb := m.LoadBalancers[aws.StringValue(request.LoadBalancerName)]
if lb == nil {
return nil, fmt.Errorf("LoadBalancer not found")
}
lb.description.HealthCheck = request.HealthCheck
copy := *lb.description.HealthCheck
return &elb.ConfigureHealthCheckOutput{
HealthCheck: &copy,
}, nil
}

View File

@ -0,0 +1,87 @@
/*
Copyright 2018 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package mockelb
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/elb"
"github.com/golang/glog"
)
func (m *MockELB) DescribeTags(request *elb.DescribeTagsInput) (*elb.DescribeTagsOutput, error) {
m.mutex.Lock()
defer m.mutex.Unlock()
glog.Infof("DescribeTags %v", request)
var tags []*elb.TagDescription
for k, lb := range m.LoadBalancers {
match := false
if len(request.LoadBalancerNames) == 0 {
match = true
} else {
for _, name := range request.LoadBalancerNames {
if *name == k {
match = true
}
}
}
if !match {
continue
}
tagDescription := &elb.TagDescription{
LoadBalancerName: aws.String(k),
}
for k, v := range lb.tags {
tagDescription.Tags = append(tagDescription.Tags, &elb.Tag{
Key: aws.String(k),
Value: aws.String(v),
})
}
tags = append(tags, tagDescription)
}
response := &elb.DescribeTagsOutput{
TagDescriptions: tags,
}
return response, nil
}
func (m *MockELB) AddTags(request *elb.AddTagsInput) (*elb.AddTagsOutput, error) {
m.mutex.Lock()
defer m.mutex.Unlock()
glog.Infof("AddTags %v", request)
for _, name := range request.LoadBalancerNames {
elb := m.LoadBalancers[*name]
if elb == nil {
return nil, fmt.Errorf("ELB %q not found", *name)
}
for _, tag := range request.Tags {
elb.tags[*tag.Key] = *tag.Value
}
}
return &elb.AddTagsOutput{}, nil
}

View File

@ -55,6 +55,14 @@ func TestLifecycleMinimal(t *testing.T) {
})
}
// TestLifecyclePrivateCalico runs the test on a private topology
func TestLifecyclePrivateCalico(t *testing.T) {
runLifecycleTestAWS(&LifecycleTestOptions{
t: t,
SrcDir: "privatecalico",
})
}
func runLifecycleTest(h *testutils.IntegrationTestHarness, o *LifecycleTestOptions) {
t := o.t

View File

@ -143,7 +143,7 @@ func (e *LaunchConfiguration) Find(c *fi.Context) (*LaunchConfiguration, error)
actual.RootVolumeIops = b.Ebs.Iops
}
userData, err := base64.StdEncoding.DecodeString(*lc.UserData)
userData, err := base64.StdEncoding.DecodeString(aws.StringValue(lc.UserData))
if err != nil {
return nil, fmt.Errorf("error decoding UserData: %v", err)
}

View File

@ -737,6 +737,10 @@ func addAWSTags(c AWSCloud, id string, expected map[string]string) error {
}
func (c *awsCloudImplementation) GetELBTags(loadBalancerName string) (map[string]string, error) {
return getELBTags(c, loadBalancerName)
}
func getELBTags(c AWSCloud, loadBalancerName string) (map[string]string, error) {
tags := map[string]string{}
request := &elb.DescribeTagsInput{
@ -764,6 +768,10 @@ func (c *awsCloudImplementation) GetELBTags(loadBalancerName string) (map[string
// CreateELBTags will add tags to the specified loadBalancer, retrying up to MaxCreateTagsAttempts times if it hits an eventual-consistency type error
func (c *awsCloudImplementation) CreateELBTags(loadBalancerName string, tags map[string]string) error {
return createELBTags(c, loadBalancerName, tags)
}
func createELBTags(c AWSCloud, loadBalancerName string, tags map[string]string) error {
if len(tags) == 0 {
return nil
}

View File

@ -151,11 +151,11 @@ func (c *MockAWSCloud) GetTags(resourceID string) (map[string]string, error) {
}
func (c *MockAWSCloud) GetELBTags(loadBalancerName string) (map[string]string, error) {
return nil, fmt.Errorf("MockAWSCloud GetELBTags not implemented")
return getELBTags(c, loadBalancerName)
}
func (c *MockAWSCloud) CreateELBTags(loadBalancerName string, tags map[string]string) error {
return fmt.Errorf("MockAWSCloud CreateELBTags not implemented")
return createELBTags(c, loadBalancerName, tags)
}
func (c *MockAWSCloud) DescribeInstance(instanceID string) (*ec2.Instance, error) {