fix tests
This commit is contained in:
		
							parent
							
								
									8f68d72a22
								
							
						
					
					
						commit
						a00b626cfa
					
				| 
						 | 
					@ -11,7 +11,7 @@ HBREPO="golift/homebrew-mugs"
 | 
				
			||||||
MAINT="David Newhall II <david at sleepers dot pro>"
 | 
					MAINT="David Newhall II <david at sleepers dot pro>"
 | 
				
			||||||
VENDOR="Go Lift <code at golift dot io>"
 | 
					VENDOR="Go Lift <code at golift dot io>"
 | 
				
			||||||
DESC="Polls a UniFi controller and exports metrics to InfluxDB"
 | 
					DESC="Polls a UniFi controller and exports metrics to InfluxDB"
 | 
				
			||||||
GOLANGCI_LINT_ARGS="--enable-all -D gochecknoglobals -e dupl -e G101"
 | 
					GOLANGCI_LINT_ARGS="--enable-all -D gochecknoglobals -D dupl -D lll -e G101 "
 | 
				
			||||||
# Example must exist at examples/$CONFIG_FILE.example
 | 
					# Example must exist at examples/$CONFIG_FILE.example
 | 
				
			||||||
CONFIG_FILE="up.conf"
 | 
					CONFIG_FILE="up.conf"
 | 
				
			||||||
LICENSE="MIT"
 | 
					LICENSE="MIT"
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -62,8 +62,8 @@ type Config struct {
 | 
				
			||||||
	ReAuth     bool     `json:"reauthenticate" toml:"reauthenticate" xml:"reauthenticate" yaml:"reauthenticate" env:"UP_REAUTHENTICATE"`
 | 
						ReAuth     bool     `json:"reauthenticate" toml:"reauthenticate" xml:"reauthenticate" yaml:"reauthenticate" env:"UP_REAUTHENTICATE"`
 | 
				
			||||||
	Mode       string   `json:"mode" toml:"mode" xml:"mode" yaml:"mode" env:"UP_POLLING_MODE"`
 | 
						Mode       string   `json:"mode" toml:"mode" xml:"mode" yaml:"mode" env:"UP_POLLING_MODE"`
 | 
				
			||||||
	InfluxURL  string   `json:"influx_url,_omitempty" toml:"influx_url,_omitempty" xml:"influx_url" yaml:"influx_url" env:"UP_INFLUX_URL"`
 | 
						InfluxURL  string   `json:"influx_url,_omitempty" toml:"influx_url,_omitempty" xml:"influx_url" yaml:"influx_url" env:"UP_INFLUX_URL"`
 | 
				
			||||||
	InfluxUser string   `json:"influx_user,_omitempty" toml:"influx_user,_omitempty" xml:"influx_user" yaml:"influx_user" env:"UP_INFLUX_USER"`
 | 
						InfluxUser string   `json:"influx_user,_omitempty" toml:"influx_user,_omitempty" xml:"influx_user" yaml:"influx_user" env:"INFLUX_USER"`
 | 
				
			||||||
	InfluxPass string   `json:"influx_pass,_omitempty" toml:"influx_pass,_omitempty" xml:"influx_pass" yaml:"influx_pass" env:"UP_INFLUX_PASS"`
 | 
						InfluxPass string   `json:"influx_pass,_omitempty" toml:"influx_pass,_omitempty" xml:"influx_pass" yaml:"influx_pass" env:"INFLUX_PASS"`
 | 
				
			||||||
	InfluxDB   string   `json:"influx_db,_omitempty" toml:"influx_db,_omitempty" xml:"influx_db" yaml:"influx_db" env:"UP_INFLUX_DB"`
 | 
						InfluxDB   string   `json:"influx_db,_omitempty" toml:"influx_db,_omitempty" xml:"influx_db" yaml:"influx_db" env:"UP_INFLUX_DB"`
 | 
				
			||||||
	UnifiUser  string   `json:"unifi_user,_omitempty" toml:"unifi_user,_omitempty" xml:"unifi_user" yaml:"unifi_user" env:"UP_UNIFI_USER"`
 | 
						UnifiUser  string   `json:"unifi_user,_omitempty" toml:"unifi_user,_omitempty" xml:"unifi_user" yaml:"unifi_user" env:"UP_UNIFI_USER"`
 | 
				
			||||||
	UnifiPass  string   `json:"unifi_pass,_omitempty" toml:"unifi_pass,_omitempty" xml:"unifi_pass" yaml:"unifi_pass" env:"UP_UNIFI_PASS"`
 | 
						UnifiPass  string   `json:"unifi_pass,_omitempty" toml:"unifi_pass,_omitempty" xml:"unifi_pass" yaml:"unifi_pass" env:"UP_UNIFI_PASS"`
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -43,26 +43,3 @@ func (u *UnifiPoller) LogDebugf(m string, v ...interface{}) {
 | 
				
			||||||
func (u *UnifiPoller) LogErrorf(m string, v ...interface{}) {
 | 
					func (u *UnifiPoller) LogErrorf(m string, v ...interface{}) {
 | 
				
			||||||
	_ = log.Output(2, fmt.Sprintf("[ERROR] "+m, v...))
 | 
						_ = log.Output(2, fmt.Sprintf("[ERROR] "+m, v...))
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					 | 
				
			||||||
// pick returns the first non empty string in a list.
 | 
					 | 
				
			||||||
// used in a few places around this library.
 | 
					 | 
				
			||||||
func pick(strings ...string) string {
 | 
					 | 
				
			||||||
	for _, s := range strings {
 | 
					 | 
				
			||||||
		if s != "" {
 | 
					 | 
				
			||||||
			return s
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	return ""
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// parseBool returns true/false if the string is "true" or "false", otherwise returns e value.
 | 
					 | 
				
			||||||
func parseBool(s string, e bool) bool {
 | 
					 | 
				
			||||||
	switch s {
 | 
					 | 
				
			||||||
	case "true", "t":
 | 
					 | 
				
			||||||
		return true
 | 
					 | 
				
			||||||
	case "false", "f":
 | 
					 | 
				
			||||||
		return false
 | 
					 | 
				
			||||||
	default:
 | 
					 | 
				
			||||||
		return e
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue