provisioner/chef-solo: convert []uint8 to string
This commit is contained in:
parent
25638c3e04
commit
bb8d0a5e7a
@ -499,6 +499,8 @@ func (p *Provisioner) deepJsonFix(key string, current interface{}) (interface{},
|
|||||||
}
|
}
|
||||||
|
|
||||||
return val, nil
|
return val, nil
|
||||||
|
case []uint8:
|
||||||
|
return string(c), nil
|
||||||
case map[interface{}]interface{}:
|
case map[interface{}]interface{}:
|
||||||
val := make(map[string]interface{})
|
val := make(map[string]interface{})
|
||||||
for k, v := range c {
|
for k, v := range c {
|
||||||
|
@ -267,7 +267,7 @@ func TestProvisionerPrepare_jsonNested(t *testing.T) {
|
|||||||
config := testConfig()
|
config := testConfig()
|
||||||
config["json"] = map[string]interface{}{
|
config["json"] = map[string]interface{}{
|
||||||
"foo": map[interface{}]interface{}{
|
"foo": map[interface{}]interface{}{
|
||||||
"bar": "baz",
|
"bar": []uint8("baz"),
|
||||||
},
|
},
|
||||||
|
|
||||||
"bar": []interface{}{
|
"bar": []interface{}{
|
||||||
@ -281,6 +281,7 @@ func TestProvisionerPrepare_jsonNested(t *testing.T) {
|
|||||||
"bFalse": false,
|
"bFalse": false,
|
||||||
"bTrue": true,
|
"bTrue": true,
|
||||||
"bNil": nil,
|
"bNil": nil,
|
||||||
|
"bStr": []uint8("bar"),
|
||||||
|
|
||||||
"bInt": 1,
|
"bInt": 1,
|
||||||
"bFloat": 4.5,
|
"bFloat": 4.5,
|
||||||
@ -291,4 +292,12 @@ func TestProvisionerPrepare_jsonNested(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %s", err)
|
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"])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user