Commit bb8d0a5e authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

provisioner/chef-solo: convert []uint8 to string

parent 25638c3e
......@@ -499,6 +499,8 @@ func (p *Provisioner) deepJsonFix(key string, current interface{}) (interface{},
}
return val, nil
case []uint8:
return string(c), nil
case map[interface{}]interface{}:
val := make(map[string]interface{})
for k, v := range c {
......
......@@ -267,7 +267,7 @@ func TestProvisionerPrepare_jsonNested(t *testing.T) {
config := testConfig()
config["json"] = map[string]interface{}{
"foo": map[interface{}]interface{}{
"bar": "baz",
"bar": []uint8("baz"),
},
"bar": []interface{}{
......@@ -281,6 +281,7 @@ func TestProvisionerPrepare_jsonNested(t *testing.T) {
"bFalse": false,
"bTrue": true,
"bNil": nil,
"bStr": []uint8("bar"),
"bInt": 1,
"bFloat": 4.5,
......@@ -291,4 +292,12 @@ func TestProvisionerPrepare_jsonNested(t *testing.T) {
if err != nil {
t.Fatalf("err: %s", err)
}
fooMap := p.config.Json["foo"].(map[string]interface{})
if fooMap["bar"] != "baz" {
t.Fatalf("nope: %#v", fooMap["bar"])
}
if p.config.Json["bStr"] != "bar" {
t.Fatalf("nope: %#v", fooMap["bar"])
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment