2022-06-14 07:20:13 +00:00
|
|
|
package validator
|
|
|
|
|
|
|
|
import (
|
2022-07-05 04:43:12 +00:00
|
|
|
"fmt"
|
|
|
|
|
2022-06-14 07:20:13 +00: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 04:43:12 +00:00
|
|
|
if config.Telemetry.Metrics.Address == nil {
|
|
|
|
config.Telemetry.Metrics.Address = schema.DefaultTelemetryConfig.Metrics.Address
|
|
|
|
}
|
|
|
|
|
2023-05-07 05:48:26 +00:00
|
|
|
if err := config.Telemetry.Metrics.Address.ValidateHTTP(); err != nil {
|
|
|
|
validator.Push(fmt.Errorf(errFmtTelemetryMetricsAddress, config.Telemetry.Metrics.Address.String(), err))
|
2022-07-05 04:43:12 +00:00
|
|
|
}
|
|
|
|
|
2023-05-07 05:48:26 +00:00
|
|
|
if config.Telemetry.Metrics.Address.Port() == 0 {
|
|
|
|
config.Telemetry.Metrics.Address.SetPort(schema.DefaultTelemetryConfig.Metrics.Address.Port())
|
2022-06-14 07:20:13 +00:00
|
|
|
}
|
2022-08-08 21:50:12 +00:00
|
|
|
|
|
|
|
if config.Telemetry.Metrics.Buffers.Read <= 0 {
|
|
|
|
config.Telemetry.Metrics.Buffers.Read = schema.DefaultTelemetryConfig.Metrics.Buffers.Read
|
|
|
|
}
|
|
|
|
|
|
|
|
if config.Telemetry.Metrics.Buffers.Write <= 0 {
|
|
|
|
config.Telemetry.Metrics.Buffers.Write = schema.DefaultTelemetryConfig.Metrics.Buffers.Write
|
|
|
|
}
|
|
|
|
|
|
|
|
if config.Telemetry.Metrics.Timeouts.Read <= 0 {
|
|
|
|
config.Telemetry.Metrics.Timeouts.Read = schema.DefaultTelemetryConfig.Metrics.Timeouts.Read
|
|
|
|
}
|
|
|
|
|
|
|
|
if config.Telemetry.Metrics.Timeouts.Write <= 0 {
|
|
|
|
config.Telemetry.Metrics.Timeouts.Write = schema.DefaultTelemetryConfig.Metrics.Timeouts.Write
|
|
|
|
}
|
|
|
|
|
|
|
|
if config.Telemetry.Metrics.Timeouts.Idle <= 0 {
|
|
|
|
config.Telemetry.Metrics.Timeouts.Idle = schema.DefaultTelemetryConfig.Metrics.Timeouts.Idle
|
|
|
|
}
|
2022-06-14 07:20:13 +00:00
|
|
|
}
|