package authservice import ( "flag" "fmt" ) const ( defaultRulesEngineHost = "rulesengine" defaultUserServiceHost = "userservice" confUserServiceHost = "ea-user-service-host" confRulesEngineHost = "ea-rules-engine-host" confEdgeAPI = "edge-api" ) // Config is a struct that stores the cli or env flags at runtime. type Config struct { UserServiceHost string RulesEngineHost string EdgeAPI string } // Bind flags updates the flags at runtime when ffparse is called (usually in main) func (config *Config) BindFlags(flags *flag.FlagSet) { flags.StringVar( &config.UserServiceHost, confUserServiceHost, defaultUserServiceHost, "IP address at which user service endpoints are hosted", ) flags.StringVar( &config.RulesEngineHost, confRulesEngineHost, defaultRulesEngineHost, "IP address at which rules engine endpoints are hosted", ) flags.StringVar( &config.EdgeAPI, confEdgeAPI, config.EdgeAPI, "URL of the Edge API to be used to authenticate users.", ) } func (config *Config) Validate() error { if config.EdgeAPI == "" { return fmt.Errorf("edge api url required") } return nil }