2022-06-14 14:20:13 +07:00
|
|
|
package validator
|
|
|
|
|
|
|
|
import (
|
2022-07-05 11:43:12 +07:00
|
|
|
"fmt"
|
|
|
|
|
2022-06-14 14:20:13 +07:00
|
|
|
"github.com/authelia/authelia/v4/internal/configuration/schema"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ValidateTelemetry validates the telemetry configuration.
|
|
|
|
func ValidateTelemetry(config *schema.Configuration, validator *schema.StructValidator) {
|
2022-07-05 11:43:12 +07:00
|
|
|
if config.Telemetry.Metrics.Address == nil {
|
|
|
|
config.Telemetry.Metrics.Address = schema.DefaultTelemetryConfig.Metrics.Address
|
|
|
|
}
|
|
|
|
|
|
|
|
switch config.Telemetry.Metrics.Address.Scheme {
|
|
|
|
case "tcp":
|
|
|
|
break
|
|
|
|
default:
|
|
|
|
validator.Push(fmt.Errorf(errFmtTelemetryMetricsScheme, config.Telemetry.Metrics.Address.Scheme))
|
|
|
|
}
|
|
|
|
|
|
|
|
if config.Telemetry.Metrics.Address.Port == 0 {
|
|
|
|
config.Telemetry.Metrics.Address.Port = schema.DefaultTelemetryConfig.Metrics.Address.Port
|
2022-06-14 14:20:13 +07:00
|
|
|
}
|
|
|
|
}
|