metrics: fix review findings
This commit is contained in:
parent
ee659f509f
commit
6a032bfaa2
12 changed files with 141 additions and 115 deletions
|
|
@ -119,6 +119,7 @@ func NewConfig(cfgFile string) (*Config, error) {
|
|||
type Config struct {
|
||||
Default Default `toml:"default" json:"default"`
|
||||
APIServer APIServer `toml:"apiserver,omitempty" json:"apiserver,omitempty"`
|
||||
Metrics Metrics `toml:"metrics,omitempty" json:"metrics,omitempty"`
|
||||
Database Database `toml:"database,omitempty" json:"database,omitempty"`
|
||||
Providers []Provider `toml:"provider,omitempty" json:"provider,omitempty"`
|
||||
Github []Github `toml:"github,omitempty"`
|
||||
|
|
@ -476,30 +477,19 @@ func (t *TLSConfig) Validate() error {
|
|||
return nil
|
||||
}
|
||||
|
||||
type MetricsConfig struct {
|
||||
Port int `toml:"port" json:"port"`
|
||||
Disabled bool `toml:"disabled" json:"disabled"`
|
||||
NoAuth bool `toml:"no_auth" json:"no-auth"`
|
||||
}
|
||||
|
||||
// MetricsBindAddress returns a host:port string.
|
||||
func (a *APIServer) MetricsBindAddress() string {
|
||||
metricsPort := a.MetricsConfig.Port
|
||||
if metricsPort == 0 {
|
||||
metricsPort = 8081
|
||||
}
|
||||
return fmt.Sprintf("%s:%d", a.Bind, metricsPort)
|
||||
type Metrics struct {
|
||||
DisableAuth bool `toml:"disable_auth" json:"disable-auth"`
|
||||
Enable bool `toml:"enable" json:"enable"`
|
||||
}
|
||||
|
||||
// APIServer holds configuration for the API server
|
||||
// worker
|
||||
type APIServer struct {
|
||||
Bind string `toml:"bind" json:"bind"`
|
||||
Port int `toml:"port" json:"port"`
|
||||
UseTLS bool `toml:"use_tls" json:"use-tls"`
|
||||
TLSConfig TLSConfig `toml:"tls" json:"tls"`
|
||||
CORSOrigins []string `toml:"cors_origins" json:"cors-origins"`
|
||||
MetricsConfig MetricsConfig `toml:"metrics" json:"metrics"`
|
||||
Bind string `toml:"bind" json:"bind"`
|
||||
Port int `toml:"port" json:"port"`
|
||||
UseTLS bool `toml:"use_tls" json:"use-tls"`
|
||||
TLSConfig TLSConfig `toml:"tls" json:"tls"`
|
||||
CORSOrigins []string `toml:"cors_origins" json:"cors-origins"`
|
||||
}
|
||||
|
||||
func (a *APIServer) APITLSConfig() (*tls.Config, error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue