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
079d6f4d
Commit
079d6f4d
authored
Jun 03, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: Introduce Cancel() method to Builder
parent
e21d389f
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
33 additions
and
8 deletions
+33
-8
builder/amazonebs/builder.go
builder/amazonebs/builder.go
+3
-0
packer/builder.go
packer/builder.go
+10
-7
packer/builder_test.go
packer/builder_test.go
+5
-0
packer/plugin/builder.go
packer/plugin/builder.go
+3
-0
packer/plugin/builder_test.go
packer/plugin/builder_test.go
+2
-0
packer/rpc/builder.go
packer/rpc/builder.go
+4
-0
packer/rpc/builder_test.go
packer/rpc/builder_test.go
+5
-0
packer/ui_test.go
packer/ui_test.go
+1
-1
No files found.
builder/amazonebs/builder.go
View file @
079d6f4d
...
...
@@ -102,3 +102,6 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook) packer.Artifact {
// Build the artifact and return it
return
&
artifact
{
state
[
"amis"
]
.
(
map
[
string
]
string
)}
}
func
(
b
*
Builder
)
Cancel
()
{
}
packer/builder.go
View file @
079d6f4d
...
...
@@ -2,14 +2,17 @@ package packer
// Implementers of Builder are responsible for actually building images
// on some platform given some configuration.
//
// Prepare is responsible for reading in some configuration, in the raw form
// of map[string]interface{}, and storing that state for use later. Any setup
// should be done in this method. Note that NO side effects should really take
// place in prepare. It is meant as a state setup step only.
//
// Run is where the actual build should take place. It takes a Build and a Ui.
type
Builder
interface
{
// Prepare is responsible for reading in some configuration, in the raw form
// of map[string]interface{}, and storing that state for use later. Any setup
// should be done in this method. Note that NO side effects should really take
// place in prepare. It is meant as a state setup step only.
Prepare
(
config
interface
{})
error
// Run is where the actual build should take place. It takes a Build and a Ui.
Run
(
ui
Ui
,
hook
Hook
)
Artifact
// Cancel cancels a possibly running Builder. This should block until
// the builder actually cancels and cleans up after itself.
Cancel
()
}
packer/builder_test.go
View file @
079d6f4d
...
...
@@ -6,6 +6,7 @@ type TestBuilder struct {
runCalled
bool
runHook
Hook
runUi
Ui
cancelCalled
bool
}
func
(
tb
*
TestBuilder
)
Prepare
(
config
interface
{})
error
{
...
...
@@ -20,3 +21,7 @@ func (tb *TestBuilder) Run(ui Ui, h Hook) Artifact {
tb
.
runUi
=
ui
return
nil
}
func
(
tb
*
TestBuilder
)
Cancel
()
{
tb
.
cancelCalled
=
true
}
packer/plugin/builder.go
View file @
079d6f4d
...
...
@@ -31,6 +31,9 @@ func (b *cmdBuilder) Run(ui packer.Ui, hook packer.Hook) packer.Artifact {
return
b
.
builder
.
Run
(
ui
,
hook
)
}
func
(
b
*
cmdBuilder
)
Cancel
()
{
}
func
(
c
*
cmdBuilder
)
checkExit
(
p
interface
{},
cb
func
())
{
if
c
.
client
.
Exited
()
&&
cb
!=
nil
{
cb
()
...
...
packer/plugin/builder_test.go
View file @
079d6f4d
...
...
@@ -17,6 +17,8 @@ func (helperBuilder) Run(packer.Ui, packer.Hook) packer.Artifact {
return
nil
}
func
(
helperBuilder
)
Cancel
()
{}
func
TestBuilder_NoExist
(
t
*
testing
.
T
)
{
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
...
...
packer/rpc/builder.go
View file @
079d6f4d
...
...
@@ -60,6 +60,10 @@ func (b *builder) Run(ui packer.Ui, hook packer.Hook) packer.Artifact {
return
Artifact
(
client
)
}
func
(
b
*
builder
)
Cancel
()
{
}
func
(
b
*
BuilderServer
)
Prepare
(
args
*
BuilderPrepareArgs
,
reply
*
error
)
error
{
err
:=
b
.
builder
.
Prepare
(
args
.
Config
)
if
err
!=
nil
{
...
...
packer/rpc/builder_test.go
View file @
079d6f4d
...
...
@@ -15,6 +15,7 @@ type testBuilder struct {
runCalled
bool
runHook
packer
.
Hook
runUi
packer
.
Ui
cancelCalled
bool
}
func
(
b
*
testBuilder
)
Prepare
(
config
interface
{})
error
{
...
...
@@ -30,6 +31,10 @@ func (b *testBuilder) Run(ui packer.Ui, hook packer.Hook) packer.Artifact {
return
testBuilderArtifact
}
func
(
b
*
testBuilder
)
Cancel
()
{
b
.
cancelCalled
=
true
}
func
TestBuilderRPC
(
t
*
testing
.
T
)
{
assert
:=
asserts
.
NewTestingAsserts
(
t
,
true
)
...
...
packer/ui_test.go
View file @
079d6f4d
...
...
@@ -20,7 +20,7 @@ func TestColoredUi(t *testing.T) {
ui
:=
&
ColoredUi
{
UiColorRed
,
bufferUi
}
ui
.
Say
(
"foo"
)
assert
.
Equal
(
readWriter
(
bufferUi
),
"
\0
33[
0
;31;40mfoo
\0
33[0m
\n
"
,
"should have color"
)
assert
.
Equal
(
readWriter
(
bufferUi
),
"
\0
33[
1
;31;40mfoo
\0
33[0m
\n
"
,
"should have color"
)
}
func
TestPrefixedUi
(
t
*
testing
.
T
)
{
...
...
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