2023-06-30 18:26:27 +02:00
|
|
|
package config
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
type MetricsConfig struct {
|
|
|
|
Enabled InterpolatedBool `yaml:"enabled"`
|
|
|
|
Endpoint InterpolatedString `yaml:"endpoint"`
|
|
|
|
BasicAuth *BasicAuthConfig `yaml:"basicAuth"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type BasicAuthConfig struct {
|
|
|
|
Credentials *InterpolatedMap `yaml:"credentials"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *BasicAuthConfig) CredentialsMap() map[string]string {
|
|
|
|
if c.Credentials == nil {
|
|
|
|
return map[string]string{}
|
|
|
|
}
|
|
|
|
|
2024-05-24 12:31:09 +02:00
|
|
|
credentials := make(map[string]string, len(c.Credentials.Data))
|
2023-06-30 18:26:27 +02:00
|
|
|
|
2024-05-24 12:31:09 +02:00
|
|
|
for k, v := range c.Credentials.Data {
|
2023-06-30 18:26:27 +02:00
|
|
|
credentials[k] = fmt.Sprintf("%v", v)
|
|
|
|
}
|
|
|
|
|
|
|
|
return credentials
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewDefaultMetricsConfig() MetricsConfig {
|
|
|
|
return MetricsConfig{
|
|
|
|
Enabled: true,
|
|
|
|
Endpoint: "/.bouncer/metrics",
|
|
|
|
BasicAuth: nil,
|
|
|
|
}
|
|
|
|
}
|