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
4 changes: 3 additions & 1 deletion lib/auth/auth_with_roles_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2050,6 +2050,7 @@ func TestKubernetesClusterCRUD_DiscoveryService(t *testing.T) {
Status: aws.String(eks.ClusterStatusActive),
})
require.NoError(t, err)
eksCluster.SetOrigin(types.OriginCloud)

// Discovery service must not have access to non-cloud cluster (cluster
// without "cloud" origin label).
Expand All @@ -2069,6 +2070,7 @@ func TestKubernetesClusterCRUD_DiscoveryService(t *testing.T) {
Status: aws.String(eks.ClusterStatusActive),
})
require.NoError(t, err)
clusterWithDynamicLabels.SetOrigin(types.OriginCloud)
clusterWithDynamicLabels.SetDynamicLabels(map[string]types.CommandLabel{
"hostname": &types.CommandLabelV2{
Period: types.Duration(time.Hour),
Expand All @@ -2084,7 +2086,7 @@ func TestKubernetesClusterCRUD_DiscoveryService(t *testing.T) {
t.Run("Read", func(t *testing.T) {
clusters, err := discoveryClt.GetKubernetesClusters(ctx)
require.NoError(t, err)
require.Equal(t, clusters, []types.KubeCluster{eksCluster})
require.Empty(t, cmp.Diff([]types.KubeCluster{eksCluster}, clusters))
})
t.Run("Update", func(t *testing.T) {
require.NoError(t, discoveryClt.UpdateKubernetesCluster(ctx, eksCluster))
Expand Down
45 changes: 21 additions & 24 deletions lib/integrations/awsoidc/listdatabases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,13 @@ 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": "",
"status": "available",
"teleport.dev/cloud": "AWS",
"teleport.dev/origin": "cloud",
"account-id": "123456789012",
"endpoint-type": "instance",
"engine": "postgres",
"engine-version": "",
"region": "",
"status": "available",
"teleport.dev/cloud": "AWS",
},
},
types.DatabaseSpecV3{
Expand Down Expand Up @@ -254,14 +253,13 @@ 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": "",
"status": "available",
"teleport.dev/cloud": "AWS",
"teleport.dev/origin": "cloud",
"account-id": "123456789012",
"endpoint-type": "instance",
"engine": "postgres",
"engine-version": "",
"region": "",
"status": "available",
"teleport.dev/cloud": "AWS",
},
},
types.DatabaseSpecV3{
Expand Down Expand Up @@ -312,14 +310,13 @@ 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": "",
"status": "available",
"teleport.dev/cloud": "AWS",
"teleport.dev/origin": "cloud",
"account-id": "123456789012",
"endpoint-type": "primary",
"engine": "aurora-postgresql",
"engine-version": "",
"region": "",
"status": "available",
"teleport.dev/cloud": "AWS",
},
},
types.DatabaseSpecV3{
Expand Down
2 changes: 0 additions & 2 deletions lib/services/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,6 @@ func labelsFromAWSMetadata(meta *types.AWS) map[string]string {
labels[types.DiscoveryLabelAccountID] = meta.AccountID
labels[types.DiscoveryLabelRegion] = meta.Region
}
labels[types.OriginLabel] = types.OriginCloud
labels[types.CloudLabel] = types.CloudAWS
return labels
}
Expand All @@ -1640,7 +1639,6 @@ func labelsFromMetaAndEndpointType(meta *types.AWS, endpointType string, extraLa
// azureTagsToLabels converts Azure tags to a labels map.
func azureTagsToLabels(tags map[string]string) map[string]string {
labels := make(map[string]string)
labels[types.OriginLabel] = types.OriginCloud
labels[types.CloudLabel] = types.CloudAzure
return addLabels(labels, tags)
}
Expand Down
40 changes: 4 additions & 36 deletions lib/services/database_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,6 @@ func TestDatabaseFromAzureDBServer(t *testing.T) {
types.DiscoveryLabelEngine: "Microsoft.DBforMySQL/servers",
types.DiscoveryLabelEngineVersion: "5.7",
types.DiscoveryLabelAzureResourceGroup: "defaultRG",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAzure,
types.DiscoveryLabelAzureSubscriptionID: "sub1",
"foo": "bar",
Expand Down Expand Up @@ -532,7 +531,6 @@ func TestDatabaseFromAzureRedis(t *testing.T) {
types.DiscoveryLabelEngine: "Microsoft.Cache/Redis",
types.DiscoveryLabelEngineVersion: "6.0",
types.DiscoveryLabelAzureResourceGroup: group,
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAzure,
types.DiscoveryLabelAzureSubscriptionID: subscription,
"foo": "bar",
Expand Down Expand Up @@ -591,7 +589,6 @@ func TestDatabaseFromAzureRedisEnterprise(t *testing.T) {
types.DiscoveryLabelEngine: "Microsoft.Cache/redisEnterprise",
types.DiscoveryLabelEngineVersion: "6.0",
types.DiscoveryLabelAzureResourceGroup: group,
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAzure,
types.DiscoveryLabelAzureSubscriptionID: subscription,
types.DiscoveryLabelEndpointType: "OSSCluster",
Expand Down Expand Up @@ -639,7 +636,6 @@ func TestDatabaseFromRDSInstance(t *testing.T) {
Description: "RDS instance in us-west-1",
Labels: map[string]string{
types.DiscoveryLabelAccountID: "123456789012",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAWS,
types.DiscoveryLabelRegion: "us-west-1",
types.DiscoveryLabelEngine: RDSEnginePostgres,
Expand Down Expand Up @@ -701,7 +697,6 @@ func TestDatabaseFromRDSV2Instance(t *testing.T) {
Description: "RDS instance in us-west-1",
Labels: map[string]string{
types.DiscoveryLabelAccountID: "123456789012",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAWS,
types.DiscoveryLabelRegion: "us-west-1",
types.DiscoveryLabelEngine: RDSEnginePostgres,
Expand Down Expand Up @@ -780,7 +775,6 @@ func TestDatabaseFromRDSInstanceNameOverride(t *testing.T) {
Description: "RDS instance in us-west-1",
Labels: map[string]string{
types.DiscoveryLabelAccountID: "123456789012",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAWS,
types.DiscoveryLabelRegion: "us-west-1",
types.DiscoveryLabelEngine: RDSEnginePostgres,
Expand Down Expand Up @@ -849,7 +843,6 @@ func TestDatabaseFromRDSCluster(t *testing.T) {
Description: "Aurora cluster in us-east-1",
Labels: map[string]string{
types.DiscoveryLabelAccountID: "123456789012",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAWS,
types.DiscoveryLabelRegion: "us-east-1",
types.DiscoveryLabelEngine: RDSEngineAuroraMySQL,
Expand All @@ -874,7 +867,6 @@ func TestDatabaseFromRDSCluster(t *testing.T) {
Description: "Aurora cluster in us-east-1 (reader endpoint)",
Labels: map[string]string{
types.DiscoveryLabelAccountID: "123456789012",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAWS,
types.DiscoveryLabelRegion: "us-east-1",
types.DiscoveryLabelEngine: RDSEngineAuroraMySQL,
Expand All @@ -896,7 +888,6 @@ func TestDatabaseFromRDSCluster(t *testing.T) {
t.Run("custom endpoints", func(t *testing.T) {
expectedLabels := map[string]string{
types.DiscoveryLabelAccountID: "123456789012",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAWS,
types.DiscoveryLabelRegion: "us-east-1",
types.DiscoveryLabelEngine: RDSEngineAuroraMySQL,
Expand Down Expand Up @@ -989,7 +980,6 @@ func TestDatabaseFromRDSV2Cluster(t *testing.T) {
Description: "Aurora cluster in us-east-1",
Labels: map[string]string{
types.DiscoveryLabelAccountID: "123456789012",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAWS,
types.DiscoveryLabelRegion: "us-east-1",
types.DiscoveryLabelEngine: RDSEngineAuroraMySQL,
Expand Down Expand Up @@ -1046,7 +1036,6 @@ func TestDatabaseFromRDSV2Cluster(t *testing.T) {
"teleport.dev/database_name": "override-1",
types.DiscoveryLabelAccountID: "123456789012",
types.CloudLabel: types.CloudAWS,
types.OriginLabel: types.OriginCloud,
types.DiscoveryLabelRegion: "us-east-1",
types.DiscoveryLabelEngine: RDSEngineAuroraMySQL,
types.DiscoveryLabelEngineVersion: "8.0.0",
Expand Down Expand Up @@ -1115,7 +1104,6 @@ func TestDatabaseFromRDSClusterNameOverride(t *testing.T) {
Description: "Aurora cluster in us-east-1",
Labels: map[string]string{
types.DiscoveryLabelAccountID: "123456789012",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAWS,
types.DiscoveryLabelRegion: "us-east-1",
types.DiscoveryLabelEngine: RDSEngineAuroraMySQL,
Expand All @@ -1141,7 +1129,6 @@ func TestDatabaseFromRDSClusterNameOverride(t *testing.T) {
Description: "Aurora cluster in us-east-1 (reader endpoint)",
Labels: map[string]string{
types.DiscoveryLabelAccountID: "123456789012",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAWS,
types.DiscoveryLabelRegion: "us-east-1",
types.DiscoveryLabelEngine: RDSEngineAuroraMySQL,
Expand All @@ -1164,7 +1151,6 @@ func TestDatabaseFromRDSClusterNameOverride(t *testing.T) {
t.Run("custom endpoints", func(t *testing.T) {
expectedLabels := map[string]string{
types.DiscoveryLabelAccountID: "123456789012",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAWS,
types.DiscoveryLabelRegion: "us-east-1",
types.DiscoveryLabelEngine: RDSEngineAuroraMySQL,
Expand Down Expand Up @@ -1249,7 +1235,6 @@ func TestDatabaseFromRDSProxy(t *testing.T) {
Labels: map[string]string{
"key": "val",
types.DiscoveryLabelAccountID: "123456789012",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAWS,
types.DiscoveryLabelRegion: "ca-central-1",
types.DiscoveryLabelEngine: "MYSQL",
Expand Down Expand Up @@ -1281,7 +1266,6 @@ func TestDatabaseFromRDSProxy(t *testing.T) {
Labels: map[string]string{
"key": "val",
types.DiscoveryLabelAccountID: "123456789012",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAWS,
types.DiscoveryLabelRegion: "ca-central-1",
types.DiscoveryLabelEngine: "MYSQL",
Expand Down Expand Up @@ -1444,11 +1428,10 @@ func TestAzureTagsToLabels(t *testing.T) {
}
labels := azureTagsToLabels(azureTags)
wantLabels := map[string]string{
"Name": "test",
"Env": "dev",
"foo:bar": "some-id",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAzure,
"Name": "test",
"Env": "dev",
"foo:bar": "some-id",
types.CloudLabel: types.CloudAzure,
}
require.Equal(t, wantLabels, labels)
}
Expand Down Expand Up @@ -1479,7 +1462,6 @@ func TestDatabaseFromRedshiftCluster(t *testing.T) {
Description: "Redshift cluster in us-east-1",
Labels: map[string]string{
types.DiscoveryLabelAccountID: "123456789012",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAWS,
types.DiscoveryLabelRegion: "us-east-1",
"key": "val",
Expand Down Expand Up @@ -1533,7 +1515,6 @@ func TestDatabaseFromRedshiftCluster(t *testing.T) {
Description: "Redshift cluster in us-east-1",
Labels: map[string]string{
types.DiscoveryLabelAccountID: "123456789012",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAWS,
types.DiscoveryLabelRegion: "us-east-1",
overrideLabel: "mycluster-override-2",
Expand Down Expand Up @@ -1613,7 +1594,6 @@ func TestDatabaseFromElastiCacheConfigurationEndpoint(t *testing.T) {
Description: "ElastiCache cluster in us-east-1 (configuration endpoint)",
Labels: map[string]string{
types.DiscoveryLabelAccountID: "123456789012",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAWS,
types.DiscoveryLabelRegion: "us-east-1",
types.DiscoveryLabelEndpointType: "configuration",
Expand Down Expand Up @@ -1689,7 +1669,6 @@ func TestDatabaseFromElastiCacheConfigurationEndpointNameOverride(t *testing.T)
Description: "ElastiCache cluster in us-east-1 (configuration endpoint)",
Labels: map[string]string{
types.DiscoveryLabelAccountID: "123456789012",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAWS,
types.DiscoveryLabelRegion: "us-east-1",
types.DiscoveryLabelEndpointType: "configuration",
Expand Down Expand Up @@ -1748,7 +1727,6 @@ func TestDatabaseFromElastiCacheNodeGroups(t *testing.T) {
Description: "ElastiCache cluster in us-east-1 (primary endpoint)",
Labels: map[string]string{
types.DiscoveryLabelAccountID: "123456789012",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAWS,
types.DiscoveryLabelRegion: "us-east-1",
types.DiscoveryLabelEndpointType: "primary",
Expand All @@ -1775,7 +1753,6 @@ func TestDatabaseFromElastiCacheNodeGroups(t *testing.T) {
Description: "ElastiCache cluster in us-east-1 (reader endpoint)",
Labels: map[string]string{
types.DiscoveryLabelAccountID: "123456789012",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAWS,
types.DiscoveryLabelRegion: "us-east-1",
types.DiscoveryLabelEndpointType: "reader",
Expand Down Expand Up @@ -1836,7 +1813,6 @@ func TestDatabaseFromElastiCacheNodeGroupsNameOverride(t *testing.T) {
Description: "ElastiCache cluster in us-east-1 (primary endpoint)",
Labels: map[string]string{
types.DiscoveryLabelAccountID: "123456789012",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAWS,
types.DiscoveryLabelRegion: "us-east-1",
types.DiscoveryLabelEndpointType: "primary",
Expand Down Expand Up @@ -1864,7 +1840,6 @@ func TestDatabaseFromElastiCacheNodeGroupsNameOverride(t *testing.T) {
Description: "ElastiCache cluster in us-east-1 (reader endpoint)",
Labels: map[string]string{
types.DiscoveryLabelAccountID: "123456789012",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAWS,
types.DiscoveryLabelRegion: "us-east-1",
types.DiscoveryLabelEndpointType: "reader",
Expand Down Expand Up @@ -1913,7 +1888,6 @@ func TestDatabaseFromMemoryDBCluster(t *testing.T) {
Description: "MemoryDB cluster in us-east-1",
Labels: map[string]string{
types.DiscoveryLabelAccountID: "123456789012",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAWS,
types.DiscoveryLabelRegion: "us-east-1",
types.DiscoveryLabelEndpointType: "cluster",
Expand Down Expand Up @@ -1948,7 +1922,6 @@ func TestDatabaseFromRedshiftServerlessWorkgroup(t *testing.T) {
Description: "Redshift Serverless workgroup in eu-west-2",
Labels: map[string]string{
types.DiscoveryLabelAccountID: "123456789012",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAWS,
types.DiscoveryLabelRegion: "eu-west-2",
types.DiscoveryLabelEndpointType: "workgroup",
Expand Down Expand Up @@ -1984,7 +1957,6 @@ func TestDatabaseFromRedshiftServerlessVPCEndpoint(t *testing.T) {
Description: "Redshift Serverless endpoint in eu-west-2",
Labels: map[string]string{
types.DiscoveryLabelAccountID: "123456789012",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAWS,
types.DiscoveryLabelRegion: "eu-west-2",
types.DiscoveryLabelEndpointType: "vpc-endpoint",
Expand Down Expand Up @@ -2040,7 +2012,6 @@ func TestDatabaseFromMemoryDBClusterNameOverride(t *testing.T) {
Description: "MemoryDB cluster in us-east-1",
Labels: map[string]string{
types.DiscoveryLabelAccountID: "123456789012",
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAWS,
types.DiscoveryLabelRegion: "us-east-1",
types.DiscoveryLabelEndpointType: "cluster",
Expand Down Expand Up @@ -2434,7 +2405,6 @@ func TestDatabaseFromAzureMySQLFlexServer(t *testing.T) {
types.DiscoveryLabelEngine: provider,
types.DiscoveryLabelEngineVersion: "8.0.21",
types.DiscoveryLabelAzureResourceGroup: group,
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAzure,
types.DiscoveryLabelAzureSubscriptionID: subID,
"foo": "bar",
Expand Down Expand Up @@ -2511,7 +2481,6 @@ func TestDatabaseFromAzurePostgresFlexServer(t *testing.T) {
types.DiscoveryLabelEngine: provider,
types.DiscoveryLabelEngineVersion: "14",
types.DiscoveryLabelAzureResourceGroup: group,
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAzure,
types.DiscoveryLabelAzureSubscriptionID: subID,
"foo": "bar",
Expand Down Expand Up @@ -2609,7 +2578,6 @@ func TestMakeAzureDatabaseLoginUsername(t *testing.T) {
types.DiscoveryLabelEngine: tt.engine,
types.DiscoveryLabelEngineVersion: "1.2.3",
types.DiscoveryLabelAzureResourceGroup: group,
types.OriginLabel: types.OriginCloud,
types.CloudLabel: types.CloudAzure,
types.DiscoveryLabelAzureSubscriptionID: subID,
"foo": "bar",
Expand Down
3 changes: 0 additions & 3 deletions lib/services/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ func NewKubeClusterFromAzureAKS(cluster *azure.AKSCluster) (types.KubeCluster, e
// labelsFromAzureKubeCluster creates kube cluster labels.
func labelsFromAzureKubeCluster(cluster *azure.AKSCluster) map[string]string {
labels := azureTagsToLabels(cluster.Tags)
labels[types.OriginLabel] = types.OriginCloud
labels[types.CloudLabel] = types.CloudAzure
labels[types.DiscoveryLabelRegion] = cluster.Location

Expand Down Expand Up @@ -253,7 +252,6 @@ func getOrSetDefaultGCPDescription(cluster gcp.GKECluster) string {
func labelsFromGCPKubeCluster(cluster gcp.GKECluster) map[string]string {
labels := make(map[string]string)
maps.Copy(labels, cluster.Labels)
labels[types.OriginLabel] = types.OriginCloud

labels[types.CloudLabel] = types.CloudGCP
labels[types.DiscoveryLabelGCPLocation] = cluster.Location
Expand Down Expand Up @@ -289,7 +287,6 @@ func NewKubeClusterFromAWSEKS(cluster *eks.Cluster) (types.KubeCluster, error) {
// labelsFromAWSKubeCluster creates kube cluster labels.
func labelsFromAWSKubeCluster(cluster *eks.Cluster, parsedARN arn.ARN) map[string]string {
labels := awsEKSTagsToLabels(cluster.Tags)
labels[types.OriginLabel] = types.OriginCloud
labels[types.CloudLabel] = types.CloudAWS
labels[types.DiscoveryLabelRegion] = parsedARN.Region

Expand Down
Loading