Commit 9537f085 authored by Matthew Hooker's avatar Matthew Hooker

clean up and retab.

parent 4b76b2d9
......@@ -56,27 +56,27 @@ func TestJsonTemplateProcess_user(t *testing.T) {
tpl.UserVars["foo"] = "bar"
jsonData := make(map[string]interface{})
jsonData["key"] = map[string]string{
"key1": "{{user `foo`}}",
}
jsonData["key"] = map[string]string{
"key1": "{{user `foo`}}",
}
jsonBytes, err := json.MarshalIndent(jsonData, "", " ")
if err != nil {
t.Fatalf("err: %s", err)
t.Fatalf("err: %s", err)
}
var jsonString = string(jsonBytes)
var jsonString = string(jsonBytes)
result, err := tpl.Process(jsonString, nil)
result, err := tpl.Process(jsonString, nil)
if err != nil {
t.Fatalf("err: %s", err)
}
var dat map[string]map[string]interface{}
if err := json.Unmarshal([]byte(result), &dat); err != nil {
var dat map[string]map[string]interface{}
if err := json.Unmarshal([]byte(result), &dat); err != nil {
t.Fatalf("err: %s", err)
}
}
if dat["key"]["key1"] != "bar" {
t.Fatalf("found %s instead", dat["key"]["key1"])
}
if dat["key"]["key1"] != "bar" {
t.Fatalf("found %s instead", dat["key"]["key1"])
}
}
......
......@@ -235,17 +235,15 @@ func (p *Provisioner) createJson(ui packer.Ui, comm packer.Communicator) (string
if err != nil {
return "", err
}
var jsonString = string(jsonBytes)
println(jsonString)
result, err := p.config.tpl.Process(jsonString, nil)
jsonBytesProcessed, err := p.config.tpl.Process(string(jsonBytes), nil)
if err != nil {
return "", err
}
// Upload the bytes
remotePath := filepath.Join(p.config.StagingDir, "node.json")
if err := comm.Upload(remotePath, bytes.NewReader([]byte(result))); err != nil {
if err := comm.Upload(remotePath, bytes.NewReader([]byte(jsonBytesProcessed))); err != nil {
return "", err
}
......
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