mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 12:40:07 +00:00
fix: config fields not generated on first startup (#1016)
* fix: config fields not generated on first startup * cleanup * fix reference * replace yaml module * remove duplicated fields * remove yaml.v3 as a direct dependency * update dependency * chore
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
||||
"reflect"
|
||||
|
||||
"github.com/go-viper/mapstructure/v2"
|
||||
"sigs.k8s.io/yaml"
|
||||
)
|
||||
|
||||
// TextUnmarshalerHookFunc is a fixed version of mapstructure.TextUnmarshallerHookFunc.
|
||||
@@ -69,3 +70,21 @@ func TextUnmarshalerHookFunc() mapstructure.DecodeHookFuncType {
|
||||
return result, nil
|
||||
}
|
||||
}
|
||||
|
||||
// KubeYAML implements a YAML parser.
|
||||
type KubeYAML struct{}
|
||||
|
||||
// Unmarshal parses the given YAML bytes.
|
||||
func (p *KubeYAML) Unmarshal(b []byte) (map[string]any, error) {
|
||||
var out map[string]any
|
||||
if err := yaml.Unmarshal(b, &out); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Marshal marshals the given config map to YAML bytes.
|
||||
func (p *KubeYAML) Marshal(o map[string]any) ([]byte, error) {
|
||||
return yaml.Marshal(o)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user