From fc595de0fd6af2b9a4ce4978c7484e8047aa5c30 Mon Sep 17 00:00:00 2001 From: Matthew Hooker Date: Wed, 28 Aug 2013 17:35:43 -0700 Subject: [PATCH] clean up and retab. --- packer/config_template_test.go | 24 ++++++++++++------------ provisioner/chef-solo/provisioner.go | 6 ++---- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/packer/config_template_test.go b/packer/config_template_test.go index 817868bbf..7e0ef5d85 100644 --- a/packer/config_template_test.go +++ b/packer/config_template_test.go @@ -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"]) + } } diff --git a/provisioner/chef-solo/provisioner.go b/provisioner/chef-solo/provisioner.go index 05c1836a2..8589070c6 100644 --- a/provisioner/chef-solo/provisioner.go +++ b/provisioner/chef-solo/provisioner.go @@ -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 }