From 6f747fe0d29f46f63e1b8993cbba9c9534ee8c82 Mon Sep 17 00:00:00 2001 From: Thomas Gazagnaire Date: Wed, 12 Apr 2017 14:09:46 +0200 Subject: [PATCH] better comment in converter for yaml validation Signed-off-by: Thomas Gazagnaire --- src/cmd/moby/config.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cmd/moby/config.go b/src/cmd/moby/config.go index 76a45b02d..7e93a7816 100644 --- a/src/cmd/moby/config.go +++ b/src/cmd/moby/config.go @@ -81,8 +81,10 @@ type MobyImage struct { Sysctl map[string]string } -// recursively convert the map keys from `interface{}` to `string` -// this is needed to convert "yaml" interfaces to "JSON" interfaces +// github.com/go-yaml/yaml treats map keys as interface{} while encoding/json +// requires them to be strings, integers or to implement encoding.TextMarshaler. +// Fix this up by recursively mapping all map[interface{}]interface{} types into +// map[string]interface{}. // see http://stackoverflow.com/questions/40737122/convert-yaml-to-json-without-struct-golang#answer-40737676 func convert(i interface{}) interface{} { switch x := i.(type) {