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
229eab06
Commit
229eab06
authored
Aug 09, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common/command: rename BuildFilters to BuildOptions
parent
165ce3b4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
19 deletions
+20
-19
command/build/command.go
command/build/command.go
+4
-4
command/validate/command.go
command/validate/command.go
+4
-4
common/command/build_flags.go
common/command/build_flags.go
+3
-3
common/command/template.go
common/command/template.go
+7
-6
common/command/template_test.go
common/command/template_test.go
+2
-2
No files found.
command/build/command.go
View file @
229eab06
...
...
@@ -22,13 +22,13 @@ func (Command) Help() string {
func
(
c
Command
)
Run
(
env
packer
.
Environment
,
args
[]
string
)
int
{
var
cfgDebug
bool
var
cfgForce
bool
build
Filters
:=
new
(
cmdcommon
.
BuildFilter
s
)
build
Options
:=
new
(
cmdcommon
.
BuildOption
s
)
cmdFlags
:=
flag
.
NewFlagSet
(
"build"
,
flag
.
ContinueOnError
)
cmdFlags
.
Usage
=
func
()
{
env
.
Ui
()
.
Say
(
c
.
Help
())
}
cmdFlags
.
BoolVar
(
&
cfgDebug
,
"debug"
,
false
,
"debug mode for builds"
)
cmdFlags
.
BoolVar
(
&
cfgForce
,
"force"
,
false
,
"force a build if artifacts exist"
)
cmdcommon
.
Build
FilterFlags
(
cmdFlags
,
buildFilter
s
)
cmdcommon
.
Build
OptionFlags
(
cmdFlags
,
buildOption
s
)
if
err
:=
cmdFlags
.
Parse
(
args
);
err
!=
nil
{
return
1
}
...
...
@@ -39,7 +39,7 @@ func (c Command) Run(env packer.Environment, args []string) int {
return
1
}
if
err
:=
build
Filter
s
.
Validate
();
err
!=
nil
{
if
err
:=
build
Option
s
.
Validate
();
err
!=
nil
{
env
.
Ui
()
.
Error
(
err
.
Error
())
env
.
Ui
()
.
Error
(
""
)
env
.
Ui
()
.
Error
(
c
.
Help
())
...
...
@@ -63,7 +63,7 @@ func (c Command) Run(env packer.Environment, args []string) int {
}
// Go through each builder and compile the builds that we care about
builds
,
err
:=
build
Filter
s
.
Builds
(
tpl
,
components
)
builds
,
err
:=
build
Option
s
.
Builds
(
tpl
,
components
)
if
err
!=
nil
{
env
.
Ui
()
.
Error
(
err
.
Error
())
return
1
...
...
command/validate/command.go
View file @
229eab06
...
...
@@ -17,12 +17,12 @@ func (Command) Help() string {
func
(
c
Command
)
Run
(
env
packer
.
Environment
,
args
[]
string
)
int
{
var
cfgSyntaxOnly
bool
build
Filters
:=
new
(
cmdcommon
.
BuildFilter
s
)
build
Options
:=
new
(
cmdcommon
.
BuildOption
s
)
cmdFlags
:=
flag
.
NewFlagSet
(
"validate"
,
flag
.
ContinueOnError
)
cmdFlags
.
Usage
=
func
()
{
env
.
Ui
()
.
Say
(
c
.
Help
())
}
cmdFlags
.
BoolVar
(
&
cfgSyntaxOnly
,
"syntax-only"
,
false
,
"check syntax only"
)
cmdcommon
.
Build
FilterFlags
(
cmdFlags
,
buildFilter
s
)
cmdcommon
.
Build
OptionFlags
(
cmdFlags
,
buildOption
s
)
if
err
:=
cmdFlags
.
Parse
(
args
);
err
!=
nil
{
return
1
}
...
...
@@ -33,7 +33,7 @@ func (c Command) Run(env packer.Environment, args []string) int {
return
1
}
if
err
:=
build
Filter
s
.
Validate
();
err
!=
nil
{
if
err
:=
build
Option
s
.
Validate
();
err
!=
nil
{
env
.
Ui
()
.
Error
(
err
.
Error
())
env
.
Ui
()
.
Error
(
""
)
env
.
Ui
()
.
Error
(
c
.
Help
())
...
...
@@ -64,7 +64,7 @@ func (c Command) Run(env packer.Environment, args []string) int {
}
// Otherwise, get all the builds
builds
,
err
:=
build
Filter
s
.
Builds
(
tpl
,
components
)
builds
,
err
:=
build
Option
s
.
Builds
(
tpl
,
components
)
if
err
!=
nil
{
env
.
Ui
()
.
Error
(
err
.
Error
())
return
1
...
...
common/command/build_flags.go
View file @
229eab06
...
...
@@ -4,9 +4,9 @@ import (
"flag"
)
// Build
Filter
Flags sets the proper command line flags needed for
// build
filter
s.
func
Build
FilterFlags
(
fs
*
flag
.
FlagSet
,
f
*
BuildFilter
s
)
{
// Build
Option
Flags sets the proper command line flags needed for
// build
option
s.
func
Build
OptionFlags
(
fs
*
flag
.
FlagSet
,
f
*
BuildOption
s
)
{
fs
.
Var
((
*
SliceValue
)(
&
f
.
Except
),
"except"
,
"build all builds except these"
)
fs
.
Var
((
*
SliceValue
)(
&
f
.
Only
),
"only"
,
"only build the given builds by name"
)
}
common/command/template.go
View file @
229eab06
...
...
@@ -7,14 +7,15 @@ import (
"log"
)
// BuildFilters is a set of options to filter the builds out of a template.
type
BuildFilters
struct
{
// BuildOptions is a set of options related to builds that can be set
// from the command line.
type
BuildOptions
struct
{
Except
[]
string
Only
[]
string
}
// Validate validates the
filter setting
s
func
(
f
*
Build
Filter
s
)
Validate
()
error
{
// Validate validates the
option
s
func
(
f
*
Build
Option
s
)
Validate
()
error
{
if
len
(
f
.
Except
)
>
0
&&
len
(
f
.
Only
)
>
0
{
return
errors
.
New
(
"Only one of '-except' or '-only' may be specified."
)
}
...
...
@@ -23,8 +24,8 @@ func (f *BuildFilters) Validate() error {
}
// Builds returns the builds out of the given template that pass the
// configured
filter
s.
func
(
f
*
Build
Filter
s
)
Builds
(
t
*
packer
.
Template
,
cf
*
packer
.
ComponentFinder
)
([]
packer
.
Build
,
error
)
{
// configured
option
s.
func
(
f
*
Build
Option
s
)
Builds
(
t
*
packer
.
Template
,
cf
*
packer
.
ComponentFinder
)
([]
packer
.
Build
,
error
)
{
buildNames
:=
t
.
BuildNames
()
builds
:=
make
([]
packer
.
Build
,
0
,
len
(
buildNames
))
for
_
,
buildName
:=
range
buildNames
{
...
...
common/command/template_test.go
View file @
229eab06
...
...
@@ -4,8 +4,8 @@ import (
"testing"
)
func
TestBuild
Filter
sValidate
(
t
*
testing
.
T
)
{
bf
:=
new
(
Build
Filter
s
)
func
TestBuild
Option
sValidate
(
t
*
testing
.
T
)
{
bf
:=
new
(
Build
Option
s
)
err
:=
bf
.
Validate
()
if
err
!=
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