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
b5f4ffa5
Commit
b5f4ffa5
authored
May 26, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
template: OnlyExcept skipping
parent
c12072ec
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
0 deletions
+68
-0
template/template.go
template/template.go
+25
-0
template/template_test.go
template/template_test.go
+43
-0
No files found.
template/template.go
View file @
b5f4ffa5
...
...
@@ -125,6 +125,31 @@ func (t *Template) Validate() error {
return
err
}
// Skip says whether or not to skip the build with the given name.
func
(
o
*
OnlyExcept
)
Skip
(
n
string
)
bool
{
if
len
(
o
.
Only
)
>
0
{
for
_
,
v
:=
range
o
.
Only
{
if
v
==
n
{
return
false
}
}
return
true
}
if
len
(
o
.
Except
)
>
0
{
for
_
,
v
:=
range
o
.
Except
{
if
v
==
n
{
return
true
}
}
return
false
}
return
false
}
// Validate validates that the OnlyExcept settings are correct for a thing.
func
(
o
*
OnlyExcept
)
Validate
(
t
*
Template
)
error
{
if
len
(
o
.
Only
)
>
0
&&
len
(
o
.
Except
)
>
0
{
...
...
template/template_test.go
View file @
b5f4ffa5
...
...
@@ -92,3 +92,46 @@ func TestTemplateValidate(t *testing.T) {
}
}
}
func
TestOnlyExceptSkip
(
t
*
testing
.
T
)
{
cases
:=
[]
struct
{
Only
,
Except
[]
string
Input
string
Result
bool
}{
{
[]
string
{
"foo"
},
nil
,
"foo"
,
false
,
},
{
nil
,
[]
string
{
"foo"
},
"foo"
,
true
,
},
{
nil
,
nil
,
"foo"
,
false
,
},
}
for
_
,
tc
:=
range
cases
{
oe
:=
&
OnlyExcept
{
Only
:
tc
.
Only
,
Except
:
tc
.
Except
,
}
actual
:=
oe
.
Skip
(
tc
.
Input
)
if
actual
!=
tc
.
Result
{
t
.
Fatalf
(
"bad: %#v
\n\n
%#v
\n\n
%#v
\n\n
%#v"
,
actual
,
tc
.
Only
,
tc
.
Except
,
tc
.
Input
)
}
}
}
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