Skip to content

Commit 67065d0

Browse files
committed
add labels
1 parent f9ee0d3 commit 67065d0

File tree

3 files changed

+78
-0
lines changed

3 files changed

+78
-0
lines changed

internal/convert/convert.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ func fillReplicationSpecs(resourceb *hclwrite.Body) error {
123123
if tags != nil {
124124
resourceb.SetAttributeRaw(nTags, tags)
125125
}
126+
labels, errLabels := getTagsLabelsOpt(nLabels, resourceb)
127+
if errLabels != nil {
128+
return errLabels
129+
}
130+
if labels != nil {
131+
resourceb.SetAttributeRaw(nLabels, labels)
132+
}
126133
fillTimeoutsOpt(resourceb)
127134
resourceb.RemoveBlock(repSpecsSrc)
128135
return nil

internal/convert/testdata/clu2adv/tags_labels_timeouts.in.tf

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,40 @@ resource "mongodbatlas_cluster" "basictimeouts" {
3636
create = "60m"
3737
}
3838
}
39+
40+
resource "mongodbatlas_cluster" "all" {
41+
project_id = var.project_id
42+
name = "all"
43+
cluster_type = "REPLICASET"
44+
provider_name = "AWS"
45+
provider_instance_size_name = "M10"
46+
replication_specs {
47+
num_shards = 1
48+
regions_config {
49+
region_name = "US_EAST_1"
50+
electable_nodes = 3
51+
priority = 7
52+
}
53+
}
54+
tags {
55+
key = "environment"
56+
value = "dev"
57+
}
58+
tags {
59+
key = "Tag 2"
60+
value = "Value 2"
61+
}
62+
labels {
63+
key = "label1"
64+
value = "Val label 1"
65+
}
66+
labels {
67+
key = "Label 2"
68+
value = "label val 2"
69+
}
70+
timeouts {
71+
create = "60m"
72+
update = "50m"
73+
delete = "30m"
74+
}
75+
}

internal/convert/testdata/clu2adv/tags_labels_timeouts.out.tf

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,37 @@ resource "mongodbatlas_advanced_cluster" "basictimeouts" {
4444
# Generated by atlas-cli-plugin-terraform.
4545
# Please confirm that all references to this resource are updated.
4646
}
47+
48+
resource "mongodbatlas_advanced_cluster" "all" {
49+
project_id = var.project_id
50+
name = "all"
51+
cluster_type = "REPLICASET"
52+
replication_specs = [{
53+
region_configs = [{
54+
provider_name = "AWS"
55+
region_name = "US_EAST_1"
56+
priority = 7
57+
electable_specs = {
58+
node_count = 3
59+
instance_size = "M10"
60+
}
61+
}]
62+
}]
63+
tags = {
64+
environment = "dev"
65+
Tag 2 = "Value 2"
66+
}
67+
labels = {
68+
label1 = "Val label 1"
69+
Label 2 = "label val 2"
70+
}
71+
timeouts = {
72+
73+
create = "60m"
74+
update = "50m"
75+
delete = "30m"
76+
}
77+
78+
# Generated by atlas-cli-plugin-terraform.
79+
# Please confirm that all references to this resource are updated.
80+
}

0 commit comments

Comments
 (0)