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
4c865477
Commit
4c865477
authored
Aug 22, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common/command: error if only/except points to bad build
parent
9cc4137a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
0 deletions
+44
-0
CHANGELOG.md
CHANGELOG.md
+3
-0
common/command/template.go
common/command/template.go
+21
-0
common/command/template_test.go
common/command/template_test.go
+20
-0
No files found.
CHANGELOG.md
View file @
4c865477
## 0.3.5 (unreleased)
BUG FIXES:
*
command/build,command/validate: If a non-existent build is specified to
'-only' or '-except', it is now an error. [GH-326]
## 0.3.4 (August 21, 2013)
...
...
common/command/template.go
View file @
4c865477
...
...
@@ -65,6 +65,27 @@ func (f *BuildOptions) AllUserVars() (map[string]string, error) {
// configured options.
func
(
f
*
BuildOptions
)
Builds
(
t
*
packer
.
Template
,
cf
*
packer
.
ComponentFinder
)
([]
packer
.
Build
,
error
)
{
buildNames
:=
t
.
BuildNames
()
checks
:=
make
(
map
[
string
][]
string
)
checks
[
"except"
]
=
f
.
Except
checks
[
"only"
]
=
f
.
Only
for
t
,
ns
:=
range
checks
{
for
_
,
n
:=
range
ns
{
found
:=
false
for
_
,
actual
:=
range
buildNames
{
if
actual
==
n
{
found
=
true
break
}
}
if
!
found
{
return
nil
,
fmt
.
Errorf
(
"Unknown build in '%s' flag: %s"
,
t
,
n
)
}
}
}
builds
:=
make
([]
packer
.
Build
,
0
,
len
(
buildNames
))
for
_
,
buildName
:=
range
buildNames
{
if
len
(
f
.
Except
)
>
0
{
...
...
common/command/template_test.go
View file @
4c865477
...
...
@@ -77,6 +77,26 @@ func TestBuildOptionsBuilds_only(t *testing.T) {
}
}
func
TestBuildOptionsBuilds_exceptNonExistent
(
t
*
testing
.
T
)
{
opts
:=
new
(
BuildOptions
)
opts
.
Except
=
[]
string
{
"i-dont-exist"
}
_
,
err
:=
opts
.
Builds
(
testTemplate
())
if
err
==
nil
{
t
.
Fatal
(
"err should not be nil"
)
}
}
func
TestBuildOptionsBuilds_onlyNonExistent
(
t
*
testing
.
T
)
{
opts
:=
new
(
BuildOptions
)
opts
.
Only
=
[]
string
{
"i-dont-exist"
}
_
,
err
:=
opts
.
Builds
(
testTemplate
())
if
err
==
nil
{
t
.
Fatal
(
"err should not be nil"
)
}
}
func
TestBuildOptionsValidate
(
t
*
testing
.
T
)
{
bf
:=
new
(
BuildOptions
)
...
...
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