Skip to content

Commit fb172e7

Browse files
authored
OpenStack instance tag support (#150)
1 parent 776a67e commit fb172e7

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

parser_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ const exampleStateFile = `
185185
"id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
186186
"access_ip_v4": "10.120.0.226",
187187
"access_ip_v6": "",
188+
"tag.%": "1",
189+
"tag.ostags": "rock",
188190
"metadata.status": "superServer",
189191
"metadata.#": "very bad",
190192
"metadata_toes": "faada2142412jhb1j2"
@@ -560,6 +562,7 @@ const expectedListOutput = `
560562
"webserver": ["192.168.0.3"],
561563
"staging": ["192.168.0.3"],
562564
"status_superserver": ["10.120.0.226"],
565+
"ostags_rock": ["10.120.0.226"],
563566
"database": ["10.0.0.8"],
564567
"scw_test": ["10.0.0.11"],
565568
"tfinventory_rocks": ["10.0.0.19"],
@@ -668,6 +671,9 @@ olddatacenter="\u003c0.7_format"
668671
[one_1]
669672
10.0.1.1
670673
674+
[ostags_rock]
675+
10.120.0.226
676+
671677
[role_nine]
672678
10.0.0.9
673679

resource.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,11 @@ func (r Resource) Tags() map[string]string {
122122
// At some point Terraform changed the key for counts of attributes to end with ".%"
123123
// instead of ".#". Both need to be considered as Terraform still supports state
124124
// files using the old format.
125-
if len(parts) == 2 && parts[0] == "metadata" && parts[1] != "#" && parts[1] != "%" {
125+
if len(parts) == 2 && parts[0] == "tag" && parts[1] != "#" && parts[1] != "%" {
126+
kk := strings.ToLower(parts[1])
127+
vv := strings.ToLower(v)
128+
t[kk] = vv
129+
} else if len(parts) == 2 && parts[0] == "metadata" && parts[1] != "#" && parts[1] != "%" {
126130
kk := strings.ToLower(parts[1])
127131
vv := strings.ToLower(v)
128132
t[kk] = vv

0 commit comments

Comments
 (0)