From 2e4dd639124ce787a59f4e7dd915f09810cc85a4 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 21 May 2015 14:44:29 -0600 Subject: [PATCH] template: parse push --- template/parse.go | 11 +++++++++++ template/parse_test.go | 10 ++++++++++ template/test-fixtures/parse-push.json | 5 +++++ 3 files changed, 26 insertions(+) create mode 100644 template/test-fixtures/parse-push.json diff --git a/template/parse.go b/template/parse.go index df29e8af0..c0e21b1c4 100644 --- a/template/parse.go +++ b/template/parse.go @@ -174,6 +174,17 @@ func (r *rawTemplate) Template() (*Template, error) { result.Provisioners = append(result.Provisioners, &p) } + // Push + if len(r.Push) > 0 { + var p Push + if err := r.decoder(&p, nil).Decode(r.Push); err != nil { + errs = multierror.Append(errs, fmt.Errorf( + "push: %s", err)) + } + + result.Push = &p + } + // If we have errors, return those with a nil result if errs != nil { return nil, errs diff --git a/template/parse_test.go b/template/parse_test.go index 3e6847604..023c3d537 100644 --- a/template/parse_test.go +++ b/template/parse_test.go @@ -259,6 +259,16 @@ func TestParse(t *testing.T) { }, false, }, + + { + "parse-push.json", + &Template{ + Push: &Push{ + Name: "foo", + }, + }, + false, + }, } for _, tc := range cases { diff --git a/template/test-fixtures/parse-push.json b/template/test-fixtures/parse-push.json new file mode 100644 index 000000000..2529eedc4 --- /dev/null +++ b/template/test-fixtures/parse-push.json @@ -0,0 +1,5 @@ +{ + "push": { + "name": "foo" + } +}