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