Files
athens/pkg/config/proxy.go
Nathaniel Ward ed05805db6 change env var for port to ATHENS_PORT (#839)
* use sys env ATHENS_PORT instead of PORT

* add default port

* validate is not needed since we default a port now. add test for default port
2018-10-31 22:24:54 -04:00

26 lines
1.0 KiB
Go

package config
// ProxyConfig specifies the properties required to run the proxy
type ProxyConfig struct {
StorageType string `validate:"required" envconfig:"ATHENS_STORAGE_TYPE"`
GlobalEndpoint string `envconfig:"ATHENS_GLOBAL_ENDPOINT"` // This feature is not yet implemented
Port string `envconfig:"ATHENS_PORT" default:":3000"`
BasicAuthUser string `envconfig:"BASIC_AUTH_USER"`
BasicAuthPass string `envconfig:"BASIC_AUTH_PASS"`
ForceSSL bool `envconfig:"PROXY_FORCE_SSL"`
ValidatorHook string `envconfig:"ATHENS_PROXY_VALIDATOR"`
PathPrefix string `envconfig:"ATHENS_PATH_PREFIX"`
NETRCPath string `envconfig:"ATHENS_NETRC_PATH"`
GithubToken string `envconfig:"ATHENS_GITHUB_TOKEN"`
HGRCPath string `envconfig:"ATHENS_HGRC_PATH"`
}
// BasicAuth returns BasicAuthUser and BasicAuthPassword
// and ok if neither of them are empty
func (p *ProxyConfig) BasicAuth() (user, pass string, ok bool) {
user = p.BasicAuthUser
pass = p.BasicAuthPass
ok = user != "" && pass != ""
return user, pass, ok
}