github.com/grafana/pyroscope@v1.18.0/pkg/util/yaml.go (about) 1 // SPDX-License-Identifier: AGPL-3.0-only 2 // Provenance-includes-location: https://github.com/cortexproject/cortex/blob/master/pkg/util/yaml.go 3 // Provenance-includes-license: Apache-2.0 4 // Provenance-includes-copyright: The Cortex Authors. 5 6 package util 7 8 import "gopkg.in/yaml.v3" 9 10 // YAMLMarshalUnmarshal utility function that converts a YAML interface in a map 11 // doing marshal and unmarshal of the parameter 12 func YAMLMarshalUnmarshal(in interface{}) (map[interface{}]interface{}, error) { 13 yamlBytes, err := yaml.Marshal(in) 14 if err != nil { 15 return nil, err 16 } 17 18 object := make(map[interface{}]interface{}) 19 if err := yaml.Unmarshal(yamlBytes, object); err != nil { 20 return nil, err 21 } 22 23 return object, nil 24 }