diff --git a/cmd/aws-application-networking-k8s/main.go b/cmd/aws-application-networking-k8s/main.go index 3a8acb73..cf76db11 100644 --- a/cmd/aws-application-networking-k8s/main.go +++ b/cmd/aws-application-networking-k8s/main.go @@ -120,15 +120,15 @@ func main() { "DefaultServiceNetwork", config.DefaultServiceNetwork, "ClusterName", config.ClusterName, "LogLevel", logLevel, - "EnablePrivateVPC", config.EnablePrivateVPC, + "DisableTaggingServiceAPI", config.DisableTaggingServiceAPI, ) cloud, err := aws.NewCloud(log.Named("cloud"), aws.CloudConfig{ - VpcId: config.VpcID, - AccountId: config.AccountID, - Region: config.Region, - ClusterName: config.ClusterName, - PrivateVPC: config.EnablePrivateVPC, + VpcId: config.VpcID, + AccountId: config.AccountID, + Region: config.Region, + ClusterName: config.ClusterName, + TaggingServiceAPIDisabled: config.DisableTaggingServiceAPI, }) if err != nil { setupLog.Fatal("cloud client setup failed: %s", err) diff --git a/pkg/aws/cloud.go b/pkg/aws/cloud.go index afeb725d..b5f6ba80 100644 --- a/pkg/aws/cloud.go +++ b/pkg/aws/cloud.go @@ -4,7 +4,6 @@ import ( "context" "fmt" - "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/request" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/vpclattice" @@ -22,11 +21,11 @@ const ( //go:generate mockgen -destination cloud_mocks.go -package aws github.com/aws/aws-application-networking-k8s/pkg/aws Cloud type CloudConfig struct { - VpcId string - AccountId string - Region string - ClusterName string - PrivateVPC bool + VpcId string + AccountId string + Region string + ClusterName string + TaggingServiceAPIDisabled bool } type Cloud interface { @@ -40,12 +39,6 @@ type Cloud interface { // creates lattice tags with default values populated and merges them with provided tags DefaultTagsMergedWith(services.Tags) services.Tags - // find tags on lattice resources - FindTagsForARNs(ctx context.Context, arns []string) (map[string]services.Tags, error) - - // find lattice target group ARNs using tags - FindTargetGroupARNs(context.Context, services.Tags) ([]string, error) - // check if managedBy tag set for lattice resource IsArnManaged(ctx context.Context, arn string) (bool, error) @@ -79,7 +72,14 @@ func NewCloud(log gwlog.Logger, cfg CloudConfig) (Cloud, error) { }) lattice := services.NewDefaultLattice(sess, cfg.AccountId, cfg.Region) - tagging := services.NewDefaultTagging(sess, cfg.Region) + var tagging services.Tagging + + if cfg.TaggingServiceAPIDisabled { + tagging = services.NewLatticeTagging(sess, cfg.AccountId, cfg.Region, cfg.VpcId) + } else { + tagging = services.NewDefaultTagging(sess, cfg.Region) + } + cl := NewDefaultCloudWithTagging(lattice, tagging, cfg) return cl, nil } @@ -133,55 +133,6 @@ func (c *defaultCloud) DefaultTagsMergedWith(tags services.Tags) services.Tags { return newTags } -func (c *defaultCloud) FindTagsForARNs(ctx context.Context, arns []string) (map[string]services.Tags, error) { - if !c.cfg.PrivateVPC { - return c.tagging.GetTagsForArns(ctx, arns) - } - - tagsForARNs := map[string]services.Tags{} - - for _, arn := range arns { - tags, err := c.lattice.ListTagsForResourceWithContext(ctx, - &vpclattice.ListTagsForResourceInput{ResourceArn: aws.String(arn)}, - ) - if err != nil { - return nil, err - } - tagsForARNs[arn] = tags.Tags - } - return tagsForARNs, nil -} - -func (c *defaultCloud) FindTargetGroupARNs(ctx context.Context, tags services.Tags) ([]string, error) { - if !c.cfg.PrivateVPC { - return c.tagging.FindResourcesByTags(ctx, services.ResourceTypeTargetGroup, tags) - } - - tgs, err := c.lattice.ListTargetGroupsAsList(ctx, &vpclattice.ListTargetGroupsInput{ - VpcIdentifier: aws.String(c.cfg.VpcId), - }) - if err != nil { - return nil, err - } - - arns := make([]string, 0, len(tgs)) - - for _, tg := range tgs { - resp, err := c.lattice.ListTagsForResourceWithContext(ctx, - &vpclattice.ListTagsForResourceInput{ResourceArn: tg.Arn}, - ) - if err != nil { - return nil, err - } - - if containsTags(tags, resp.Tags) { - arns = append(arns, aws.StringValue(tg.Arn)) - } - } - - return arns, nil -} - func (c *defaultCloud) getTags(ctx context.Context, arn string) (services.Tags, error) { tagsReq := &vpclattice.ListTagsForResourceInput{ResourceArn: &arn} resp, err := c.lattice.ListTagsForResourceWithContext(ctx, tagsReq) @@ -229,15 +180,6 @@ func (c *defaultCloud) TryOwnFromTags(ctx context.Context, arn string, tags serv return c.isOwner(managedBy), nil } -func containsTags(source, check services.Tags) bool { - for k, v := range source { - if aws.StringValue(check[k]) != aws.StringValue(v) { - return false - } - } - return true -} - func (c *defaultCloud) ownResource(ctx context.Context, arn string) error { _, err := c.Lattice().TagResourceWithContext(ctx, &vpclattice.TagResourceInput{ ResourceArn: &arn, diff --git a/pkg/aws/cloud_mocks.go b/pkg/aws/cloud_mocks.go index 6249ea62..bd8fe67b 100644 --- a/pkg/aws/cloud_mocks.go +++ b/pkg/aws/cloud_mocks.go @@ -77,36 +77,6 @@ func (mr *MockCloudMockRecorder) DefaultTagsMergedWith(arg0 interface{}) *gomock return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DefaultTagsMergedWith", reflect.TypeOf((*MockCloud)(nil).DefaultTagsMergedWith), arg0) } -// FindTagsForARNs mocks base method. -func (m *MockCloud) FindTagsForARNs(arg0 context.Context, arg1 []string) (map[string]map[string]*string, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FindTagsForARNs", arg0, arg1) - ret0, _ := ret[0].(map[string]map[string]*string) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// FindTagsForARNs indicates an expected call of FindTagsForARNs. -func (mr *MockCloudMockRecorder) FindTagsForARNs(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindTagsForARNs", reflect.TypeOf((*MockCloud)(nil).FindTagsForARNs), arg0, arg1) -} - -// FindTargetGroupARNs mocks base method. -func (m *MockCloud) FindTargetGroupARNs(arg0 context.Context, arg1 map[string]*string) ([]string, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "FindTargetGroupARNs", arg0, arg1) - ret0, _ := ret[0].([]string) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// FindTargetGroupARNs indicates an expected call of FindTargetGroupARNs. -func (mr *MockCloudMockRecorder) FindTargetGroupARNs(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindTargetGroupARNs", reflect.TypeOf((*MockCloud)(nil).FindTargetGroupARNs), arg0, arg1) -} - // IsArnManaged mocks base method. func (m *MockCloud) IsArnManaged(arg0 context.Context, arg1 string) (bool, error) { m.ctrl.T.Helper() diff --git a/pkg/aws/services/tagging.go b/pkg/aws/services/tagging.go index a3266a46..e35078a6 100644 --- a/pkg/aws/services/tagging.go +++ b/pkg/aws/services/tagging.go @@ -2,11 +2,14 @@ package services import ( "context" + "fmt" + "github.com/aws/aws-application-networking-k8s/pkg/utils" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" taggingapi "github.com/aws/aws-sdk-go/service/resourcegroupstaggingapi" taggingapiiface "github.com/aws/aws-sdk-go/service/resourcegroupstaggingapi/resourcegroupstaggingapiiface" + "github.com/aws/aws-sdk-go/service/vpclattice" ) //go:generate mockgen -destination tagging_mocks.go -package services github.com/aws/aws-application-networking-k8s/pkg/aws/services Tagging @@ -26,8 +29,6 @@ const ( type Tags = map[string]*string type Tagging interface { - taggingapiiface.ResourceGroupsTaggingAPIAPI - // Receives a list of arns and returns arn-to-tags map. GetTagsForArns(ctx context.Context, arns []string) (map[string]Tags, error) @@ -39,6 +40,11 @@ type defaultTagging struct { taggingapiiface.ResourceGroupsTaggingAPIAPI } +type latticeTagging struct { + Lattice + vpcId string +} + func (t *defaultTagging) GetTagsForArns(ctx context.Context, arns []string) (map[string]Tags, error) { chunks := utils.Chunks(utils.SliceMap(arns, aws.String), maxArnsPerGetResourcesApi) result := make(map[string]Tags) @@ -80,6 +86,66 @@ func NewDefaultTagging(sess *session.Session, region string) *defaultTagging { return &defaultTagging{ResourceGroupsTaggingAPIAPI: api} } +// Use VPC Lattice API instead of the Resource Groups Tagging API +func NewLatticeTagging(sess *session.Session, acc string, region string, vpcId string) *latticeTagging { + api := NewDefaultLattice(sess, acc, region) + return &latticeTagging{Lattice: api, vpcId: vpcId} +} + +func (t *latticeTagging) GetTagsForArns(ctx context.Context, arns []string) (map[string]Tags, error) { + result := map[string]Tags{} + + for _, arn := range arns { + tags, err := t.ListTagsForResourceWithContext(ctx, + &vpclattice.ListTagsForResourceInput{ResourceArn: aws.String(arn)}, + ) + if err != nil { + return nil, err + } + result[arn] = tags.Tags + } + return result, nil +} + +func (t *latticeTagging) FindResourcesByTags(ctx context.Context, resourceType ResourceType, tags Tags) ([]string, error) { + if resourceType != ResourceTypeTargetGroup { + return nil, fmt.Errorf("unsupported resource type %q for FindResourcesByTags", resourceType) + } + + tgs, err := t.ListTargetGroupsAsList(ctx, &vpclattice.ListTargetGroupsInput{ + VpcIdentifier: aws.String(t.vpcId), + }) + if err != nil { + return nil, err + } + + arns := make([]string, 0, len(tgs)) + + for _, tg := range tgs { + resp, err := t.ListTagsForResourceWithContext(ctx, + &vpclattice.ListTagsForResourceInput{ResourceArn: tg.Arn}, + ) + if err != nil { + return nil, err + } + + if containsTags(tags, resp.Tags) { + arns = append(arns, aws.StringValue(tg.Arn)) + } + } + + return arns, nil +} + +func containsTags(source, check Tags) bool { + for k, v := range source { + if aws.StringValue(check[k]) != aws.StringValue(v) { + return false + } + } + return true +} + func convertTags(tags []*taggingapi.Tag) Tags { out := make(Tags) for _, tag := range tags { diff --git a/pkg/aws/services/tagging_mocks.go b/pkg/aws/services/tagging_mocks.go index 6f0d22ec..0e85d2e3 100644 --- a/pkg/aws/services/tagging_mocks.go +++ b/pkg/aws/services/tagging_mocks.go @@ -8,8 +8,6 @@ import ( context "context" reflect "reflect" - request "github.com/aws/aws-sdk-go/aws/request" - resourcegroupstaggingapi "github.com/aws/aws-sdk-go/service/resourcegroupstaggingapi" gomock "github.com/golang/mock/gomock" ) @@ -36,56 +34,6 @@ func (m *MockTagging) EXPECT() *MockTaggingMockRecorder { return m.recorder } -// DescribeReportCreation mocks base method. -func (m *MockTagging) DescribeReportCreation(arg0 *resourcegroupstaggingapi.DescribeReportCreationInput) (*resourcegroupstaggingapi.DescribeReportCreationOutput, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DescribeReportCreation", arg0) - ret0, _ := ret[0].(*resourcegroupstaggingapi.DescribeReportCreationOutput) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// DescribeReportCreation indicates an expected call of DescribeReportCreation. -func (mr *MockTaggingMockRecorder) DescribeReportCreation(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DescribeReportCreation", reflect.TypeOf((*MockTagging)(nil).DescribeReportCreation), arg0) -} - -// DescribeReportCreationRequest mocks base method. -func (m *MockTagging) DescribeReportCreationRequest(arg0 *resourcegroupstaggingapi.DescribeReportCreationInput) (*request.Request, *resourcegroupstaggingapi.DescribeReportCreationOutput) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "DescribeReportCreationRequest", arg0) - ret0, _ := ret[0].(*request.Request) - ret1, _ := ret[1].(*resourcegroupstaggingapi.DescribeReportCreationOutput) - return ret0, ret1 -} - -// DescribeReportCreationRequest indicates an expected call of DescribeReportCreationRequest. -func (mr *MockTaggingMockRecorder) DescribeReportCreationRequest(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DescribeReportCreationRequest", reflect.TypeOf((*MockTagging)(nil).DescribeReportCreationRequest), arg0) -} - -// DescribeReportCreationWithContext mocks base method. -func (m *MockTagging) DescribeReportCreationWithContext(arg0 context.Context, arg1 *resourcegroupstaggingapi.DescribeReportCreationInput, arg2 ...request.Option) (*resourcegroupstaggingapi.DescribeReportCreationOutput, error) { - m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} - for _, a := range arg2 { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "DescribeReportCreationWithContext", varargs...) - ret0, _ := ret[0].(*resourcegroupstaggingapi.DescribeReportCreationOutput) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// DescribeReportCreationWithContext indicates an expected call of DescribeReportCreationWithContext. -func (mr *MockTaggingMockRecorder) DescribeReportCreationWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DescribeReportCreationWithContext", reflect.TypeOf((*MockTagging)(nil).DescribeReportCreationWithContext), varargs...) -} - // FindResourcesByTags mocks base method. func (m *MockTagging) FindResourcesByTags(arg0 context.Context, arg1 ResourceType, arg2 map[string]*string) ([]string, error) { m.ctrl.T.Helper() @@ -101,338 +49,6 @@ func (mr *MockTaggingMockRecorder) FindResourcesByTags(arg0, arg1, arg2 interfac return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindResourcesByTags", reflect.TypeOf((*MockTagging)(nil).FindResourcesByTags), arg0, arg1, arg2) } -// GetComplianceSummary mocks base method. -func (m *MockTagging) GetComplianceSummary(arg0 *resourcegroupstaggingapi.GetComplianceSummaryInput) (*resourcegroupstaggingapi.GetComplianceSummaryOutput, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetComplianceSummary", arg0) - ret0, _ := ret[0].(*resourcegroupstaggingapi.GetComplianceSummaryOutput) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetComplianceSummary indicates an expected call of GetComplianceSummary. -func (mr *MockTaggingMockRecorder) GetComplianceSummary(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetComplianceSummary", reflect.TypeOf((*MockTagging)(nil).GetComplianceSummary), arg0) -} - -// GetComplianceSummaryPages mocks base method. -func (m *MockTagging) GetComplianceSummaryPages(arg0 *resourcegroupstaggingapi.GetComplianceSummaryInput, arg1 func(*resourcegroupstaggingapi.GetComplianceSummaryOutput, bool) bool) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetComplianceSummaryPages", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// GetComplianceSummaryPages indicates an expected call of GetComplianceSummaryPages. -func (mr *MockTaggingMockRecorder) GetComplianceSummaryPages(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetComplianceSummaryPages", reflect.TypeOf((*MockTagging)(nil).GetComplianceSummaryPages), arg0, arg1) -} - -// GetComplianceSummaryPagesWithContext mocks base method. -func (m *MockTagging) GetComplianceSummaryPagesWithContext(arg0 context.Context, arg1 *resourcegroupstaggingapi.GetComplianceSummaryInput, arg2 func(*resourcegroupstaggingapi.GetComplianceSummaryOutput, bool) bool, arg3 ...request.Option) error { - m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1, arg2} - for _, a := range arg3 { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "GetComplianceSummaryPagesWithContext", varargs...) - ret0, _ := ret[0].(error) - return ret0 -} - -// GetComplianceSummaryPagesWithContext indicates an expected call of GetComplianceSummaryPagesWithContext. -func (mr *MockTaggingMockRecorder) GetComplianceSummaryPagesWithContext(arg0, arg1, arg2 interface{}, arg3 ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1, arg2}, arg3...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetComplianceSummaryPagesWithContext", reflect.TypeOf((*MockTagging)(nil).GetComplianceSummaryPagesWithContext), varargs...) -} - -// GetComplianceSummaryRequest mocks base method. -func (m *MockTagging) GetComplianceSummaryRequest(arg0 *resourcegroupstaggingapi.GetComplianceSummaryInput) (*request.Request, *resourcegroupstaggingapi.GetComplianceSummaryOutput) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetComplianceSummaryRequest", arg0) - ret0, _ := ret[0].(*request.Request) - ret1, _ := ret[1].(*resourcegroupstaggingapi.GetComplianceSummaryOutput) - return ret0, ret1 -} - -// GetComplianceSummaryRequest indicates an expected call of GetComplianceSummaryRequest. -func (mr *MockTaggingMockRecorder) GetComplianceSummaryRequest(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetComplianceSummaryRequest", reflect.TypeOf((*MockTagging)(nil).GetComplianceSummaryRequest), arg0) -} - -// GetComplianceSummaryWithContext mocks base method. -func (m *MockTagging) GetComplianceSummaryWithContext(arg0 context.Context, arg1 *resourcegroupstaggingapi.GetComplianceSummaryInput, arg2 ...request.Option) (*resourcegroupstaggingapi.GetComplianceSummaryOutput, error) { - m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} - for _, a := range arg2 { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "GetComplianceSummaryWithContext", varargs...) - ret0, _ := ret[0].(*resourcegroupstaggingapi.GetComplianceSummaryOutput) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetComplianceSummaryWithContext indicates an expected call of GetComplianceSummaryWithContext. -func (mr *MockTaggingMockRecorder) GetComplianceSummaryWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetComplianceSummaryWithContext", reflect.TypeOf((*MockTagging)(nil).GetComplianceSummaryWithContext), varargs...) -} - -// GetResources mocks base method. -func (m *MockTagging) GetResources(arg0 *resourcegroupstaggingapi.GetResourcesInput) (*resourcegroupstaggingapi.GetResourcesOutput, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetResources", arg0) - ret0, _ := ret[0].(*resourcegroupstaggingapi.GetResourcesOutput) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetResources indicates an expected call of GetResources. -func (mr *MockTaggingMockRecorder) GetResources(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetResources", reflect.TypeOf((*MockTagging)(nil).GetResources), arg0) -} - -// GetResourcesPages mocks base method. -func (m *MockTagging) GetResourcesPages(arg0 *resourcegroupstaggingapi.GetResourcesInput, arg1 func(*resourcegroupstaggingapi.GetResourcesOutput, bool) bool) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetResourcesPages", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// GetResourcesPages indicates an expected call of GetResourcesPages. -func (mr *MockTaggingMockRecorder) GetResourcesPages(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetResourcesPages", reflect.TypeOf((*MockTagging)(nil).GetResourcesPages), arg0, arg1) -} - -// GetResourcesPagesWithContext mocks base method. -func (m *MockTagging) GetResourcesPagesWithContext(arg0 context.Context, arg1 *resourcegroupstaggingapi.GetResourcesInput, arg2 func(*resourcegroupstaggingapi.GetResourcesOutput, bool) bool, arg3 ...request.Option) error { - m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1, arg2} - for _, a := range arg3 { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "GetResourcesPagesWithContext", varargs...) - ret0, _ := ret[0].(error) - return ret0 -} - -// GetResourcesPagesWithContext indicates an expected call of GetResourcesPagesWithContext. -func (mr *MockTaggingMockRecorder) GetResourcesPagesWithContext(arg0, arg1, arg2 interface{}, arg3 ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1, arg2}, arg3...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetResourcesPagesWithContext", reflect.TypeOf((*MockTagging)(nil).GetResourcesPagesWithContext), varargs...) -} - -// GetResourcesRequest mocks base method. -func (m *MockTagging) GetResourcesRequest(arg0 *resourcegroupstaggingapi.GetResourcesInput) (*request.Request, *resourcegroupstaggingapi.GetResourcesOutput) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetResourcesRequest", arg0) - ret0, _ := ret[0].(*request.Request) - ret1, _ := ret[1].(*resourcegroupstaggingapi.GetResourcesOutput) - return ret0, ret1 -} - -// GetResourcesRequest indicates an expected call of GetResourcesRequest. -func (mr *MockTaggingMockRecorder) GetResourcesRequest(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetResourcesRequest", reflect.TypeOf((*MockTagging)(nil).GetResourcesRequest), arg0) -} - -// GetResourcesWithContext mocks base method. -func (m *MockTagging) GetResourcesWithContext(arg0 context.Context, arg1 *resourcegroupstaggingapi.GetResourcesInput, arg2 ...request.Option) (*resourcegroupstaggingapi.GetResourcesOutput, error) { - m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} - for _, a := range arg2 { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "GetResourcesWithContext", varargs...) - ret0, _ := ret[0].(*resourcegroupstaggingapi.GetResourcesOutput) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetResourcesWithContext indicates an expected call of GetResourcesWithContext. -func (mr *MockTaggingMockRecorder) GetResourcesWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetResourcesWithContext", reflect.TypeOf((*MockTagging)(nil).GetResourcesWithContext), varargs...) -} - -// GetTagKeys mocks base method. -func (m *MockTagging) GetTagKeys(arg0 *resourcegroupstaggingapi.GetTagKeysInput) (*resourcegroupstaggingapi.GetTagKeysOutput, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTagKeys", arg0) - ret0, _ := ret[0].(*resourcegroupstaggingapi.GetTagKeysOutput) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetTagKeys indicates an expected call of GetTagKeys. -func (mr *MockTaggingMockRecorder) GetTagKeys(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTagKeys", reflect.TypeOf((*MockTagging)(nil).GetTagKeys), arg0) -} - -// GetTagKeysPages mocks base method. -func (m *MockTagging) GetTagKeysPages(arg0 *resourcegroupstaggingapi.GetTagKeysInput, arg1 func(*resourcegroupstaggingapi.GetTagKeysOutput, bool) bool) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTagKeysPages", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// GetTagKeysPages indicates an expected call of GetTagKeysPages. -func (mr *MockTaggingMockRecorder) GetTagKeysPages(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTagKeysPages", reflect.TypeOf((*MockTagging)(nil).GetTagKeysPages), arg0, arg1) -} - -// GetTagKeysPagesWithContext mocks base method. -func (m *MockTagging) GetTagKeysPagesWithContext(arg0 context.Context, arg1 *resourcegroupstaggingapi.GetTagKeysInput, arg2 func(*resourcegroupstaggingapi.GetTagKeysOutput, bool) bool, arg3 ...request.Option) error { - m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1, arg2} - for _, a := range arg3 { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "GetTagKeysPagesWithContext", varargs...) - ret0, _ := ret[0].(error) - return ret0 -} - -// GetTagKeysPagesWithContext indicates an expected call of GetTagKeysPagesWithContext. -func (mr *MockTaggingMockRecorder) GetTagKeysPagesWithContext(arg0, arg1, arg2 interface{}, arg3 ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1, arg2}, arg3...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTagKeysPagesWithContext", reflect.TypeOf((*MockTagging)(nil).GetTagKeysPagesWithContext), varargs...) -} - -// GetTagKeysRequest mocks base method. -func (m *MockTagging) GetTagKeysRequest(arg0 *resourcegroupstaggingapi.GetTagKeysInput) (*request.Request, *resourcegroupstaggingapi.GetTagKeysOutput) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTagKeysRequest", arg0) - ret0, _ := ret[0].(*request.Request) - ret1, _ := ret[1].(*resourcegroupstaggingapi.GetTagKeysOutput) - return ret0, ret1 -} - -// GetTagKeysRequest indicates an expected call of GetTagKeysRequest. -func (mr *MockTaggingMockRecorder) GetTagKeysRequest(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTagKeysRequest", reflect.TypeOf((*MockTagging)(nil).GetTagKeysRequest), arg0) -} - -// GetTagKeysWithContext mocks base method. -func (m *MockTagging) GetTagKeysWithContext(arg0 context.Context, arg1 *resourcegroupstaggingapi.GetTagKeysInput, arg2 ...request.Option) (*resourcegroupstaggingapi.GetTagKeysOutput, error) { - m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} - for _, a := range arg2 { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "GetTagKeysWithContext", varargs...) - ret0, _ := ret[0].(*resourcegroupstaggingapi.GetTagKeysOutput) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetTagKeysWithContext indicates an expected call of GetTagKeysWithContext. -func (mr *MockTaggingMockRecorder) GetTagKeysWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTagKeysWithContext", reflect.TypeOf((*MockTagging)(nil).GetTagKeysWithContext), varargs...) -} - -// GetTagValues mocks base method. -func (m *MockTagging) GetTagValues(arg0 *resourcegroupstaggingapi.GetTagValuesInput) (*resourcegroupstaggingapi.GetTagValuesOutput, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTagValues", arg0) - ret0, _ := ret[0].(*resourcegroupstaggingapi.GetTagValuesOutput) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetTagValues indicates an expected call of GetTagValues. -func (mr *MockTaggingMockRecorder) GetTagValues(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTagValues", reflect.TypeOf((*MockTagging)(nil).GetTagValues), arg0) -} - -// GetTagValuesPages mocks base method. -func (m *MockTagging) GetTagValuesPages(arg0 *resourcegroupstaggingapi.GetTagValuesInput, arg1 func(*resourcegroupstaggingapi.GetTagValuesOutput, bool) bool) error { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTagValuesPages", arg0, arg1) - ret0, _ := ret[0].(error) - return ret0 -} - -// GetTagValuesPages indicates an expected call of GetTagValuesPages. -func (mr *MockTaggingMockRecorder) GetTagValuesPages(arg0, arg1 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTagValuesPages", reflect.TypeOf((*MockTagging)(nil).GetTagValuesPages), arg0, arg1) -} - -// GetTagValuesPagesWithContext mocks base method. -func (m *MockTagging) GetTagValuesPagesWithContext(arg0 context.Context, arg1 *resourcegroupstaggingapi.GetTagValuesInput, arg2 func(*resourcegroupstaggingapi.GetTagValuesOutput, bool) bool, arg3 ...request.Option) error { - m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1, arg2} - for _, a := range arg3 { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "GetTagValuesPagesWithContext", varargs...) - ret0, _ := ret[0].(error) - return ret0 -} - -// GetTagValuesPagesWithContext indicates an expected call of GetTagValuesPagesWithContext. -func (mr *MockTaggingMockRecorder) GetTagValuesPagesWithContext(arg0, arg1, arg2 interface{}, arg3 ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1, arg2}, arg3...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTagValuesPagesWithContext", reflect.TypeOf((*MockTagging)(nil).GetTagValuesPagesWithContext), varargs...) -} - -// GetTagValuesRequest mocks base method. -func (m *MockTagging) GetTagValuesRequest(arg0 *resourcegroupstaggingapi.GetTagValuesInput) (*request.Request, *resourcegroupstaggingapi.GetTagValuesOutput) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetTagValuesRequest", arg0) - ret0, _ := ret[0].(*request.Request) - ret1, _ := ret[1].(*resourcegroupstaggingapi.GetTagValuesOutput) - return ret0, ret1 -} - -// GetTagValuesRequest indicates an expected call of GetTagValuesRequest. -func (mr *MockTaggingMockRecorder) GetTagValuesRequest(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTagValuesRequest", reflect.TypeOf((*MockTagging)(nil).GetTagValuesRequest), arg0) -} - -// GetTagValuesWithContext mocks base method. -func (m *MockTagging) GetTagValuesWithContext(arg0 context.Context, arg1 *resourcegroupstaggingapi.GetTagValuesInput, arg2 ...request.Option) (*resourcegroupstaggingapi.GetTagValuesOutput, error) { - m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} - for _, a := range arg2 { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "GetTagValuesWithContext", varargs...) - ret0, _ := ret[0].(*resourcegroupstaggingapi.GetTagValuesOutput) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// GetTagValuesWithContext indicates an expected call of GetTagValuesWithContext. -func (mr *MockTaggingMockRecorder) GetTagValuesWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTagValuesWithContext", reflect.TypeOf((*MockTagging)(nil).GetTagValuesWithContext), varargs...) -} - // GetTagsForArns mocks base method. func (m *MockTagging) GetTagsForArns(arg0 context.Context, arg1 []string) (map[string]map[string]*string, error) { m.ctrl.T.Helper() @@ -447,153 +63,3 @@ func (mr *MockTaggingMockRecorder) GetTagsForArns(arg0, arg1 interface{}) *gomoc mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTagsForArns", reflect.TypeOf((*MockTagging)(nil).GetTagsForArns), arg0, arg1) } - -// StartReportCreation mocks base method. -func (m *MockTagging) StartReportCreation(arg0 *resourcegroupstaggingapi.StartReportCreationInput) (*resourcegroupstaggingapi.StartReportCreationOutput, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StartReportCreation", arg0) - ret0, _ := ret[0].(*resourcegroupstaggingapi.StartReportCreationOutput) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StartReportCreation indicates an expected call of StartReportCreation. -func (mr *MockTaggingMockRecorder) StartReportCreation(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartReportCreation", reflect.TypeOf((*MockTagging)(nil).StartReportCreation), arg0) -} - -// StartReportCreationRequest mocks base method. -func (m *MockTagging) StartReportCreationRequest(arg0 *resourcegroupstaggingapi.StartReportCreationInput) (*request.Request, *resourcegroupstaggingapi.StartReportCreationOutput) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "StartReportCreationRequest", arg0) - ret0, _ := ret[0].(*request.Request) - ret1, _ := ret[1].(*resourcegroupstaggingapi.StartReportCreationOutput) - return ret0, ret1 -} - -// StartReportCreationRequest indicates an expected call of StartReportCreationRequest. -func (mr *MockTaggingMockRecorder) StartReportCreationRequest(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartReportCreationRequest", reflect.TypeOf((*MockTagging)(nil).StartReportCreationRequest), arg0) -} - -// StartReportCreationWithContext mocks base method. -func (m *MockTagging) StartReportCreationWithContext(arg0 context.Context, arg1 *resourcegroupstaggingapi.StartReportCreationInput, arg2 ...request.Option) (*resourcegroupstaggingapi.StartReportCreationOutput, error) { - m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} - for _, a := range arg2 { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "StartReportCreationWithContext", varargs...) - ret0, _ := ret[0].(*resourcegroupstaggingapi.StartReportCreationOutput) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// StartReportCreationWithContext indicates an expected call of StartReportCreationWithContext. -func (mr *MockTaggingMockRecorder) StartReportCreationWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StartReportCreationWithContext", reflect.TypeOf((*MockTagging)(nil).StartReportCreationWithContext), varargs...) -} - -// TagResources mocks base method. -func (m *MockTagging) TagResources(arg0 *resourcegroupstaggingapi.TagResourcesInput) (*resourcegroupstaggingapi.TagResourcesOutput, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "TagResources", arg0) - ret0, _ := ret[0].(*resourcegroupstaggingapi.TagResourcesOutput) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// TagResources indicates an expected call of TagResources. -func (mr *MockTaggingMockRecorder) TagResources(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TagResources", reflect.TypeOf((*MockTagging)(nil).TagResources), arg0) -} - -// TagResourcesRequest mocks base method. -func (m *MockTagging) TagResourcesRequest(arg0 *resourcegroupstaggingapi.TagResourcesInput) (*request.Request, *resourcegroupstaggingapi.TagResourcesOutput) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "TagResourcesRequest", arg0) - ret0, _ := ret[0].(*request.Request) - ret1, _ := ret[1].(*resourcegroupstaggingapi.TagResourcesOutput) - return ret0, ret1 -} - -// TagResourcesRequest indicates an expected call of TagResourcesRequest. -func (mr *MockTaggingMockRecorder) TagResourcesRequest(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TagResourcesRequest", reflect.TypeOf((*MockTagging)(nil).TagResourcesRequest), arg0) -} - -// TagResourcesWithContext mocks base method. -func (m *MockTagging) TagResourcesWithContext(arg0 context.Context, arg1 *resourcegroupstaggingapi.TagResourcesInput, arg2 ...request.Option) (*resourcegroupstaggingapi.TagResourcesOutput, error) { - m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} - for _, a := range arg2 { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "TagResourcesWithContext", varargs...) - ret0, _ := ret[0].(*resourcegroupstaggingapi.TagResourcesOutput) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// TagResourcesWithContext indicates an expected call of TagResourcesWithContext. -func (mr *MockTaggingMockRecorder) TagResourcesWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "TagResourcesWithContext", reflect.TypeOf((*MockTagging)(nil).TagResourcesWithContext), varargs...) -} - -// UntagResources mocks base method. -func (m *MockTagging) UntagResources(arg0 *resourcegroupstaggingapi.UntagResourcesInput) (*resourcegroupstaggingapi.UntagResourcesOutput, error) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "UntagResources", arg0) - ret0, _ := ret[0].(*resourcegroupstaggingapi.UntagResourcesOutput) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// UntagResources indicates an expected call of UntagResources. -func (mr *MockTaggingMockRecorder) UntagResources(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UntagResources", reflect.TypeOf((*MockTagging)(nil).UntagResources), arg0) -} - -// UntagResourcesRequest mocks base method. -func (m *MockTagging) UntagResourcesRequest(arg0 *resourcegroupstaggingapi.UntagResourcesInput) (*request.Request, *resourcegroupstaggingapi.UntagResourcesOutput) { - m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "UntagResourcesRequest", arg0) - ret0, _ := ret[0].(*request.Request) - ret1, _ := ret[1].(*resourcegroupstaggingapi.UntagResourcesOutput) - return ret0, ret1 -} - -// UntagResourcesRequest indicates an expected call of UntagResourcesRequest. -func (mr *MockTaggingMockRecorder) UntagResourcesRequest(arg0 interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UntagResourcesRequest", reflect.TypeOf((*MockTagging)(nil).UntagResourcesRequest), arg0) -} - -// UntagResourcesWithContext mocks base method. -func (m *MockTagging) UntagResourcesWithContext(arg0 context.Context, arg1 *resourcegroupstaggingapi.UntagResourcesInput, arg2 ...request.Option) (*resourcegroupstaggingapi.UntagResourcesOutput, error) { - m.ctrl.T.Helper() - varargs := []interface{}{arg0, arg1} - for _, a := range arg2 { - varargs = append(varargs, a) - } - ret := m.ctrl.Call(m, "UntagResourcesWithContext", varargs...) - ret0, _ := ret[0].(*resourcegroupstaggingapi.UntagResourcesOutput) - ret1, _ := ret[1].(error) - return ret0, ret1 -} - -// UntagResourcesWithContext indicates an expected call of UntagResourcesWithContext. -func (mr *MockTaggingMockRecorder) UntagResourcesWithContext(arg0, arg1 interface{}, arg2 ...interface{}) *gomock.Call { - mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{arg0, arg1}, arg2...) - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UntagResourcesWithContext", reflect.TypeOf((*MockTagging)(nil).UntagResourcesWithContext), varargs...) -} diff --git a/pkg/config/controller_config.go b/pkg/config/controller_config.go index f5ccdac0..86ad0790 100644 --- a/pkg/config/controller_config.go +++ b/pkg/config/controller_config.go @@ -23,7 +23,7 @@ const ( CLUSTER_VPC_ID = "CLUSTER_VPC_ID" CLUSTER_NAME = "CLUSTER_NAME" DEFAULT_SERVICE_NETWORK = "DEFAULT_SERVICE_NETWORK" - ENABLE_PRIVATE_VPC = "ENABLE_PRIVATE_VPC" + DISABLE_TAGGING_SERVICE_API = "DISABLE_TAGGING_SERVICE_API" ENABLE_SERVICE_NETWORK_OVERRIDE = "ENABLE_SERVICE_NETWORK_OVERRIDE" AWS_ACCOUNT_ID = "AWS_ACCOUNT_ID" DEV_MODE = "DEV_MODE" @@ -38,7 +38,7 @@ var ClusterName = "" var DevMode = "" var WebhookEnabled = "" -var EnablePrivateVPC = false +var DisableTaggingServiceAPI = false var ServiceNetworkOverrideMode = false func ConfigInit() error { @@ -84,10 +84,10 @@ func configInit(sess *session.Session, metadata EC2Metadata) error { ServiceNetworkOverrideMode = true } - privateVPC := os.Getenv(ENABLE_PRIVATE_VPC) + privateVPC := os.Getenv(DISABLE_TAGGING_SERVICE_API) if strings.ToLower(privateVPC) == "true" { - EnablePrivateVPC = true + DisableTaggingServiceAPI = true } ClusterName, err = getClusterName(sess) diff --git a/pkg/controllers/route_controller_test.go b/pkg/controllers/route_controller_test.go index 3dee7975..dcb6a109 100644 --- a/pkg/controllers/route_controller_test.go +++ b/pkg/controllers/route_controller_test.go @@ -2,7 +2,6 @@ package controllers import ( "context" - "testing" mock_client "github.com/aws/aws-application-networking-k8s/mocks/controller-runtime/client" anv1alpha1 "github.com/aws/aws-application-networking-k8s/pkg/apis/applicationnetworking/v1alpha1" @@ -29,6 +28,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/external-dns/endpoint" gwv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1" + "testing" ) func TestRouteReconciler_ReconcileCreates(t *testing.T) { @@ -171,7 +171,6 @@ func TestRouteReconciler_ReconcileCreates(t *testing.T) { }).AnyTimes() mockCloud.EXPECT().DefaultTags().Return(mocks.Tags{}).AnyTimes() mockCloud.EXPECT().DefaultTagsMergedWith(gomock.Any()).Return(mocks.Tags{}).AnyTimes() - mockCloud.EXPECT().FindTargetGroupARNs(ctx, gomock.Any()).Return([]string{}, nil).AnyTimes() // we expect a fair number of lattice calls mockLattice.EXPECT().ListTargetsAsList(ctx, gomock.Any()).Return( @@ -235,6 +234,7 @@ func TestRouteReconciler_ReconcileCreates(t *testing.T) { }, }, nil) // will trigger DNS Update + mockTagging.EXPECT().FindResourcesByTags(ctx, gomock.Any(), gomock.Any()).Return(nil, nil) mockLattice.EXPECT().ListTargetGroupsAsList(ctx, gomock.Any()).Return( []*vpclattice.TargetGroupSummary{}, nil).AnyTimes() // this will cause us to skip "unused delete" step mockLattice.EXPECT().CreateTargetGroupWithContext(ctx, gomock.Any()).Return( diff --git a/pkg/deploy/lattice/target_group_manager.go b/pkg/deploy/lattice/target_group_manager.go index 46319894..0838f594 100644 --- a/pkg/deploy/lattice/target_group_manager.go +++ b/pkg/deploy/lattice/target_group_manager.go @@ -4,7 +4,6 @@ import ( "context" "errors" "fmt" - "reflect" "github.com/aws/aws-application-networking-k8s/pkg/aws/services" "github.com/aws/aws-application-networking-k8s/pkg/utils" @@ -14,6 +13,7 @@ import ( pkg_aws "github.com/aws/aws-application-networking-k8s/pkg/aws" model "github.com/aws/aws-application-networking-k8s/pkg/model/lattice" "github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog" + "reflect" ) //go:generate mockgen -destination target_group_manager_mock.go -package lattice github.com/aws/aws-application-networking-k8s/pkg/deploy/lattice TargetGroupManager @@ -258,7 +258,7 @@ func (s *defaultTargetGroupManager) List(ctx context.Context) ([]tgListOutput, e tgArns := utils.SliceMap(resp, func(tg *vpclattice.TargetGroupSummary) string { return aws.StringValue(tg.Arn) }) - tgArnToTagsMap, err := s.cloud.FindTagsForARNs(ctx, tgArns) + tgArnToTagsMap, err := s.cloud.Tagging().GetTagsForArns(ctx, tgArns) if err != nil { return nil, err @@ -276,7 +276,8 @@ func (s *defaultTargetGroupManager) findTargetGroup( ctx context.Context, modelTargetGroup *model.TargetGroup, ) (*vpclattice.GetTargetGroupOutput, error) { - arns, err := s.cloud.FindTargetGroupARNs(ctx, model.TagsFromTGTagFields(modelTargetGroup.Spec.TargetGroupTagFields)) + arns, err := s.cloud.Tagging().FindResourcesByTags(ctx, services.ResourceTypeTargetGroup, + model.TagsFromTGTagFields(modelTargetGroup.Spec.TargetGroupTagFields)) if err != nil { return nil, err }