template: stores the path
This commit is contained in:
parent
2752e51e09
commit
2b9e52e743
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue