Skip to content

Commit

Permalink
Convert grouped properties to hierarchical properties
Browse files Browse the repository at this point in the history
  • Loading branch information
debovema committed Nov 28, 2018
1 parent c3522ca commit ac5b450
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions consul/consul.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"github.com/TIBCOSoftware/flogo-lib/app"
"github.com/TIBCOSoftware/flogo-lib/logger"
"github.com/hashicorp/consul/api"
"strings"
)

var (
Expand All @@ -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 {
Expand Down

0 comments on commit ac5b450

Please sign in to comment.