diff --git a/test/helper/cloud/aws/vpc.go b/test/helper/cloud/aws/vpc.go index 2d61b74f88..d430fee918 100644 --- a/test/helper/cloud/aws/vpc.go +++ b/test/helper/cloud/aws/vpc.go @@ -23,7 +23,7 @@ import ( "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" + taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" ) func CreateVPC(ctx context.Context, name, cidr, region string) (string, error) { @@ -43,9 +43,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/cloud/azure/vpc.go b/test/helper/cloud/azure/vpc.go index c3424a3627..79efa8b395 100644 --- a/test/helper/cloud/azure/vpc.go +++ b/test/helper/cloud/azure/vpc.go @@ -22,6 +22,7 @@ import ( "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) { @@ -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/aws.go b/test/helper/e2e/actions/cloud/aws.go index de28f20e51..f132cc5e8e 100644 --- a/test/helper/e2e/actions/cloud/aws.go +++ b/test/helper/e2e/actions/cloud/aws.go @@ -35,7 +35,7 @@ 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" + taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" ) 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/cloud/azure.go b/test/helper/e2e/actions/cloud/azure.go index 448b03fbe5..36da9e908f 100644 --- a/test/helper/e2e/actions/cloud/azure.go +++ b/test/helper/e2e/actions/cloud/azure.go @@ -26,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 ( @@ -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/actions/cloudaccess/aws_roles.go b/test/helper/e2e/actions/cloudaccess/aws_roles.go index 608ebf5766..f4ee679ae5 100644 --- a/test/helper/e2e/actions/cloudaccess/aws_roles.go +++ b/test/helper/e2e/actions/cloudaccess/aws_roles.go @@ -25,7 +25,7 @@ import ( "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" + taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" ) type AssumeRolePolicyDocument struct { @@ -113,10 +113,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..7a323c7b5a 100644 --- a/test/helper/e2e/api/aws/aws_resources_generator.go +++ b/test/helper/e2e/api/aws/aws_resources_generator.go @@ -26,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 { @@ -108,10 +110,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 +196,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/azure/azure.go b/test/helper/e2e/api/azure/azure.go index 8b26b10893..fe770a94ab 100644 --- a/test/helper/e2e/api/azure/azure.go +++ b/test/helper/e2e/api/azure/azure.go @@ -26,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" ) @@ -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 } 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