1
1
mirror of https://github.com/adammck/terraform-inventory synced 2024-11-22 20:01:58 +01:00

Add tags for vSphere instances (#68)

This commit is contained in:
Nic Grayson 2017-06-20 12:24:02 -05:00 committed by Adam Mckaig
parent 1063a010f5
commit 656ee7639a
2 changed files with 12 additions and 0 deletions

@ -124,6 +124,8 @@ const exampleStateFile = `
"primary": {
"id": "aaaaaaaa",
"attributes": {
"custom_configuration_parameters.%": "1",
"custom_configuration_parameters.role": "rrrrrrrr",
"datacenter": "dddddddd",
"host": "hhhhhhhh",
"id": "aaaaaaaa",
@ -231,6 +233,7 @@ const expectedListOutput = `
"type_softlayer_virtual_guest": ["10.0.0.7"],
"type_google_compute_instance": ["10.0.0.8"],
"role_rrrrrrrr": ["10.20.30.40"],
"role_web": ["10.0.0.1"],
"webserver": ["192.168.0.3"],
"staging": ["192.168.0.3"],

@ -137,6 +137,15 @@ func (r Resource) Tags() map[string]string {
t[kk] = vv
}
}
case "vsphere_virtual_machine":
for k, v := range r.Attributes() {
parts := strings.SplitN(k, ".", 2)
if len(parts) == 2 && parts[0] == "custom_configuration_parameters" && parts[1] != "#" && parts[1] != "%" {
kk := strings.ToLower(parts[1])
vv := strings.ToLower(v)
t[kk] = vv
}
}
case "digitalocean_droplet", "google_compute_instance":
for k, v := range r.Attributes() {
parts := strings.SplitN(k, ".", 2)