This commit is contained in:
davidnewhall2 2019-12-17 02:09:30 -08:00
parent d3d420597e
commit da75406310
4 changed files with 13 additions and 5 deletions

4
Gopkg.lock generated
View File

@ -107,11 +107,11 @@
[[projects]]
branch = "master"
digest = "1:7a90fad47972b5ae06013d4685eb2f3007e7c92609a1399d2adf59fe04cd9b63"
digest = "1:331d56d3a24e9b8d203883c28803313af060ca5c350be0a9c0552b43f355ecd8"
name = "golift.io/config"
packages = ["."]
pruneopts = "UT"
revision = "fe642c8392dc00d72ddcc47f05a06096bd5d054b"
revision = "1861b4270bf42ec3ccaf86871aa1cf6742564d0f"
[[projects]]
digest = "1:2883cea734f2766f41ff9c9d4aefccccc53e3d44f5c8b08893b9c218cf666722"

View File

@ -108,14 +108,21 @@ func (u *InputUnifi) checkSites(c *Controller) error {
return nil
}
keep := []string{}
FIRST:
for _, s := range c.Sites {
for _, site := range sites {
if s == site.Name {
keep = append(keep, s)
continue FIRST
}
}
return fmt.Errorf("configured site not found on controller: %v", s)
u.LogErrorf("Configured site not found on controller %s: %v", c.Name, s)
}
if c.Sites = keep; len(keep) < 1 {
c.Sites = []string{"all"}
}
return nil

View File

@ -52,7 +52,7 @@ type Metrics struct {
// Config represents the core library input data.
type Config struct {
Poller `json:"poller" toml:"poller" xml:"poller" yaml:"poller"`
*Poller `json:"poller" toml:"poller" xml:"poller" yaml:"poller"`
}
// Poller is the global config values.
@ -103,6 +103,7 @@ func (u *UnifiPoller) ParseConfigs() error {
// parseInterface parses the config file and environment variables into the provided interface.
func (u *UnifiPoller) parseInterface(i interface{}) error {
config.ENVTag = "xml" // xml tag is better formatted for slices.
// Parse config file into provided interface.
if err := config.ParseFile(i, u.Flags.ConfigFile); err != nil {
return err

View File

@ -12,7 +12,7 @@ import (
// New returns a new poller struct.
func New() *UnifiPoller {
return &UnifiPoller{Config: &Config{}, Flags: &Flags{}}
return &UnifiPoller{Config: &Config{Poller: &Poller{}}, Flags: &Flags{}}
}
// Start begins the application from a CLI.