Skip to content

Commit

Permalink
Merge 1ef4e98 into ddc933c
Browse files Browse the repository at this point in the history
  • Loading branch information
alenn-m committed Nov 27, 2018
2 parents ddc933c + 1ef4e98 commit c78d19e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ go:
- tip

before_install:
- go get -u github.com/imdario/mergo
- go get -u github.com/axw/gocov/gocov
- go get -u github.com/mattn/goveralls
- go get -u golang.org/x/tools/cmd/cover
Expand Down
22 changes: 22 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bufio"
"encoding/json"
"fmt"
"github.com/imdario/mergo"
"io"
"io/ioutil"
"os"
Expand Down Expand Up @@ -378,9 +379,30 @@ func (c *Config) LoadConfig(source io.Reader) error {
return err
}
c.applyMissingNames()
c.mergeWildCardEntries()
return nil
}

func (c *Config) mergeWildCardEntries() {
for k, host := range c.Hosts {
if strings.Contains(k, "*") {
continue
}

for key, subHost := range c.Hosts {
if strings.Contains(key, "*") {
tempKey := strings.Replace(key, "*", "", -1)
// if the wildcard matches
if strings.Contains(k, tempKey) {
if err := mergo.Merge(host, subHost); err != nil {
fmt.Println(err.Error())
}
}
}
}
}
}

func (c *Config) applyMissingNames() {
for key, host := range c.Hosts {
if host == nil {
Expand Down

0 comments on commit c78d19e

Please sign in to comment.