Commit 2b9e52e7 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

template: stores the path

parent 2752e51e
......@@ -310,5 +310,11 @@ func ParseFile(path string) (*Template, error) {
}
defer f.Close()
return Parse(f)
tpl, err := Parse(f)
if err != nil {
return nil, err
}
tpl.Path = path
return tpl, nil
}
......@@ -272,11 +272,15 @@ func TestParse(t *testing.T) {
}
for _, tc := range cases {
path := fixtureDir(tc.File)
tpl, err := ParseFile(fixtureDir(tc.File))
if (err != nil) != tc.Err {
t.Fatalf("err: %s", err)
}
if tc.Result != nil {
tc.Result.Path = path
}
if tpl != nil {
tpl.RawContents = nil
}
......
......@@ -11,6 +11,10 @@ import (
// Template represents the parsed template that is used to configure
// Packer builds.
type Template struct {
// Path is the path to the template. This will be blank if Parse is
// used, but will be automatically populated by ParseFile.
Path string
Description string
MinVersion string
......
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