mirror of
https://github.com/adammck/terraform-inventory
synced 2024-11-26 07:43:46 +01:00
Add OpenStack metadata integration (#65)
This commit is contained in:
parent
6f4c1a9983
commit
898a7270c4
@ -142,7 +142,10 @@ const exampleStateFile = `
|
|||||||
"attributes": {
|
"attributes": {
|
||||||
"id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
|
"id": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
|
||||||
"access_ip_v4": "10.120.0.226",
|
"access_ip_v4": "10.120.0.226",
|
||||||
"access_ip_v6": ""
|
"access_ip_v6": "",
|
||||||
|
"metadata.status": "superServer",
|
||||||
|
"metadata.#": "very bad",
|
||||||
|
"metadata_toes": "faada2142412jhb1j2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -231,6 +234,7 @@ const expectedListOutput = `
|
|||||||
"role_web": ["10.0.0.1"],
|
"role_web": ["10.0.0.1"],
|
||||||
"webserver": ["192.168.0.3"],
|
"webserver": ["192.168.0.3"],
|
||||||
"staging": ["192.168.0.3"],
|
"staging": ["192.168.0.3"],
|
||||||
|
"status_superserver": ["10.120.0.226"],
|
||||||
"database": ["10.0.0.8"]
|
"database": ["10.0.0.8"]
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
@ -115,6 +115,15 @@ func (r Resource) Tags() map[string]string {
|
|||||||
t := map[string]string{}
|
t := map[string]string{}
|
||||||
|
|
||||||
switch r.resourceType {
|
switch r.resourceType {
|
||||||
|
case "openstack_compute_instance_v2":
|
||||||
|
for k, v := range r.Attributes() {
|
||||||
|
parts := strings.SplitN(k, ".", 2)
|
||||||
|
if len(parts) == 2 && parts[0] == "metadata" && parts[1] != "#" {
|
||||||
|
kk := strings.ToLower(parts[1])
|
||||||
|
vv := strings.ToLower(v)
|
||||||
|
t[kk] = vv
|
||||||
|
}
|
||||||
|
}
|
||||||
case "aws_instance":
|
case "aws_instance":
|
||||||
for k, v := range r.Attributes() {
|
for k, v := range r.Attributes() {
|
||||||
parts := strings.SplitN(k, ".", 2)
|
parts := strings.SplitN(k, ".", 2)
|
||||||
|
Loading…
Reference in New Issue
Block a user