DecodeYAMLLibObject decodes interface format yaml.v2 lib returns map as map[interface{}]interface{} while gohan lib uses map[string]interface{} so we need to convert it here
(yamlData interface{})
| 153 | //yaml.v2 lib returns map as map[interface{}]interface{} while gohan lib uses map[string]interface{} |
| 154 | //so we need to convert it here |
| 155 | func DecodeYAMLLibObject(yamlData interface{}) interface{} { |
| 156 | yamlMap, ok := yamlData.(map[interface{}]interface{}) |
| 157 | if ok { |
| 158 | mapData := map[string]interface{}{} |
| 159 | for key, value := range yamlMap { |
| 160 | mapData[key.(string)] = DecodeYAMLLibObject(value) |
| 161 | } |
| 162 | return mapData |
| 163 | } |
| 164 | yamlList, ok := yamlData.([]interface{}) |
| 165 | if ok { |
| 166 | mapList := []interface{}{} |
| 167 | for _, value := range yamlList { |
| 168 | mapList = append(mapList, DecodeYAMLLibObject(value)) |
| 169 | } |
| 170 | return mapList |
| 171 | } |
| 172 | return yamlData |
| 173 | } |
| 174 | |
| 175 | //GetContent loads file from remote or local |
| 176 | func GetContent(url string) ([]byte, error) { |
no outgoing calls
no test coverage detected