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) {
...
@@ -49,11 +49,6 @@ func (m *Meta) Core(tpl *template.Template) (*packer.Core, error) {
return
nil
,
fmt
.
Errorf
(
"Error initializing core: %s"
,
err
)
return
nil
,
fmt
.
Errorf
(
"Error initializing core: %s"
,
err
)
}
}
// Validate it
if
err
:=
core
.
Validate
();
err
!=
nil
{
return
nil
,
err
}
return
core
,
nil
return
core
,
nil
}
}
...
...
packer/core.go
View file @
590997df
...
@@ -72,6 +72,9 @@ func NewCore(c *CoreConfig) (*Core, error) {
...
@@ -72,6 +72,9 @@ func NewCore(c *CoreConfig) (*Core, error) {
variables
:
c
.
Variables
,
variables
:
c
.
Variables
,
builds
:
builds
,
builds
:
builds
,
}
}
if
err
:=
result
.
validate
();
err
!=
nil
{
return
nil
,
err
}
if
err
:=
result
.
init
();
err
!=
nil
{
if
err
:=
result
.
init
();
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
@@ -205,11 +208,11 @@ func (c *Core) Build(n string) (Build, error) {
...
@@ -205,11 +208,11 @@ func (c *Core) Build(n string) (Build, error) {
},
nil
},
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.
// 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
// First validate the template in general, we can't do anything else
// unless the template itself is valid.
// unless the template itself is valid.
if
err
:=
c
.
template
.
Validate
();
err
!=
nil
{
if
err
:=
c
.
template
.
Validate
();
err
!=
nil
{
...
...
packer/core_test.go
View file @
590997df
...
@@ -376,15 +376,11 @@ func TestCoreValidate(t *testing.T) {
...
@@ -376,15 +376,11 @@ func TestCoreValidate(t *testing.T) {
t
.
Fatalf
(
"err: %s
\n\n
%s"
,
tc
.
File
,
err
)
t
.
Fatalf
(
"err: %s
\n\n
%s"
,
tc
.
File
,
err
)
}
}
core
,
err
:
=
NewCore
(
&
CoreConfig
{
_
,
err
=
NewCore
(
&
CoreConfig
{
Template
:
tpl
,
Template
:
tpl
,
Variables
:
tc
.
Vars
,
Variables
:
tc
.
Vars
,
})
})
if
err
!=
nil
{
if
(
err
!=
nil
)
!=
tc
.
Err
{
t
.
Fatalf
(
"err: %s
\n\n
%s"
,
tc
.
File
,
err
)
}
if
err
:=
core
.
Validate
();
(
err
!=
nil
)
!=
tc
.
Err
{
t
.
Fatalf
(
"err: %s
\n\n
%s"
,
tc
.
File
,
err
)
t
.
Fatalf
(
"err: %s
\n\n
%s"
,
tc
.
File
,
err
)
}
}
}
}
...
...
packer/test-fixtures/build-prov-skip.json
View file @
590997df
{
{
"builders"
:
[{
"builders"
:
[{
"type"
:
"test"
"type"
:
"test"
},
{
"name"
:
"foo"
,
"type"
:
"test"
}],
}],
"provisioners"
:
[{
"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