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
590997df
Commit
590997df
authored
May 28, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: automatically validate when creating a core
parent
e0a9215e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
14 deletions
+11
-14
command/meta.go
command/meta.go
+0
-5
packer/core.go
packer/core.go
+6
-3
packer/core_test.go
packer/core_test.go
+2
-6
packer/test-fixtures/build-prov-skip.json
packer/test-fixtures/build-prov-skip.json
+3
-0
No files found.
command/meta.go
View file @
590997df
...
...
@@ -49,11 +49,6 @@ func (m *Meta) Core(tpl *template.Template) (*packer.Core, error) {
return
nil
,
fmt
.
Errorf
(
"Error initializing core: %s"
,
err
)
}
// Validate it
if
err
:=
core
.
Validate
();
err
!=
nil
{
return
nil
,
err
}
return
core
,
nil
}
...
...
packer/core.go
View file @
590997df
...
...
@@ -72,6 +72,9 @@ func NewCore(c *CoreConfig) (*Core, error) {
variables
:
c
.
Variables
,
builds
:
builds
,
}
if
err
:=
result
.
validate
();
err
!=
nil
{
return
nil
,
err
}
if
err
:=
result
.
init
();
err
!=
nil
{
return
nil
,
err
}
...
...
@@ -205,11 +208,11 @@ func (c *Core) Build(n string) (Build, error) {
},
nil
}
//
V
alidate does a full validation of the template.
//
v
alidate does a full validation of the template.
//
// This will automatically call template.
V
alidate() in addition to doing
// This will automatically call template.
v
alidate() in addition to doing
// richer semantic checks around variables and so on.
func
(
c
*
Core
)
V
alidate
()
error
{
func
(
c
*
Core
)
v
alidate
()
error
{
// First validate the template in general, we can't do anything else
// unless the template itself is valid.
if
err
:=
c
.
template
.
Validate
();
err
!=
nil
{
...
...
packer/core_test.go
View file @
590997df
...
...
@@ -376,15 +376,11 @@ func TestCoreValidate(t *testing.T) {
t
.
Fatalf
(
"err: %s
\n\n
%s"
,
tc
.
File
,
err
)
}
core
,
err
:
=
NewCore
(
&
CoreConfig
{
_
,
err
=
NewCore
(
&
CoreConfig
{
Template
:
tpl
,
Variables
:
tc
.
Vars
,
})
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s
\n\n
%s"
,
tc
.
File
,
err
)
}
if
err
:=
core
.
Validate
();
(
err
!=
nil
)
!=
tc
.
Err
{
if
(
err
!=
nil
)
!=
tc
.
Err
{
t
.
Fatalf
(
"err: %s
\n\n
%s"
,
tc
.
File
,
err
)
}
}
...
...
packer/test-fixtures/build-prov-skip.json
View file @
590997df
{
"builders"
:
[{
"type"
:
"test"
},
{
"name"
:
"foo"
,
"type"
:
"test"
}],
"provisioners"
:
[{
...
...
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