feat(agent) multi-driver db monitoring, hot-plug config, release pipeline
This commit is contained in:
45
internal/config/config.go
Normal file
45
internal/config/config.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"os"
|
||||
)
|
||||
|
||||
const DefaultDBConfigPath = "/etc/bugswatch/databases.json"
|
||||
|
||||
type Config struct {
|
||||
Endpoint string
|
||||
AgentID string
|
||||
APIToken string
|
||||
HostID string
|
||||
Env string
|
||||
DBConfigPath string
|
||||
}
|
||||
|
||||
func Load() (Config, error) {
|
||||
dbConfig := os.Getenv("BUGSWATCH_DB_CONFIG")
|
||||
if dbConfig == "" {
|
||||
dbConfig = DefaultDBConfigPath
|
||||
}
|
||||
|
||||
cfg := Config{
|
||||
Endpoint: os.Getenv("BUGSWATCH_ENDPOINT"),
|
||||
AgentID: os.Getenv("BUGSWATCH_AGENT_ID"),
|
||||
APIToken: os.Getenv("BUGSWATCH_API_TOKEN"),
|
||||
HostID: os.Getenv("BUGSWATCH_HOST_ID"),
|
||||
Env: os.Getenv("BUGSWATCH_ENVIRONMENT"),
|
||||
DBConfigPath: dbConfig,
|
||||
}
|
||||
|
||||
if cfg.Endpoint == "" {
|
||||
return Config{}, errors.New("BUGSWATCH_ENDPOINT not set")
|
||||
}
|
||||
if cfg.AgentID == "" {
|
||||
return Config{}, errors.New("BUGSWATCH_AGENT_ID not set")
|
||||
}
|
||||
if cfg.APIToken == "" {
|
||||
return Config{}, errors.New("BUGSWATCH_API_TOKEN not set")
|
||||
}
|
||||
|
||||
return cfg, nil
|
||||
}
|
||||
Reference in New Issue
Block a user