Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
packer
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kristopher Ruzic
packer
Commits
838abe40
Commit
838abe40
authored
Jun 27, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
post-processor/vagrant: validate the template
parent
6f3d0f6b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
2 deletions
+16
-2
post-processor/vagrant/post-processor.go
post-processor/vagrant/post-processor.go
+7
-1
post-processor/vagrant/post-processor_test.go
post-processor/vagrant/post-processor_test.go
+9
-1
No files found.
post-processor/vagrant/post-processor.go
View file @
838abe40
...
...
@@ -8,6 +8,7 @@ import (
"github.com/mitchellh/mapstructure"
"github.com/mitchellh/packer/packer"
"log"
"text/template"
)
var
builtins
=
map
[
string
]
string
{
...
...
@@ -31,7 +32,12 @@ func (p *PostProcessor) Configure(raw interface{}) error {
}
if
p
.
config
.
OutputPath
==
""
{
return
fmt
.
Errorf
(
"`output` must be specified."
)
p
.
config
.
OutputPath
=
"packer_{{.Provider}}.box"
}
_
,
err
=
template
.
New
(
"output"
)
.
Parse
(
p
.
config
.
OutputPath
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"output invalid template: %s"
,
err
)
}
mapConfig
,
ok
:=
raw
.
(
map
[
string
]
interface
{})
...
...
post-processor/vagrant/post-processor_test.go
View file @
838abe40
...
...
@@ -20,10 +20,18 @@ func TestPostProcessor_ImplementsPostProcessor(t *testing.T) {
func
TestBuilderPrepare_OutputPath
(
t
*
testing
.
T
)
{
var
p
PostProcessor
// Default
c
:=
testConfig
()
delete
(
c
,
"output"
)
err
:=
p
.
Configure
(
c
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
// Bad template
c
[
"output"
]
=
"bad {{{{.Template}}}}"
err
=
p
.
Configure
(
c
)
if
err
==
nil
{
t
.
Fatal
f
(
"configure should fail
"
)
t
.
Fatal
(
"should have error
"
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment