mirror of
https://github.com/adammck/terraform-inventory
synced 2024-11-23 00:12:13 +01:00
Added support for Digital Ocean droplet tags (#56)
This commit is contained in:
parent
be8d8d7bdb
commit
017b2858b0
@ -98,7 +98,10 @@ const exampleStateFile = `
|
|||||||
"id": "ddddddd",
|
"id": "ddddddd",
|
||||||
"attributes": {
|
"attributes": {
|
||||||
"id": "ddddddd",
|
"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"],
|
"type_google_compute_instance": ["10.0.0.8"],
|
||||||
|
|
||||||
"role_web": ["10.0.0.1"],
|
"role_web": ["10.0.0.1"],
|
||||||
|
"webserver": ["192.168.0.3"],
|
||||||
|
"staging": ["192.168.0.3"],
|
||||||
"database": ["10.0.0.8"]
|
"database": ["10.0.0.8"]
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
@ -94,11 +94,11 @@ func (r Resource) Groups() []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for k, v := range r.Tags() {
|
for k, v := range r.Tags() {
|
||||||
// google
|
// Valueless
|
||||||
if v == "" {
|
if v == "" {
|
||||||
g := k
|
g := k
|
||||||
groups = append(groups, g)
|
groups = append(groups, g)
|
||||||
// aws
|
// Key-value
|
||||||
} else {
|
} else {
|
||||||
g := fmt.Sprintf("%s_%s", k, v)
|
g := fmt.Sprintf("%s_%s", k, v)
|
||||||
groups = append(groups, g)
|
groups = append(groups, g)
|
||||||
@ -124,7 +124,7 @@ func (r Resource) Tags() map[string]string {
|
|||||||
t[kk] = vv
|
t[kk] = vv
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case "google_compute_instance":
|
case "digitalocean_droplet", "google_compute_instance":
|
||||||
for k, v := range r.Attributes() {
|
for k, v := range r.Attributes() {
|
||||||
parts := strings.SplitN(k, ".", 2)
|
parts := strings.SplitN(k, ".", 2)
|
||||||
if len(parts) == 2 && parts[0] == "tags" && parts[1] != "#" {
|
if len(parts) == 2 && parts[0] == "tags" && parts[1] != "#" {
|
||||||
|
Loading…
Reference in New Issue
Block a user