1
1
mirror of https://github.com/adammck/terraform-inventory synced 2024-11-26 07:43:46 +01:00

Added support for Digital Ocean droplet tags (#56)

This commit is contained in:
Michael Bøcker-Larsen 2017-01-20 01:50:57 +08:00 committed by Adam Mckaig
parent be8d8d7bdb
commit 017b2858b0
2 changed files with 9 additions and 4 deletions

@ -98,7 +98,10 @@ const exampleStateFile = `
"id": "ddddddd",
"attributes": {
"id": "ddddddd",
"ipv4_address": "192.168.0.3"
"ipv4_address": "192.168.0.3",
"tags.#": "2",
"tags.1": "staging",
"tags.2": "webserver"
}
}
},
@ -226,6 +229,8 @@ const expectedListOutput = `
"type_google_compute_instance": ["10.0.0.8"],
"role_web": ["10.0.0.1"],
"webserver": ["192.168.0.3"],
"staging": ["192.168.0.3"],
"database": ["10.0.0.8"]
}
`

@ -94,11 +94,11 @@ func (r Resource) Groups() []string {
}
for k, v := range r.Tags() {
// google
// Valueless
if v == "" {
g := k
groups = append(groups, g)
// aws
// Key-value
} else {
g := fmt.Sprintf("%s_%s", k, v)
groups = append(groups, g)
@ -124,7 +124,7 @@ func (r Resource) Tags() map[string]string {
t[kk] = vv
}
}
case "google_compute_instance":
case "digitalocean_droplet", "google_compute_instance":
for k, v := range r.Attributes() {
parts := strings.SplitN(k, ".", 2)
if len(parts) == 2 && parts[0] == "tags" && parts[1] != "#" {