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 }