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
d6b0ff6a
Commit
d6b0ff6a
authored
Jun 13, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
command/build: Add -except flag
parent
760995db
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
command/build/command.go
command/build/command.go
+23
-0
command/build/help.go
command/build/help.go
+1
-0
No files found.
command/build/command.go
View file @
d6b0ff6a
...
...
@@ -20,10 +20,12 @@ func (Command) Help() string {
}
func
(
c
Command
)
Run
(
env
packer
.
Environment
,
args
[]
string
)
int
{
var
cfgExcept
[]
string
var
cfgOnly
[]
string
cmdFlags
:=
flag
.
NewFlagSet
(
"build"
,
flag
.
ContinueOnError
)
cmdFlags
.
Usage
=
func
()
{
env
.
Ui
()
.
Say
(
c
.
Help
())
}
cmdFlags
.
Var
((
*
stringSliceValue
)(
&
cfgExcept
),
"except"
,
"build all builds except these"
)
cmdFlags
.
Var
((
*
stringSliceValue
)(
&
cfgOnly
),
"only"
,
"only build the given builds by name"
)
if
err
:=
cmdFlags
.
Parse
(
args
);
err
!=
nil
{
return
1
...
...
@@ -35,6 +37,12 @@ func (c Command) Run(env packer.Environment, args []string) int {
return
1
}
if
len
(
cfgOnly
)
>
0
&&
len
(
cfgExcept
)
>
0
{
env
.
Ui
()
.
Error
(
"Only one of '-except' or '-only' may be specified.
\n
"
)
env
.
Ui
()
.
Error
(
c
.
Help
())
return
1
}
// Read the file into a byte array so that we can parse the template
log
.
Printf
(
"Reading template: %s"
,
args
[
0
])
tplData
,
err
:=
ioutil
.
ReadFile
(
args
[
0
])
...
...
@@ -62,6 +70,21 @@ func (c Command) Run(env packer.Environment, args []string) int {
buildNames
:=
tpl
.
BuildNames
()
builds
:=
make
([]
packer
.
Build
,
0
,
len
(
buildNames
))
for
_
,
buildName
:=
range
buildNames
{
if
len
(
cfgExcept
)
>
0
{
found
:=
false
for
_
,
only
:=
range
cfgExcept
{
if
buildName
==
only
{
found
=
true
break
}
}
if
found
{
log
.
Printf
(
"Skipping build '%s' because specified by -except."
,
buildName
)
continue
}
}
if
len
(
cfgOnly
)
>
0
{
found
:=
false
for
_
,
only
:=
range
cfgOnly
{
...
...
command/build/help.go
View file @
d6b0ff6a
...
...
@@ -8,5 +8,6 @@ Usage: packer build TEMPLATE
Options:
-except=foo,bar,baz Build all builds other than these
-only=foo,bar,baz Only build the given builds by name
`
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