squash merge from dev branch
This commit is contained in:
32
exporter/config.go
Normal file
32
exporter/config.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package exporter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Devices []Device
|
||||
Logger *zap.SugaredLogger
|
||||
Metrics PromMetrics
|
||||
}
|
||||
|
||||
func (c *Config) FromFlags(device, address, user, password *string) error {
|
||||
if *device == "" || *address == "" || *user == "" || *password == "" {
|
||||
return fmt.Errorf("missing required param for single device configuration")
|
||||
}
|
||||
|
||||
d := &Device{
|
||||
Address: *address,
|
||||
Name: *device,
|
||||
User: *user,
|
||||
Password: *password,
|
||||
}
|
||||
|
||||
*c = Config{
|
||||
Devices: []Device{*d},
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user