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
87e7f17a
Commit
87e7f17a
authored
Jun 04, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
command/build: Add -only flag
parent
ec224771
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
3 deletions
+51
-3
command/build/build.go
command/build/build.go
+4
-0
command/build/command.go
command/build/command.go
+27
-1
command/build/help.go
command/build/help.go
+6
-2
command/build/string_slice_value.go
command/build/string_slice_value.go
+14
-0
No files found.
command/build/build.go
0 → 100644
View file @
87e7f17a
package
build
type
config
struct
{
}
command/build/command.go
View file @
87e7f17a
package
build
import
(
"flag"
"fmt"
"github.com/mitchellh/packer/packer"
"io/ioutil"
...
...
@@ -18,8 +19,18 @@ func (Command) Help() string {
}
func
(
c
Command
)
Run
(
env
packer
.
Environment
,
args
[]
string
)
int
{
var
cfgOnly
[]
string
cmdFlags
:=
flag
.
NewFlagSet
(
"build"
,
flag
.
ContinueOnError
)
cmdFlags
.
Usage
=
func
()
{
env
.
Ui
()
.
Say
(
c
.
Help
())
}
cmdFlags
.
Var
((
*
stringSliceValue
)(
&
cfgOnly
),
"only"
,
"only build the given builds by name"
)
if
err
:=
cmdFlags
.
Parse
(
args
);
err
!=
nil
{
return
1
}
args
=
cmdFlags
.
Args
()
if
len
(
args
)
!=
1
{
env
.
Ui
()
.
Say
(
c
.
Help
()
)
cmdFlags
.
Usage
(
)
return
1
}
...
...
@@ -50,6 +61,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
(
cfgOnly
)
>
0
{
found
:=
false
for
_
,
only
:=
range
cfgOnly
{
if
buildName
==
only
{
found
=
true
break
}
}
if
!
found
{
log
.
Printf
(
"Skipping build '%s' because not specified by -only."
,
buildName
)
continue
}
}
log
.
Printf
(
"Creating build: %s"
,
buildName
)
build
,
err
:=
tpl
.
Build
(
buildName
,
components
)
if
err
!=
nil
{
...
...
command/build/help.go
View file @
87e7f17a
...
...
@@ -3,6 +3,10 @@ package build
const
helpText
=
`
Usage: packer build TEMPLATE
Will execute multiple builds in parallel as defined in the template.
The various artifacts created by the template will be outputted.
Will execute multiple builds in parallel as defined in the template.
The various artifacts created by the template will be outputted.
Options:
-only=foo,bar,baz Only build the given builds by name
`
command/build/string_slice_value.go
0 → 100644
View file @
87e7f17a
package
build
import
"strings"
type
stringSliceValue
[]
string
func
(
s
*
stringSliceValue
)
String
()
string
{
return
strings
.
Join
(
*
s
,
","
)
}
func
(
s
*
stringSliceValue
)
Set
(
value
string
)
error
{
*
s
=
strings
.
Split
(
value
,
","
)
return
nil
}
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