Skip to content

Commit 3f55804

Browse files
authored
presets: Do not add "custom_tags: {}" to clusters (#2838)
Follow up to #2756
1 parent 2f60272 commit 3f55804

File tree

6 files changed

+12
-18
lines changed

6 files changed

+12
-18
lines changed

acceptance/bundle/override/clusters/output.txt

-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"min_workers": 2
77
},
88
"cluster_name": "foo",
9-
"custom_tags": {},
109
"node_type_id": "i3.xlarge",
1110
"num_workers": 2,
1211
"spark_conf": {
@@ -22,7 +21,6 @@
2221
"min_workers": 1
2322
},
2423
"cluster_name": "foo-override",
25-
"custom_tags": {},
2624
"node_type_id": "m5.xlarge",
2725
"num_workers": 3,
2826
"spark_conf": {

acceptance/bundle/override/merge-string-map/output.txt

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ Warning: expected map, found string
77
{
88
"clusters": {
99
"my_cluster": {
10-
"custom_tags": {},
1110
"spark_version": "25"
1211
}
1312
}

acceptance/bundle/validate/empty_resources/empty_dict/output.txt

+1-3
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@
8686
=== resources.clusters.rname ===
8787
{
8888
"clusters": {
89-
"rname": {
90-
"custom_tags": {}
91-
}
89+
"rname": {}
9290
}
9391
}
9492

acceptance/bundle/validate/empty_resources/with_grants/output.txt

+1-3
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ Warning: unknown field: grants
115115

116116
{
117117
"clusters": {
118-
"rname": {
119-
"custom_tags": {}
120-
}
118+
"rname": {}
121119
}
122120
}
123121

acceptance/bundle/validate/empty_resources/with_permissions/output.txt

-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ Warning: unknown field: permissions
103103
{
104104
"clusters": {
105105
"rname": {
106-
"custom_tags": {},
107106
"permissions": []
108107
}
109108
}

bundle/config/mutator/resourcemutator/apply_presets.go

+10-8
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,16 @@ func (m *applyPresets) Apply(ctx context.Context, b *bundle.Bundle) diag.Diagnos
195195
continue
196196
}
197197
c.ClusterName = prefix + c.ClusterName
198-
if c.CustomTags == nil {
199-
c.CustomTags = make(map[string]string)
200-
}
201-
for _, tag := range tags {
202-
normalisedKey := b.Tagging.NormalizeKey(tag.Key)
203-
normalisedValue := b.Tagging.NormalizeValue(tag.Value)
204-
if _, ok := c.CustomTags[normalisedKey]; !ok {
205-
c.CustomTags[normalisedKey] = normalisedValue
198+
if len(tags) > 0 {
199+
if c.CustomTags == nil {
200+
c.CustomTags = make(map[string]string, len(tags))
201+
}
202+
for _, tag := range tags {
203+
normalisedKey := b.Tagging.NormalizeKey(tag.Key)
204+
normalisedValue := b.Tagging.NormalizeValue(tag.Value)
205+
if _, ok := c.CustomTags[normalisedKey]; !ok {
206+
c.CustomTags[normalisedKey] = normalisedValue
207+
}
206208
}
207209
}
208210
}

0 commit comments

Comments
 (0)