Skip to content

Commit

Permalink
fix: fix root input paths and template paths
Browse files Browse the repository at this point in the history
  • Loading branch information
moisespsena committed Apr 25, 2019
1 parent 5c8fcc0 commit 3ff7d41
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
20 changes: 16 additions & 4 deletions config_many.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,15 +159,27 @@ func (i ManyConfigInput) Config(ctx context.Context) (configs []*InputConfig, er
input.NameSpace = i.NameSpace + "/" + input.NameSpace
}

if input.Prefix != "" {
if input.Path[0] == '/' {
// example: /{{.Env.GOROOT}}/a/b
if input.Path[1] == '{' {
input.Path = input.Path[1:]
}
input.Path, _ = input.format(ctx, "Path", input.Path)

if input.Prefix == "_" {
input.Prefix = input.Path
}
} else {
if input.Prefix != "" {
if input.Prefix == "_" {
input.Prefix = input.Path
}

input.Prefix = filepath.Join(i.Prefix, input.Prefix)
}
input.Prefix = filepath.Join(i.Prefix, input.Prefix)
}

input.Path = filepath.Join(i.Path, input.Path)
input.Path = filepath.Join(i.Path, input.Path)
}

if !i.Recursive && input.Recursive {
input.Recursive = false
Expand Down
2 changes: 1 addition & 1 deletion template.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func (i *ManyConfigInput) format(ctx context.Context, key, value string, envs ..
env := Env(append([]map[string]string{ContextEnv(ctx)}, envs...)...)
if strings.ContainsRune(value, '{') {
var t *template.Template
if t, err = template.New("").Parse(key); err != nil {
if t, err = template.New("").Parse(value); err != nil {
return
}
var buf bytes.Buffer
Expand Down

0 comments on commit 3ff7d41

Please sign in to comment.