From 3093ecd49752c4a7c5b35ff49bb935b0543bb096 Mon Sep 17 00:00:00 2001 From: Yonatan Koren Date: Fri, 8 Sep 2017 11:40:08 -0400 Subject: [PATCH] Fix tags for Joyent Triton (#76) --- parser_test.go | 1 + resource.go | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/parser_test.go b/parser_test.go index 2908bce..25f7da2 100644 --- a/parser_test.go +++ b/parser_test.go @@ -324,6 +324,7 @@ const expectedListOutput = ` "role_rrrrrrrr": ["10.20.30.40"], "role_web": ["10.0.0.1"], + "role_test": ["10.0.0.10"], "webserver": ["192.168.0.3"], "staging": ["192.168.0.3"], "status_superserver": ["10.120.0.226"], diff --git a/resource.go b/resource.go index b816eae..7b11c0a 100644 --- a/resource.go +++ b/resource.go @@ -156,6 +156,15 @@ func (r Resource) Tags() map[string]string { t[vv] = "" } } + case "triton_machine": + for k, v := range r.Attributes() { + parts := strings.SplitN(k, ".", 2) + if len(parts) == 2 && parts[0] == "tags" && parts[1] != "%" { + kk := strings.ToLower(parts[1]) + vv := strings.ToLower(v) + t[kk] = vv + } + } } return t }