Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 18 additions & 21 deletions lib/integrations/awsoidc/listdatabases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,12 @@ func TestListDatabases(t *testing.T) {
Name: "my-db",
Description: "RDS instance in ",
Labels: map[string]string{
"account-id": "123456789012",
"endpoint-type": "instance",
"engine": "postgres",
"engine-version": "",
"region": "",
"teleport.dev/origin": "cloud",
"status": "available",
"account-id": "123456789012",
"endpoint-type": "instance",
"engine": "postgres",
"engine-version": "",
"region": "",
"status": "available",
},
},
types.DatabaseSpecV3{
Expand Down Expand Up @@ -252,13 +251,12 @@ func TestListDatabases(t *testing.T) {
Name: "my-db",
Description: "RDS instance in ",
Labels: map[string]string{
"account-id": "123456789012",
"endpoint-type": "instance",
"engine": "postgres",
"engine-version": "",
"region": "",
"teleport.dev/origin": "cloud",
"status": "available",
"account-id": "123456789012",
"endpoint-type": "instance",
"engine": "postgres",
"engine-version": "",
"region": "",
"status": "available",
},
},
types.DatabaseSpecV3{
Expand Down Expand Up @@ -303,13 +301,12 @@ func TestListDatabases(t *testing.T) {
Name: "my-dbc",
Description: "Aurora cluster in ",
Labels: map[string]string{
"account-id": "123456789012",
"endpoint-type": "primary",
"engine": "aurora-postgresql",
"engine-version": "",
"region": "",
"teleport.dev/origin": "cloud",
"status": "available",
"account-id": "123456789012",
"endpoint-type": "primary",
"engine": "aurora-postgresql",
"engine-version": "",
"region": "",
"status": "available",
},
},
types.DatabaseSpecV3{
Expand Down
8 changes: 0 additions & 8 deletions lib/services/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,6 @@ func rdsEngineFamilyToProtocol(engineFamily string) (string, error) {
// labelsFromAzureServer creates database labels for the provided Azure DB server.
func labelsFromAzureServer(server *azure.DBServer) (map[string]string, error) {
labels := azureTagsToLabels(server.Tags)
labels[types.OriginLabel] = types.OriginCloud
labels[labelRegion] = server.Location
labels[labelEngineVersion] = server.Properties.Version
return withLabelsFromAzureResourceID(labels, server.ID)
Expand All @@ -1255,7 +1254,6 @@ func withLabelsFromAzureResourceID(labels map[string]string, resourceID string)
// labelsFromAzureRedis creates database labels from the provided Azure Redis instance.
func labelsFromAzureRedis(server *armredis.ResourceInfo) (map[string]string, error) {
labels := azureTagsToLabels(azure.ConvertTags(server.Tags))
labels[types.OriginLabel] = types.OriginCloud
labels[labelRegion] = azure.StringVal(server.Location)
labels[labelEngineVersion] = azure.StringVal(server.Properties.RedisVersion)
return withLabelsFromAzureResourceID(labels, azure.StringVal(server.ID))
Expand All @@ -1264,7 +1262,6 @@ func labelsFromAzureRedis(server *armredis.ResourceInfo) (map[string]string, err
// labelsFromAzureRedisEnterprise creates database labels from the provided Azure Redis Enterprise server.
func labelsFromAzureRedisEnterprise(cluster *armredisenterprise.Cluster, database *armredisenterprise.Database) (map[string]string, error) {
labels := azureTagsToLabels(azure.ConvertTags(cluster.Tags))
labels[types.OriginLabel] = types.OriginCloud
labels[labelRegion] = azure.StringVal(cluster.Location)
labels[labelEngineVersion] = azure.StringVal(cluster.Properties.RedisVersion)
labels[labelEndpointType] = azure.StringVal(database.Properties.ClusteringPolicy)
Expand All @@ -1275,7 +1272,6 @@ func labelsFromAzureRedisEnterprise(cluster *armredisenterprise.Cluster, databas
// server.
func labelsFromAzureSQLServer(server *armsql.Server) (map[string]string, error) {
labels := azureTagsToLabels(azure.ConvertTags(server.Tags))
labels[types.OriginLabel] = types.OriginCloud
labels[labelRegion] = azure.StringVal(server.Location)
labels[labelEngineVersion] = azure.StringVal(server.Properties.Version)
return withLabelsFromAzureResourceID(labels, azure.StringVal(server.ID))
Expand All @@ -1285,15 +1281,13 @@ func labelsFromAzureSQLServer(server *armsql.Server) (map[string]string, error)
// Azure Managed SQL server.
func labelsFromAzureManagedSQLServer(server *armsql.ManagedInstance) (map[string]string, error) {
labels := azureTagsToLabels(azure.ConvertTags(server.Tags))
labels[types.OriginLabel] = types.OriginCloud
labels[labelRegion] = azure.StringVal(server.Location)
return withLabelsFromAzureResourceID(labels, azure.StringVal(server.ID))
}

// labelsFromAzureMySQLFlexServer creates database labels for the provided Azure MySQL flex server.
func labelsFromAzureMySQLFlexServer(server *armmysqlflexibleservers.Server) (map[string]string, error) {
labels := azureTagsToLabels(azure.ConvertTags(server.Tags))
labels[types.OriginLabel] = types.OriginCloud
labels[labelRegion] = azure.StringVal(server.Location)
labels[labelEngineVersion] = azure.StringVal(server.Properties.Version)

Expand All @@ -1318,7 +1312,6 @@ func labelsFromAzureMySQLFlexServer(server *armmysqlflexibleservers.Server) (map
// labelsFromAzurePostgresFlexServer creates database labels for the provided Azure postgres flex server.
func labelsFromAzurePostgresFlexServer(server *armpostgresqlflexibleservers.Server) (map[string]string, error) {
labels := azureTagsToLabels(azure.ConvertTags(server.Tags))
labels[types.OriginLabel] = types.OriginCloud
labels[labelRegion] = azure.StringVal(server.Location)
labels[labelEngineVersion] = azure.StringVal(server.Properties.Version)
return withLabelsFromAzureResourceID(labels, azure.StringVal(server.ID))
Expand Down Expand Up @@ -1389,7 +1382,6 @@ func labelsFromRedshiftServerlessVPCEndpoint(endpoint *redshiftserverless.Endpoi
// labelsFromAWSMetadata returns labels from provided AWS metadata.
func labelsFromAWSMetadata(meta *types.AWS) map[string]string {
labels := make(map[string]string)
labels[types.OriginLabel] = types.OriginCloud
if meta != nil {
labels[labelAccountID] = meta.AccountID
labels[labelRegion] = meta.Region
Expand Down
42 changes: 5 additions & 37 deletions lib/services/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ func TestDatabaseFromAzureDBServer(t *testing.T) {
Name: "testdb",
Description: "Azure MySQL server in eastus",
Labels: map[string]string{
types.OriginLabel: types.OriginCloud,
labelRegion: "eastus",
labelEngine: "Microsoft.DBforMySQL/servers",
labelEngineVersion: "5.7",
Expand Down Expand Up @@ -411,7 +410,6 @@ func TestDatabaseFromAzureRedis(t *testing.T) {
Name: name,
Description: "Azure Redis server in eastus",
Labels: map[string]string{
types.OriginLabel: types.OriginCloud,
labelRegion: region,
labelEngine: "Microsoft.Cache/Redis",
labelEngineVersion: "6.0",
Expand Down Expand Up @@ -469,7 +467,6 @@ func TestDatabaseFromAzureRedisEnterprise(t *testing.T) {
Name: name,
Description: "Azure Redis Enterprise server in eastus",
Labels: map[string]string{
types.OriginLabel: types.OriginCloud,
labelRegion: region,
labelEngine: "Microsoft.Cache/redisEnterprise",
labelEngineVersion: "6.0",
Expand Down Expand Up @@ -519,7 +516,6 @@ func TestDatabaseFromRDSInstance(t *testing.T) {
Name: "instance-1",
Description: "RDS instance in us-west-1",
Labels: map[string]string{
types.OriginLabel: types.OriginCloud,
labelAccountID: "123456789012",
labelRegion: "us-west-1",
labelEngine: RDSEnginePostgres,
Expand Down Expand Up @@ -571,7 +567,6 @@ func TestDatabaseFromRDSV2Instance(t *testing.T) {
Name: "instance-1",
Description: "RDS instance in us-west-1",
Labels: map[string]string{
types.OriginLabel: types.OriginCloud,
labelAccountID: "123456789012",
labelRegion: "us-west-1",
labelEngine: RDSEnginePostgres,
Expand Down Expand Up @@ -639,7 +634,6 @@ func TestDatabaseFromRDSInstanceNameOverride(t *testing.T) {
Name: "override-1",
Description: "RDS instance in us-west-1",
Labels: map[string]string{
types.OriginLabel: types.OriginCloud,
labelAccountID: "123456789012",
labelRegion: "us-west-1",
labelEngine: RDSEnginePostgres,
Expand Down Expand Up @@ -705,7 +699,6 @@ func TestDatabaseFromRDSCluster(t *testing.T) {
Name: "cluster-1",
Description: "Aurora cluster in us-east-1",
Labels: map[string]string{
types.OriginLabel: types.OriginCloud,
labelAccountID: "123456789012",
labelRegion: "us-east-1",
labelEngine: RDSEngineAuroraMySQL,
Expand All @@ -729,7 +722,6 @@ func TestDatabaseFromRDSCluster(t *testing.T) {
Name: "cluster-1-reader",
Description: "Aurora cluster in us-east-1 (reader endpoint)",
Labels: map[string]string{
types.OriginLabel: types.OriginCloud,
labelAccountID: "123456789012",
labelRegion: "us-east-1",
labelEngine: RDSEngineAuroraMySQL,
Expand All @@ -750,7 +742,6 @@ func TestDatabaseFromRDSCluster(t *testing.T) {

t.Run("custom endpoints", func(t *testing.T) {
expectedLabels := map[string]string{
types.OriginLabel: types.OriginCloud,
labelAccountID: "123456789012",
labelRegion: "us-east-1",
labelEngine: RDSEngineAuroraMySQL,
Expand Down Expand Up @@ -842,7 +833,6 @@ func TestDatabaseFromRDSV2Cluster(t *testing.T) {
Name: "cluster-1",
Description: "Aurora cluster in us-east-1",
Labels: map[string]string{
types.OriginLabel: types.OriginCloud,
labelAccountID: "123456789012",
labelRegion: "us-east-1",
labelEngine: RDSEngineAuroraMySQL,
Expand Down Expand Up @@ -916,7 +906,6 @@ func TestDatabaseFromRDSClusterNameOverride(t *testing.T) {
Name: "mycluster-2",
Description: "Aurora cluster in us-east-1",
Labels: map[string]string{
types.OriginLabel: types.OriginCloud,
labelAccountID: "123456789012",
labelRegion: "us-east-1",
labelEngine: RDSEngineAuroraMySQL,
Expand All @@ -941,7 +930,6 @@ func TestDatabaseFromRDSClusterNameOverride(t *testing.T) {
Name: "mycluster-2-reader",
Description: "Aurora cluster in us-east-1 (reader endpoint)",
Labels: map[string]string{
types.OriginLabel: types.OriginCloud,
labelAccountID: "123456789012",
labelRegion: "us-east-1",
labelEngine: RDSEngineAuroraMySQL,
Expand All @@ -963,7 +951,6 @@ func TestDatabaseFromRDSClusterNameOverride(t *testing.T) {

t.Run("custom endpoints", func(t *testing.T) {
expectedLabels := map[string]string{
types.OriginLabel: types.OriginCloud,
labelAccountID: "123456789012",
labelRegion: "us-east-1",
labelEngine: RDSEngineAuroraMySQL,
Expand Down Expand Up @@ -1045,12 +1032,11 @@ func TestDatabaseFromRDSProxy(t *testing.T) {
Name: "testproxy",
Description: "RDS Proxy in ca-central-1",
Labels: map[string]string{
"key": "val",
types.OriginLabel: types.OriginCloud,
labelAccountID: "123456789012",
labelRegion: "ca-central-1",
labelEngine: "MYSQL",
labelVPCID: "test-vpc-id",
"key": "val",
labelAccountID: "123456789012",
labelRegion: "ca-central-1",
labelEngine: "MYSQL",
labelVPCID: "test-vpc-id",
},
}, types.DatabaseSpecV3{
Protocol: defaults.ProtocolMySQL,
Expand All @@ -1077,7 +1063,6 @@ func TestDatabaseFromRDSProxy(t *testing.T) {
Description: "RDS Proxy endpoint in ca-central-1",
Labels: map[string]string{
"key": "val",
types.OriginLabel: types.OriginCloud,
labelAccountID: "123456789012",
labelRegion: "ca-central-1",
labelEngine: "MYSQL",
Expand Down Expand Up @@ -1268,7 +1253,6 @@ func TestDatabaseFromRedshiftCluster(t *testing.T) {
Name: "mycluster",
Description: "Redshift cluster in us-east-1",
Labels: map[string]string{
types.OriginLabel: types.OriginCloud,
labelAccountID: "123456789012",
labelRegion: "us-east-1",
"key": "val",
Expand Down Expand Up @@ -1320,7 +1304,6 @@ func TestDatabaseFromRedshiftCluster(t *testing.T) {
Name: "mycluster-override-2",
Description: "Redshift cluster in us-east-1",
Labels: map[string]string{
types.OriginLabel: types.OriginCloud,
labelAccountID: "123456789012",
labelRegion: "us-east-1",
labelTeleportDBName: "mycluster-override-2",
Expand Down Expand Up @@ -1398,7 +1381,6 @@ func TestDatabaseFromElastiCacheConfigurationEndpoint(t *testing.T) {
Name: "my-cluster",
Description: "ElastiCache cluster in us-east-1 (configuration endpoint)",
Labels: map[string]string{
types.OriginLabel: types.OriginCloud,
labelAccountID: "123456789012",
labelRegion: "us-east-1",
labelEndpointType: "configuration",
Expand Down Expand Up @@ -1471,7 +1453,6 @@ func TestDatabaseFromElastiCacheConfigurationEndpointNameOverride(t *testing.T)
Name: "my-override-cluster-2",
Description: "ElastiCache cluster in us-east-1 (configuration endpoint)",
Labels: map[string]string{
types.OriginLabel: types.OriginCloud,
labelAccountID: "123456789012",
labelRegion: "us-east-1",
labelEndpointType: "configuration",
Expand Down Expand Up @@ -1527,7 +1508,6 @@ func TestDatabaseFromElastiCacheNodeGroups(t *testing.T) {
Name: "my-cluster",
Description: "ElastiCache cluster in us-east-1 (primary endpoint)",
Labels: map[string]string{
types.OriginLabel: types.OriginCloud,
labelAccountID: "123456789012",
labelRegion: "us-east-1",
labelEndpointType: "primary",
Expand All @@ -1553,7 +1533,6 @@ func TestDatabaseFromElastiCacheNodeGroups(t *testing.T) {
Name: "my-cluster-reader",
Description: "ElastiCache cluster in us-east-1 (reader endpoint)",
Labels: map[string]string{
types.OriginLabel: types.OriginCloud,
labelAccountID: "123456789012",
labelRegion: "us-east-1",
labelEndpointType: "reader",
Expand Down Expand Up @@ -1611,7 +1590,6 @@ func TestDatabaseFromElastiCacheNodeGroupsNameOverride(t *testing.T) {
Name: "my-override-cluster-2",
Description: "ElastiCache cluster in us-east-1 (primary endpoint)",
Labels: map[string]string{
types.OriginLabel: types.OriginCloud,
labelAccountID: "123456789012",
labelRegion: "us-east-1",
labelEndpointType: "primary",
Expand All @@ -1638,7 +1616,6 @@ func TestDatabaseFromElastiCacheNodeGroupsNameOverride(t *testing.T) {
Name: "my-override-cluster-2-reader",
Description: "ElastiCache cluster in us-east-1 (reader endpoint)",
Labels: map[string]string{
types.OriginLabel: types.OriginCloud,
labelAccountID: "123456789012",
labelRegion: "us-east-1",
labelEndpointType: "reader",
Expand Down Expand Up @@ -1684,7 +1661,6 @@ func TestDatabaseFromMemoryDBCluster(t *testing.T) {
Name: "my-cluster",
Description: "MemoryDB cluster in us-east-1",
Labels: map[string]string{
types.OriginLabel: types.OriginCloud,
labelAccountID: "123456789012",
labelRegion: "us-east-1",
labelEndpointType: "cluster",
Expand Down Expand Up @@ -1718,7 +1694,6 @@ func TestDatabaseFromRedshiftServerlessWorkgroup(t *testing.T) {
Name: "my-workgroup",
Description: "Redshift Serverless workgroup in eu-west-2",
Labels: map[string]string{
types.OriginLabel: types.OriginCloud,
labelAccountID: "123456789012",
labelRegion: "eu-west-2",
labelEndpointType: "workgroup",
Expand Down Expand Up @@ -1753,7 +1728,6 @@ func TestDatabaseFromRedshiftServerlessVPCEndpoint(t *testing.T) {
Name: "my-workgroup-my-endpoint",
Description: "Redshift Serverless endpoint in eu-west-2",
Labels: map[string]string{
types.OriginLabel: types.OriginCloud,
labelAccountID: "123456789012",
labelRegion: "eu-west-2",
labelEndpointType: "vpc-endpoint",
Expand Down Expand Up @@ -1806,7 +1780,6 @@ func TestDatabaseFromMemoryDBClusterNameOverride(t *testing.T) {
Name: "override-1",
Description: "MemoryDB cluster in us-east-1",
Labels: map[string]string{
types.OriginLabel: types.OriginCloud,
labelAccountID: "123456789012",
labelRegion: "us-east-1",
labelEndpointType: "cluster",
Expand Down Expand Up @@ -2098,7 +2071,6 @@ func TestNewDatabaseFromAzureSQLServer(t *testing.T) {

// Assert labels
labels := db.GetMetadata().Labels
require.Equal(t, types.OriginCloud, labels[types.OriginLabel])
require.Equal(t, "westus", labels[labelRegion])
require.Equal(t, "12.0", labels[labelEngineVersion])
},
Expand Down Expand Up @@ -2154,7 +2126,6 @@ func TestNewDatabaseFromAzureManagedSQLServer(t *testing.T) {

// Assert labels
labels := db.GetMetadata().Labels
require.Equal(t, types.OriginCloud, labels[types.OriginLabel])
require.Equal(t, "westus", labels[labelRegion])
},
},
Expand Down Expand Up @@ -2241,7 +2212,6 @@ func TestDatabaseFromAzureMySQLFlexServer(t *testing.T) {
}

wantLabels := map[string]string{
types.OriginLabel: types.OriginCloud,
labelRegion: region,
labelEngine: provider,
labelEngineVersion: "8.0.21",
Expand Down Expand Up @@ -2317,7 +2287,6 @@ func TestDatabaseFromAzurePostgresFlexServer(t *testing.T) {
}

wantLabels := map[string]string{
types.OriginLabel: types.OriginCloud,
labelRegion: region,
labelEngine: provider,
labelEngineVersion: "14",
Expand Down Expand Up @@ -2414,7 +2383,6 @@ func TestMakeAzureDatabaseLoginUsername(t *testing.T) {
Name: serverName,
Description: "test azure db server",
Labels: map[string]string{
types.OriginLabel: types.OriginCloud,
labelRegion: "eastus",
labelEngine: tt.engine,
labelEngineVersion: "1.2.3",
Expand Down
Loading