Files
akvorado/inlet/routing/config.go
Vincent Bernat 0239cd0a9f common: remove MarshalJSON helpers for mapstructure
They are not needed anymore since we don't exchange configuration files
using JSON, since baac495b9c.
2024-07-20 14:51:40 +02:00

44 lines
1.3 KiB
Go

// SPDX-FileCopyrightText: 2022 Free Mobile
// SPDX-License-Identifier: AGPL-3.0-only
package routing
import (
"akvorado/common/helpers"
"akvorado/inlet/routing/provider"
"akvorado/inlet/routing/provider/bioris"
"akvorado/inlet/routing/provider/bmp"
)
// Configuration describes the configuration for the routing client.
type Configuration struct {
// Provider defines the configuration of the provider to use
Provider ProviderConfiguration
}
// DefaultConfiguration represents the default configuration for the routing client.
func DefaultConfiguration() Configuration {
return Configuration{}
}
// ProviderConfiguration represents the configuration for a routing provider.
type ProviderConfiguration struct {
// Config is the actual configuration for the provider.
Config provider.Configuration
}
// MarshalYAML undoes ConfigurationUnmarshallerHook().
func (pc ProviderConfiguration) MarshalYAML() (interface{}, error) {
return helpers.ParametrizedConfigurationMarshalYAML(pc, providers)
}
var providers = map[string](func() provider.Configuration){
"bmp": bmp.DefaultConfiguration,
"bioris": bioris.DefaultConfiguration,
}
func init() {
helpers.RegisterMapstructureUnmarshallerHook(
helpers.ParametrizedConfigurationUnmarshallerHook(ProviderConfiguration{}, providers))
}