From 6150c90dfbc5c49d45c2eb54efb1f4a123c30bce Mon Sep 17 00:00:00 2001 From: Roo Thorp Date: Fri, 7 Nov 2025 14:02:10 +0000 Subject: [PATCH 1/3] move tags to more generic dir --- test/helper/cloud/aws/vpc.go | 9 +++---- test/helper/e2e/actions/cloud/aws.go | 26 +++++++++---------- .../e2e/actions/cloudaccess/aws_roles.go | 11 ++++---- .../e2e/api/aws/aws_resources_generator.go | 17 ++++++------ test/helper/{e2e/api/aws => }/tags.go | 0 5 files changed, 31 insertions(+), 32 deletions(-) rename test/helper/{e2e/api/aws => }/tags.go (100%) diff --git a/test/helper/cloud/aws/vpc.go b/test/helper/cloud/aws/vpc.go index 2d61b74f88..7ae6d13c83 100644 --- a/test/helper/cloud/aws/vpc.go +++ b/test/helper/cloud/aws/vpc.go @@ -17,13 +17,12 @@ package aws import ( "context" "fmt" + taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/service/ec2" "github.com/aws/aws-sdk-go-v2/service/ec2/types" - - awshelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper/e2e/api/aws" ) func CreateVPC(ctx context.Context, name, cidr, region string) (string, error) { @@ -43,9 +42,9 @@ func CreateVPC(ctx context.Context, name, cidr, region string) (string, error) { ResourceType: types.ResourceTypeVpc, Tags: []types.Tag{ {Key: aws.String("Name"), Value: aws.String(name)}, - {Key: aws.String(awshelper.OwnerEmailTag), Value: aws.String(awshelper.AKOEmail)}, - {Key: aws.String(awshelper.CostCenterTag), Value: aws.String(awshelper.AKOCostCenter)}, - {Key: aws.String(awshelper.EnvironmentTag), Value: aws.String(awshelper.AKOEnvTest)}, + {Key: aws.String(taghelper.OwnerEmailTag), Value: aws.String(taghelper.AKOEmail)}, + {Key: aws.String(taghelper.CostCenterTag), Value: aws.String(taghelper.AKOCostCenter)}, + {Key: aws.String(taghelper.EnvironmentTag), Value: aws.String(taghelper.AKOEnvTest)}, }, }}, }) diff --git a/test/helper/e2e/actions/cloud/aws.go b/test/helper/e2e/actions/cloud/aws.go index de28f20e51..f971e54d64 100644 --- a/test/helper/e2e/actions/cloud/aws.go +++ b/test/helper/e2e/actions/cloud/aws.go @@ -19,6 +19,7 @@ import ( "encoding/json" "errors" "fmt" + taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" "os" "strings" "time" @@ -35,7 +36,6 @@ import ( . "github.com/onsi/gomega" "github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/pointer" - awshelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper/e2e/api/aws" ) type AwsAction struct { @@ -91,10 +91,10 @@ func (a *AwsAction) CreateKMS(ctx context.Context, alias, region, atlasAccountAr Origin: kmstypes.OriginTypeAwsKms, Policy: aws.String(policyString), Tags: []kmstypes.Tag{ - {TagKey: aws.String(awshelper.OwnerTag), TagValue: aws.String(awshelper.AKOTeam)}, - {TagKey: aws.String(awshelper.OwnerEmailTag), TagValue: aws.String(awshelper.AKOEmail)}, - {TagKey: aws.String(awshelper.CostCenterTag), TagValue: aws.String(awshelper.AKOCostCenter)}, - {TagKey: aws.String(awshelper.EnvironmentTag), TagValue: aws.String(awshelper.AKOEnvTest)}, + {TagKey: aws.String(taghelper.OwnerTag), TagValue: aws.String(taghelper.AKOTeam)}, + {TagKey: aws.String(taghelper.OwnerEmailTag), TagValue: aws.String(taghelper.AKOEmail)}, + {TagKey: aws.String(taghelper.CostCenterTag), TagValue: aws.String(taghelper.AKOCostCenter)}, + {TagKey: aws.String(taghelper.EnvironmentTag), TagValue: aws.String(taghelper.AKOEnvTest)}, }, }) @@ -406,10 +406,10 @@ func (a *AwsAction) createVPC(ctx context.Context, name, cidr, region string) (s ResourceType: ec2types.ResourceTypeVpc, Tags: []ec2types.Tag{ {Key: aws.String("Name"), Value: aws.String(name)}, - {Key: aws.String(awshelper.OwnerTag), Value: aws.String(awshelper.AKOTeam)}, - {Key: aws.String(awshelper.OwnerEmailTag), Value: aws.String(awshelper.AKOEmail)}, - {Key: aws.String(awshelper.CostCenterTag), Value: aws.String(awshelper.AKOCostCenter)}, - {Key: aws.String(awshelper.EnvironmentTag), Value: aws.String(awshelper.AKOEnvTest)}, + {Key: aws.String(taghelper.OwnerTag), Value: aws.String(taghelper.AKOTeam)}, + {Key: aws.String(taghelper.OwnerEmailTag), Value: aws.String(taghelper.AKOEmail)}, + {Key: aws.String(taghelper.CostCenterTag), Value: aws.String(taghelper.AKOCostCenter)}, + {Key: aws.String(taghelper.EnvironmentTag), Value: aws.String(taghelper.AKOEnvTest)}, }, }}, } @@ -486,10 +486,10 @@ func (a *AwsAction) createSubnet(ctx context.Context, vpcID, name, cidr, region, ResourceType: ec2types.ResourceTypeSubnet, Tags: []ec2types.Tag{ {Key: aws.String("Name"), Value: aws.String(name)}, - {Key: aws.String(awshelper.OwnerTag), Value: aws.String(awshelper.AKOTeam)}, - {Key: aws.String(awshelper.OwnerEmailTag), Value: aws.String(awshelper.AKOEmail)}, - {Key: aws.String(awshelper.CostCenterTag), Value: aws.String(awshelper.AKOCostCenter)}, - {Key: aws.String(awshelper.EnvironmentTag), Value: aws.String(awshelper.AKOEnvTest)}, + {Key: aws.String(taghelper.OwnerTag), Value: aws.String(taghelper.AKOTeam)}, + {Key: aws.String(taghelper.OwnerEmailTag), Value: aws.String(taghelper.AKOEmail)}, + {Key: aws.String(taghelper.CostCenterTag), Value: aws.String(taghelper.AKOCostCenter)}, + {Key: aws.String(taghelper.EnvironmentTag), Value: aws.String(taghelper.AKOEnvTest)}, }, }}, VpcId: aws.String(vpcID), diff --git a/test/helper/e2e/actions/cloudaccess/aws_roles.go b/test/helper/e2e/actions/cloudaccess/aws_roles.go index 608ebf5766..90387c8135 100644 --- a/test/helper/e2e/actions/cloudaccess/aws_roles.go +++ b/test/helper/e2e/actions/cloudaccess/aws_roles.go @@ -18,14 +18,13 @@ import ( "context" "encoding/json" "fmt" + taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" "strings" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/service/iam" "github.com/aws/aws-sdk-go-v2/service/iam/types" - - awshelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper/e2e/api/aws" ) type AssumeRolePolicyDocument struct { @@ -113,10 +112,10 @@ func CreateAWSIAMRole(ctx context.Context, roleName string) (string, error) { AssumeRolePolicyDocument: &policy, } roleInput.Tags = []types.Tag{ - {Key: aws.String(awshelper.OwnerTag), Value: aws.String(awshelper.AKOTeam)}, - {Key: aws.String(awshelper.OwnerEmailTag), Value: aws.String(awshelper.AKOEmail)}, - {Key: aws.String(awshelper.CostCenterTag), Value: aws.String(awshelper.AKOCostCenter)}, - {Key: aws.String(awshelper.EnvironmentTag), Value: aws.String(awshelper.AKOEnvTest)}, + {Key: aws.String(taghelper.OwnerTag), Value: aws.String(taghelper.AKOTeam)}, + {Key: aws.String(taghelper.OwnerEmailTag), Value: aws.String(taghelper.AKOEmail)}, + {Key: aws.String(taghelper.CostCenterTag), Value: aws.String(taghelper.AKOCostCenter)}, + {Key: aws.String(taghelper.EnvironmentTag), Value: aws.String(taghelper.AKOEnvTest)}, } role, err := IAMClient.CreateRole(ctx, &roleInput) if err != nil { diff --git a/test/helper/e2e/api/aws/aws_resources_generator.go b/test/helper/e2e/api/aws/aws_resources_generator.go index 6de92b3650..0b2179fe5a 100644 --- a/test/helper/e2e/api/aws/aws_resources_generator.go +++ b/test/helper/e2e/api/aws/aws_resources_generator.go @@ -18,6 +18,7 @@ import ( "context" "encoding/json" "fmt" + taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/config" @@ -108,10 +109,10 @@ func (g *AwsResourcesGenerator) CreatePolicy(ctx context.Context, name string, p PolicyDocument: policy(), PolicyName: aws.String(name), Tags: []iamtypes.Tag{ - {Key: aws.String(OwnerTag), Value: aws.String(AKOTeam)}, - {Key: aws.String(OwnerEmailTag), Value: aws.String(AKOEmail)}, - {Key: aws.String(CostCenterTag), Value: aws.String(AKOCostCenter)}, - {Key: aws.String(EnvironmentTag), Value: aws.String(AKOEnvTest)}, + {Key: aws.String(taghelper.OwnerTag), Value: aws.String(taghelper.AKOTeam)}, + {Key: aws.String(taghelper.OwnerEmailTag), Value: aws.String(taghelper.AKOEmail)}, + {Key: aws.String(taghelper.CostCenterTag), Value: aws.String(taghelper.AKOCostCenter)}, + {Key: aws.String(taghelper.EnvironmentTag), Value: aws.String(taghelper.AKOEnvTest)}, }, } @@ -194,10 +195,10 @@ func (g *AwsResourcesGenerator) CreateBucket(ctx context.Context, name string) e tagSet := &s3types.Tagging{ TagSet: []s3types.Tag{ - {Key: aws.String(OwnerTag), Value: aws.String(AKOTeam)}, - {Key: aws.String(OwnerEmailTag), Value: aws.String(AKOEmail)}, - {Key: aws.String(CostCenterTag), Value: aws.String(AKOCostCenter)}, - {Key: aws.String(EnvironmentTag), Value: aws.String(AKOEnvTest)}, + {Key: aws.String(taghelper.OwnerTag), Value: aws.String(taghelper.AKOTeam)}, + {Key: aws.String(taghelper.OwnerEmailTag), Value: aws.String(taghelper.AKOEmail)}, + {Key: aws.String(taghelper.CostCenterTag), Value: aws.String(taghelper.AKOCostCenter)}, + {Key: aws.String(taghelper.EnvironmentTag), Value: aws.String(taghelper.AKOEnvTest)}, }, } diff --git a/test/helper/e2e/api/aws/tags.go b/test/helper/tags.go similarity index 100% rename from test/helper/e2e/api/aws/tags.go rename to test/helper/tags.go From 4c749cf3165d6b7d0c9d6e2db7b1e64d0d81578d Mon Sep 17 00:00:00 2001 From: Roo Thorp Date: Fri, 7 Nov 2025 14:16:33 +0000 Subject: [PATCH 2/3] add tags to azure resource creators --- test/helper/cloud/azure/vpc.go | 6 +++++- test/helper/e2e/actions/cloud/azure.go | 16 +++++++++++++++- test/helper/e2e/api/azure/azure.go | 9 +++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/test/helper/cloud/azure/vpc.go b/test/helper/cloud/azure/vpc.go index c3424a3627..77baca82ad 100644 --- a/test/helper/cloud/azure/vpc.go +++ b/test/helper/cloud/azure/vpc.go @@ -18,6 +18,7 @@ import ( "context" "errors" "fmt" + taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v2" @@ -45,7 +46,10 @@ func CreateVPC(ctx context.Context, vpcName, cidr, region string) (string, error }, }, Tags: map[string]*string{ - "Name": pointer.MakePtr(vpcName), + "Name": pointer.MakePtr(vpcName), + taghelper.OwnerEmailTag: pointer.MakePtr(taghelper.AKOEmail), + taghelper.CostCenterTag: pointer.MakePtr(taghelper.AKOCostCenter), + taghelper.EnvironmentTag: pointer.MakePtr(taghelper.AKOEnvTest), }, }, nil, diff --git a/test/helper/e2e/actions/cloud/azure.go b/test/helper/e2e/actions/cloud/azure.go index 448b03fbe5..9d46f9c3b2 100644 --- a/test/helper/e2e/actions/cloud/azure.go +++ b/test/helper/e2e/actions/cloud/azure.go @@ -18,6 +18,7 @@ import ( "context" "errors" "fmt" + taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" @@ -141,6 +142,11 @@ func (a *AzureAction) CreatePrivateEndpoint(vpcName, subnetName, endpointName, s }, }, }, + Tags: map[string]*string{ + taghelper.OwnerEmailTag: pointer.MakePtr(taghelper.AKOEmail), + taghelper.CostCenterTag: pointer.MakePtr(taghelper.AKOCostCenter), + taghelper.EnvironmentTag: pointer.MakePtr(taghelper.AKOEnvTest), + }, }, nil, ) @@ -246,7 +252,10 @@ func (a *AzureAction) createVpcWithSubnets(ctx context.Context, vpcName, cidr, r Subnets: subnetsSpec, }, Tags: map[string]*string{ - "Name": pointer.MakePtr(vpcName), + "Name": pointer.MakePtr(vpcName), + taghelper.OwnerEmailTag: pointer.MakePtr(taghelper.AKOEmail), + taghelper.CostCenterTag: pointer.MakePtr(taghelper.AKOCostCenter), + taghelper.EnvironmentTag: pointer.MakePtr(taghelper.AKOEnvTest), }, }, nil, @@ -421,6 +430,11 @@ func (a *AzureAction) CreateKeyVault(keyName string) (string, error) { Properties: &armkeyvault.KeyProperties{ Kty: pointer.MakePtr(armkeyvault.JSONWebKeyTypeRSA), }, + Tags: map[string]*string{ + taghelper.OwnerEmailTag: pointer.MakePtr(taghelper.AKOEmail), + taghelper.CostCenterTag: pointer.MakePtr(taghelper.AKOCostCenter), + taghelper.EnvironmentTag: pointer.MakePtr(taghelper.AKOEnvTest), + }, } r, err := a.keyVaultResourceFactory.NewKeysClient().CreateIfNotExist(ctx, a.resourceGroupName, AzureKeyVaultName, keyName, params, nil) diff --git a/test/helper/e2e/api/azure/azure.go b/test/helper/e2e/api/azure/azure.go index 8b26b10893..a44444a3af 100644 --- a/test/helper/e2e/api/azure/azure.go +++ b/test/helper/e2e/api/azure/azure.go @@ -18,6 +18,8 @@ import ( "context" "errors" "fmt" + "github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/pointer" + taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" "path" "time" @@ -63,8 +65,11 @@ func SessionAzure(subscriptionID string, tagNameValue string) (sessionAzure, err SubscriptionID: subscriptionID, Authorizer: authorizer, Tags: map[string]*string{ - "name": to.StringPtr(tagNameValue), - config.TagForTestKey: to.StringPtr(config.TagForTestValue), + "name": to.StringPtr(tagNameValue), + config.TagForTestKey: to.StringPtr(config.TagForTestValue), + taghelper.OwnerEmailTag: pointer.MakePtr(taghelper.AKOEmail), + taghelper.CostCenterTag: pointer.MakePtr(taghelper.AKOCostCenter), + taghelper.EnvironmentTag: pointer.MakePtr(taghelper.AKOEnvTest), }, }, nil } From 01c29b63b5c7045e0047d2d8c9dd5d7e1615790b Mon Sep 17 00:00:00 2001 From: Igor Karpukhin Date: Tue, 11 Nov 2025 09:58:45 +0100 Subject: [PATCH 3/3] Fixed linting errors --- test/helper/cloud/aws/vpc.go | 3 ++- test/helper/cloud/azure/vpc.go | 2 +- test/helper/e2e/actions/cloud/aws.go | 2 +- test/helper/e2e/actions/cloud/azure.go | 2 +- test/helper/e2e/actions/cloudaccess/aws_roles.go | 3 ++- test/helper/e2e/api/aws/aws_resources_generator.go | 3 ++- test/helper/e2e/api/azure/azure.go | 4 ++-- 7 files changed, 11 insertions(+), 8 deletions(-) diff --git a/test/helper/cloud/aws/vpc.go b/test/helper/cloud/aws/vpc.go index 7ae6d13c83..d430fee918 100644 --- a/test/helper/cloud/aws/vpc.go +++ b/test/helper/cloud/aws/vpc.go @@ -17,12 +17,13 @@ package aws import ( "context" "fmt" - taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/service/ec2" "github.com/aws/aws-sdk-go-v2/service/ec2/types" + + taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" ) func CreateVPC(ctx context.Context, name, cidr, region string) (string, error) { diff --git a/test/helper/cloud/azure/vpc.go b/test/helper/cloud/azure/vpc.go index 77baca82ad..79efa8b395 100644 --- a/test/helper/cloud/azure/vpc.go +++ b/test/helper/cloud/azure/vpc.go @@ -18,11 +18,11 @@ import ( "context" "errors" "fmt" - taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/network/armnetwork/v2" "github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/pointer" + taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" ) func CreateVPC(ctx context.Context, vpcName, cidr, region string) (string, error) { diff --git a/test/helper/e2e/actions/cloud/aws.go b/test/helper/e2e/actions/cloud/aws.go index f971e54d64..f132cc5e8e 100644 --- a/test/helper/e2e/actions/cloud/aws.go +++ b/test/helper/e2e/actions/cloud/aws.go @@ -19,7 +19,6 @@ import ( "encoding/json" "errors" "fmt" - taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" "os" "strings" "time" @@ -36,6 +35,7 @@ import ( . "github.com/onsi/gomega" "github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/pointer" + taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" ) type AwsAction struct { diff --git a/test/helper/e2e/actions/cloud/azure.go b/test/helper/e2e/actions/cloud/azure.go index 9d46f9c3b2..36da9e908f 100644 --- a/test/helper/e2e/actions/cloud/azure.go +++ b/test/helper/e2e/actions/cloud/azure.go @@ -18,7 +18,6 @@ import ( "context" "errors" "fmt" - taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" @@ -27,6 +26,7 @@ import ( "github.com/onsi/ginkgo/v2/dsl/core" "github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/pointer" + taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" ) const ( diff --git a/test/helper/e2e/actions/cloudaccess/aws_roles.go b/test/helper/e2e/actions/cloudaccess/aws_roles.go index 90387c8135..f4ee679ae5 100644 --- a/test/helper/e2e/actions/cloudaccess/aws_roles.go +++ b/test/helper/e2e/actions/cloudaccess/aws_roles.go @@ -18,13 +18,14 @@ import ( "context" "encoding/json" "fmt" - taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" "strings" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/service/iam" "github.com/aws/aws-sdk-go-v2/service/iam/types" + + taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" ) type AssumeRolePolicyDocument struct { diff --git a/test/helper/e2e/api/aws/aws_resources_generator.go b/test/helper/e2e/api/aws/aws_resources_generator.go index 0b2179fe5a..7a323c7b5a 100644 --- a/test/helper/e2e/api/aws/aws_resources_generator.go +++ b/test/helper/e2e/api/aws/aws_resources_generator.go @@ -18,7 +18,6 @@ import ( "context" "encoding/json" "fmt" - taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/config" @@ -27,6 +26,8 @@ import ( "github.com/aws/aws-sdk-go-v2/service/s3" s3types "github.com/aws/aws-sdk-go-v2/service/s3/types" "github.com/onsi/ginkgo/v2" + + taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" ) type AwsResourcesGenerator struct { diff --git a/test/helper/e2e/api/azure/azure.go b/test/helper/e2e/api/azure/azure.go index a44444a3af..fe770a94ab 100644 --- a/test/helper/e2e/api/azure/azure.go +++ b/test/helper/e2e/api/azure/azure.go @@ -18,8 +18,6 @@ import ( "context" "errors" "fmt" - "github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/pointer" - taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" "path" "time" @@ -28,6 +26,8 @@ import ( "github.com/Azure/go-autorest/autorest/azure/auth" "github.com/Azure/go-autorest/autorest/to" + "github.com/mongodb/mongodb-atlas-kubernetes/v2/internal/pointer" + taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper/e2e/config" )