mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-12 06:24:10 +01:00
common: remove MarshalJSON helpers for mapstructure
They are not needed anymore since we don't exchange configuration files
using JSON, since baac495b9c.
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
package helpers
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"reflect"
|
||||
@@ -234,12 +233,3 @@ func ParametrizedConfigurationMarshalYAML[OuterConfiguration any, InnerConfigura
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// ParametrizedConfigurationMarshalJSON undoes ParametrizedConfigurationUnmarshallerHook().
|
||||
func ParametrizedConfigurationMarshalJSON[OuterConfiguration any, InnerConfiguration any](oc OuterConfiguration, innerConfigurationMap map[string](func() InnerConfiguration)) ([]byte, error) {
|
||||
result, err := ParametrizedConfigurationMarshalYAML(oc, innerConfigurationMap)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return json.Marshal(result)
|
||||
}
|
||||
|
||||
@@ -108,11 +108,6 @@ func (cc CacheConfiguration) MarshalYAML() (interface{}, error) {
|
||||
return helpers.ParametrizedConfigurationMarshalYAML(cc, cacheConfigurationMap)
|
||||
}
|
||||
|
||||
// MarshalJSON undoes ConfigurationUnmarshallerHook().
|
||||
func (cc CacheConfiguration) MarshalJSON() ([]byte, error) {
|
||||
return helpers.ParametrizedConfigurationMarshalJSON(cc, cacheConfigurationMap)
|
||||
}
|
||||
|
||||
var cacheConfigurationMap = map[string](func() CacheBackendConfiguration){
|
||||
"memory": DefaultMemoryCacheConfiguration,
|
||||
"redis": DefaultRedisCacheConfiguration,
|
||||
|
||||
@@ -134,7 +134,6 @@ func (input graphLineHandlerInput) toSQL1(axis int, options toSQL1Options) strin
|
||||
dimensionsInterpolate = "emptyArrayString()"
|
||||
}
|
||||
|
||||
|
||||
// With
|
||||
withStr := ""
|
||||
if !options.skipWithClause {
|
||||
|
||||
@@ -33,7 +33,6 @@ func (c *Component) fixQueryColumnName(name string) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
|
||||
func metricForTopSort(inputUnit string) string {
|
||||
switch inputUnit {
|
||||
case "pps":
|
||||
@@ -41,4 +40,4 @@ func metricForTopSort(inputUnit string) string {
|
||||
default:
|
||||
return "Bytes"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,11 +55,6 @@ func (ic InputConfiguration) MarshalYAML() (interface{}, error) {
|
||||
return helpers.ParametrizedConfigurationMarshalYAML(ic, inputs)
|
||||
}
|
||||
|
||||
// MarshalJSON undoes ConfigurationUnmarshallerHook().
|
||||
func (ic InputConfiguration) MarshalJSON() ([]byte, error) {
|
||||
return helpers.ParametrizedConfigurationMarshalJSON(ic, inputs)
|
||||
}
|
||||
|
||||
var inputs = map[string](func() input.Configuration){
|
||||
"udp": udp.DefaultConfiguration,
|
||||
"file": file.DefaultConfiguration,
|
||||
|
||||
@@ -94,11 +94,6 @@ func (pc ProviderConfiguration) MarshalYAML() (interface{}, error) {
|
||||
return helpers.ParametrizedConfigurationMarshalYAML(pc, providers)
|
||||
}
|
||||
|
||||
// MarshalJSON undoes ConfigurationUnmarshallerHook().
|
||||
func (pc ProviderConfiguration) MarshalJSON() ([]byte, error) {
|
||||
return helpers.ParametrizedConfigurationMarshalJSON(pc, providers)
|
||||
}
|
||||
|
||||
var providers = map[string](func() provider.Configuration){
|
||||
"snmp": snmp.DefaultConfiguration,
|
||||
"gnmi": gnmi.DefaultConfiguration,
|
||||
|
||||
@@ -106,7 +106,7 @@ outer2:
|
||||
iface := state.Interfaces[index]
|
||||
// Set name
|
||||
if iface.Name == "" && len(model.IfNameKeys) > 0 {
|
||||
inner3:
|
||||
inner3:
|
||||
for _, key := range strings.Split(keys, ",") {
|
||||
for _, name := range model.IfNameKeys {
|
||||
pfx := fmt.Sprintf("%s=", name)
|
||||
|
||||
@@ -32,11 +32,6 @@ func (pc ProviderConfiguration) MarshalYAML() (interface{}, error) {
|
||||
return helpers.ParametrizedConfigurationMarshalYAML(pc, providers)
|
||||
}
|
||||
|
||||
// MarshalJSON undoes ConfigurationUnmarshallerHook().
|
||||
func (pc ProviderConfiguration) MarshalJSON() ([]byte, error) {
|
||||
return helpers.ParametrizedConfigurationMarshalJSON(pc, providers)
|
||||
}
|
||||
|
||||
var providers = map[string](func() provider.Configuration){
|
||||
"bmp": bmp.DefaultConfiguration,
|
||||
"bioris": bioris.DefaultConfiguration,
|
||||
|
||||
Reference in New Issue
Block a user