Skip to content

Commit

Permalink
Correct Configurations Filtering logic
Browse files Browse the repository at this point in the history
  • Loading branch information
evanpurkhiser committed Jun 7, 2017
1 parent 00cf59b commit 3c8b1b5
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions resolver/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,26 @@ func (c Configurations) Files() []string {
return files
}

// Filter filters down a Configurations list to only configs with the specified prefix
func (c Configurations) Filter(prefix string) Configurations {
// Filter filters down a Configurations list to only configs with the specified prefixes
func (c Configurations) Filter(prefixes []string) Configurations {
if len(prefixes) == 0 {
return c
}

for path := range c {
if !strings.HasPrefix(path, prefix) {
filtered := true

for _, prefix := range prefixes {
if strings.HasPrefix(path, prefix) {
filtered = false
break
}
}

if filtered {
delete(c, path)
}

}

return c
Expand Down

0 comments on commit 3c8b1b5

Please sign in to comment.