diff --git a/test/helper/cloud/aws/vpc.go b/test/helper/cloud/aws/vpc.go index da136d1fd0..0e49785f62 100644 --- a/test/helper/cloud/aws/vpc.go +++ b/test/helper/cloud/aws/vpc.go @@ -16,11 +16,10 @@ package aws import ( "fmt" + taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" - - awshelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper/e2e/api/aws" ) func CreateVPC(name, cidr, region string) (string, error) { @@ -36,9 +35,9 @@ func CreateVPC(name, cidr, region string) (string, error) { ResourceType: aws.String(ec2.ResourceTypeVpc), Tags: []*ec2.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..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/aws.go b/test/helper/e2e/actions/cloud/aws.go index 8d431ffe99..ced32c4a31 100644 --- a/test/helper/e2e/actions/cloud/aws.go +++ b/test/helper/e2e/actions/cloud/aws.go @@ -18,6 +18,7 @@ import ( "encoding/json" "errors" "fmt" + taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" "os" "strings" "time" @@ -31,7 +32,6 @@ import ( "github.com/onsi/ginkgo/v2/dsl/core" "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 { @@ -86,10 +86,10 @@ func (a *AwsAction) CreateKMS(alias, region, atlasAccountArn, assumedRoleArn str Origin: aws.String("AWS_KMS"), Policy: aws.String(policyString), Tags: []*kms.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)}, }, }) @@ -414,10 +414,10 @@ func (a *AwsAction) createVPC(name, cidr, region string) (string, error) { ResourceType: aws.String(ec2.ResourceTypeVpc), Tags: []*ec2.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)}, }, }}, } @@ -496,10 +496,10 @@ func (a *AwsAction) createSubnet(vpcID, name, cidr, region, az string) (*string, ResourceType: aws.String(ec2.ResourceTypeSubnet), Tags: []*ec2.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..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/actions/cloudaccess/aws_roles.go b/test/helper/e2e/actions/cloudaccess/aws_roles.go index 36774862a9..97255de36e 100644 --- a/test/helper/e2e/actions/cloudaccess/aws_roles.go +++ b/test/helper/e2e/actions/cloudaccess/aws_roles.go @@ -16,13 +16,12 @@ package cloudaccess import ( "encoding/json" + taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" "strings" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/iam" - - awshelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper/e2e/api/aws" ) type AssumeRolePolicyDocument struct { @@ -105,10 +104,10 @@ func CreateAWSIAMRole(roleName string) (string, error) { roleInput.SetRoleName(roleName) roleInput.SetAssumeRolePolicyDocument(policy) roleInput.Tags = []*iam.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)}, } //roleInput.SetTags([]*iam.Tag{ // { diff --git a/test/helper/e2e/api/aws/aws_resources_generator.go b/test/helper/e2e/api/aws/aws_resources_generator.go index fe45fb6a26..5bde02609b 100644 --- a/test/helper/e2e/api/aws/aws_resources_generator.go +++ b/test/helper/e2e/api/aws/aws_resources_generator.go @@ -16,6 +16,7 @@ package helper import ( "fmt" + taghelper "github.com/mongodb/mongodb-atlas-kubernetes/v2/test/helper" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" @@ -104,10 +105,10 @@ func (g *AwsResourcesGenerator) CreatePolicy(name string, policy func() IAMPolic PolicyDocument: policy(), PolicyName: aws.String(name), Tags: []*iam.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)}, }, } @@ -185,10 +186,10 @@ func (g *AwsResourcesGenerator) CreateBucket(name string) error { tagSet := &s3.Tagging{ TagSet: []*s3.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..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 } 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