From ac5b450c9dca1b97fd6b4c399d9e1b2ce8659867 Mon Sep 17 00:00:00 2001 From: Mathieu Debove Date: Wed, 28 Nov 2018 16:21:11 +0100 Subject: [PATCH] Convert grouped properties to hierarchical properties --- consul/consul.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/consul/consul.go b/consul/consul.go index 2626d66..545ca72 100644 --- a/consul/consul.go +++ b/consul/consul.go @@ -4,6 +4,7 @@ import ( "github.com/TIBCOSoftware/flogo-lib/app" "github.com/TIBCOSoftware/flogo-lib/logger" "github.com/hashicorp/consul/api" + "strings" ) var ( @@ -29,15 +30,16 @@ func init() { type SimpleConsulKVValueResolver struct { } -func (resolver *SimpleConsulKVValueResolver) ResolveValue(toResolve string) (interface{}, error) { - key := "flogo/" + app.GetName() + "/" + toResolve +func (resolver *SimpleConsulKVValueResolver) ResolveValue(key string) (interface{}, error) { + key = strings.Replace(key, ".", "/", -1) + consul_key := "flogo/" + app.GetName() + "/" + key - pair, _, err := kv.Get(key, nil) + pair, _, err := kv.Get(consul_key, nil) var value interface{} if err != nil || pair == nil { - log.Warnf("Property '%s' is not found in Consul.", toResolve) + log.Warnf("Property '%s' is not found in Consul.", key) value = nil // will use default value } else {