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:
Vincent Bernat
2024-07-20 14:51:40 +02:00
parent 3812ca7882
commit 0239cd0a9f
8 changed files with 2 additions and 34 deletions

View File

@@ -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)
}

View File

@@ -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,

View File

@@ -134,7 +134,6 @@ func (input graphLineHandlerInput) toSQL1(axis int, options toSQL1Options) strin
dimensionsInterpolate = "emptyArrayString()"
}
// With
withStr := ""
if !options.skipWithClause {

View File

@@ -33,7 +33,6 @@ func (c *Component) fixQueryColumnName(name string) string {
return ""
}
func metricForTopSort(inputUnit string) string {
switch inputUnit {
case "pps":

View File

@@ -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,

View File

@@ -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,

View File

@@ -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)

View File

@@ -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,