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
5371f665
Commit
5371f665
authored
Sep 20, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: verify only one of 'only' or 'except' specified [GH-438]
parent
12ad2cf9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
1 deletion
+66
-1
packer/template.go
packer/template.go
+5
-0
packer/template_test.go
packer/template_test.go
+61
-1
No files found.
packer/template.go
View file @
5371f665
...
...
@@ -554,6 +554,11 @@ func (t *TemplateOnlyExcept) Skip(name string) bool {
// Validates the only/except parameters.
func
(
t
*
TemplateOnlyExcept
)
Validate
(
b
map
[
string
]
RawBuilderConfig
)
(
e
[]
error
)
{
if
len
(
t
.
Only
)
>
0
&&
len
(
t
.
Except
)
>
0
{
e
=
append
(
e
,
fmt
.
Errorf
(
"Only one of 'only' or 'except' may be specified."
))
}
if
len
(
t
.
Only
)
>
0
{
for
_
,
n
:=
range
t
.
Only
{
if
_
,
ok
:=
b
[
n
];
!
ok
{
...
...
packer/template_test.go
View file @
5371f665
...
...
@@ -690,7 +690,67 @@ func TestTemplate_Build(t *testing.T) {
}
}
func
TestTemplateBuild_exeptPPInvalid
(
t
*
testing
.
T
)
{
func
TestTemplateBuild_exceptOnlyPP
(
t
*
testing
.
T
)
{
data
:=
`
{
"builders": [
{
"name": "test1",
"type": "test-builder"
},
{
"name": "test2",
"type": "test-builder"
}
],
"post-processors": [
{
"type": "test-pp",
"except": ["test1"],
"only": ["test1"]
}
]
}
`
_
,
err
:=
ParseTemplate
([]
byte
(
data
))
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
}
func
TestTemplateBuild_exceptOnlyProv
(
t
*
testing
.
T
)
{
data
:=
`
{
"builders": [
{
"name": "test1",
"type": "test-builder"
},
{
"name": "test2",
"type": "test-builder"
}
],
"provisioners": [
{
"type": "test-prov",
"except": ["test1"],
"only": ["test1"]
}
]
}
`
_
,
err
:=
ParseTemplate
([]
byte
(
data
))
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
}
func
TestTemplateBuild_exceptPPInvalid
(
t
*
testing
.
T
)
{
data
:=
`
{
"builders": [
...
...
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