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
a2bf964f
Commit
a2bf964f
authored
May 11, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer/rpc: Properly support hooks
parent
cb1e0cba
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
17 additions
and
5 deletions
+17
-5
builder/amazonebs/builder.go
builder/amazonebs/builder.go
+3
-0
builder/amazonebs/hook.go
builder/amazonebs/hook.go
+4
-0
config.go
config.go
+5
-0
packer.go
packer.go
+1
-0
packer/rpc/environment.go
packer/rpc/environment.go
+4
-5
No files found.
builder/amazonebs/builder.go
View file @
a2bf964f
...
...
@@ -60,6 +60,9 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook) {
MaxCount
:
0
,
}
hook
.
Run
(
HookPreLaunch
,
nil
,
ui
)
return
ui
.
Say
(
"Launching a source AWS instance...
\n
"
)
runResp
,
err
:=
ec2conn
.
RunInstances
(
runOpts
)
if
err
!=
nil
{
...
...
builder/amazonebs/hook.go
0 → 100644
View file @
a2bf964f
package
amazonebs
// This hook is fired prior to launching the EC2 instance.
const
HookPreLaunch
=
"amazonebs_pre_launch"
config.go
View file @
a2bf964f
...
...
@@ -90,3 +90,8 @@ func (c *config) LoadCommand(name string) (packer.Command, error) {
return
plugin
.
Command
(
exec
.
Command
(
commandBin
))
}
func
(
c
*
config
)
LoadHook
(
name
string
)
(
packer
.
Hook
,
error
)
{
log
.
Printf
(
"Loading hook: %s
\n
"
,
name
)
return
plugin
.
Hook
(
exec
.
Command
(
name
))
}
packer.go
View file @
a2bf964f
...
...
@@ -87,6 +87,7 @@ func main() {
envConfig
.
Commands
=
config
.
CommandNames
()
envConfig
.
Components
.
Builder
=
config
.
LoadBuilder
envConfig
.
Components
.
Command
=
config
.
LoadCommand
envConfig
.
Components
.
Hook
=
config
.
LoadHook
env
,
err
:=
packer
.
NewEnvironment
(
envConfig
)
if
err
!=
nil
{
...
...
packer/rpc/environment.go
View file @
a2bf964f
...
...
@@ -50,13 +50,12 @@ func (e *Environment) Hook(name string) (h packer.Hook, err error) {
return
}
_
,
err
=
rpc
.
Dial
(
"tcp"
,
reply
)
client
,
err
:
=
rpc
.
Dial
(
"tcp"
,
reply
)
if
err
!=
nil
{
return
}
// TODO: Hook
h
=
nil
h
=
Hook
(
client
)
return
}
...
...
@@ -89,14 +88,14 @@ func (e *EnvironmentServer) Cli(args *EnvironmentCliArgs, reply *int) (err error
}
func
(
e
*
EnvironmentServer
)
Hook
(
name
*
string
,
reply
*
string
)
error
{
_
,
err
:=
e
.
env
.
Hook
(
*
name
)
hook
,
err
:=
e
.
env
.
Hook
(
*
name
)
if
err
!=
nil
{
return
err
}
// Wrap it
// TODO: Register hook
server
:=
rpc
.
NewServer
()
RegisterHook
(
server
,
hook
)
*
reply
=
serveSingleConn
(
server
)
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