Skip to content

Commit

Permalink
Address Madhu's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandr Samylkin committed May 13, 2017
1 parent ef30a68 commit 3677c14
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ func (l *Loader) ResolvePath(relative string) (string, error) {
}

func (l *Loader) baseFiles() []string {
// Order is important: last files override values in the first files.
return []string{_baseFile, l.Environment() + ".yaml"}
}

Expand All @@ -145,7 +146,9 @@ func (l *Loader) YamlProvider() ProviderFunc {
return func() (Provider, error) {
static := NewYAMLProviderFromFiles(false, l.getResolver(), l.getStaticFiles()...)
interpolated := NewYAMLProviderWithExpand(false, l.getResolver(), os.LookupEnv, l.getFiles()...)
return NewProviderGroup("yaml", interpolated, static), nil

// Interpolated files will have higher priority than static.
return NewProviderGroup("yaml", static, interpolated), nil
}
}

Expand Down
6 changes: 3 additions & 3 deletions config/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func NewYAMLProviderFromReader(readers ...io.ReadCloser) Provider {
// and uses the mapping function to interpolated values in the underlying provider.
func NewYAMLProviderFromReaderWithExpand(mapping func(string) (string, bool), readers ...io.ReadCloser) Provider {
p := newYAMLProviderCore(readers...)
p.root.dfs(interpolate(mapping))
p.root.applyOnAllNodes(interpolate(mapping))
return NewCachedProvider(p)
}

Expand Down Expand Up @@ -306,7 +306,7 @@ func (n *yamlNode) Children() []*yamlNode {
return nodes
}

func (n *yamlNode) dfs(expand func(string) string) {
func (n *yamlNode) applyOnAllNodes(expand func(string) string) {
if n == nil {
return
}
Expand All @@ -316,7 +316,7 @@ func (n *yamlNode) dfs(expand func(string) string) {
}

for _, c := range n.Children() {
c.dfs(expand)
c.applyOnAllNodes(expand)
}
}

Expand Down

0 comments on commit 3677c14

Please sign in to comment.