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
6b87c42e
Commit
6b87c42e
authored
Jun 06, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: Change provisioner interface to take array of configs
parent
a7896e7c
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
23 additions
and
42 deletions
+23
-42
packer/build.go
packer/build.go
+1
-1
packer/build_test.go
packer/build_test.go
+1
-2
packer/plugin/provisioner.go
packer/plugin/provisioner.go
+2
-2
packer/plugin/provisioner_test.go
packer/plugin/provisioner_test.go
+1
-1
packer/provisioner.go
packer/provisioner.go
+1
-1
packer/provisioner_test.go
packer/provisioner_test.go
+3
-5
packer/rpc/provisioner.go
packer/rpc/provisioner.go
+4
-16
packer/rpc/provisioner_test.go
packer/rpc/provisioner_test.go
+6
-12
provisioner/shell/provisioner.go
provisioner/shell/provisioner.go
+4
-2
No files found.
packer/build.go
View file @
6b87c42e
...
...
@@ -52,7 +52,7 @@ func (b *coreBuild) Prepare(ui Ui) (err error) {
// Prepare the provisioners
// TODO: error handling
for
_
,
coreProv
:=
range
b
.
provisioners
{
coreProv
.
provisioner
.
Prepare
(
coreProv
.
config
,
ui
)
coreProv
.
provisioner
.
Prepare
(
coreProv
.
config
)
}
return
...
...
packer/build_test.go
View file @
6b87c42e
...
...
@@ -47,8 +47,7 @@ func TestBuild_Prepare(t *testing.T) {
coreProv
:=
coreB
.
provisioners
[
0
]
prov
:=
coreProv
.
provisioner
.
(
*
TestProvisioner
)
assert
.
True
(
prov
.
prepCalled
,
"prepare should be called"
)
assert
.
Equal
(
prov
.
prepConfig
,
42
,
"prepare should be called with proper config"
)
assert
.
Equal
(
prov
.
prepUi
,
ui
,
"prepare should be called with proper ui"
)
assert
.
Equal
(
prov
.
prepConfigs
,
[]
interface
{}{
42
},
"prepare should be called with proper config"
)
}
func
TestBuild_Run
(
t
*
testing
.
T
)
{
...
...
packer/plugin/provisioner.go
View file @
6b87c42e
...
...
@@ -13,13 +13,13 @@ type cmdProvisioner struct {
client
*
client
}
func
(
c
*
cmdProvisioner
)
Prepare
(
config
interface
{},
ui
packer
.
Ui
)
{
func
(
c
*
cmdProvisioner
)
Prepare
(
config
s
...
interface
{}
)
{
defer
func
()
{
r
:=
recover
()
c
.
checkExit
(
r
,
nil
)
}()
c
.
p
.
Prepare
(
config
,
ui
)
c
.
p
.
Prepare
(
config
s
...
)
}
func
(
c
*
cmdProvisioner
)
Provision
(
ui
packer
.
Ui
,
comm
packer
.
Communicator
)
{
...
...
packer/plugin/provisioner_test.go
View file @
6b87c42e
...
...
@@ -9,7 +9,7 @@ import (
type
helperProvisioner
byte
func
(
helperProvisioner
)
Prepare
(
interface
{},
packer
.
Ui
)
{}
func
(
helperProvisioner
)
Prepare
(
...
interface
{}
)
{}
func
(
helperProvisioner
)
Provision
(
packer
.
Ui
,
packer
.
Communicator
)
{}
...
...
packer/provisioner.go
View file @
6b87c42e
...
...
@@ -6,7 +6,7 @@ type Provisioner interface {
// Prepare is called with the raw configuration and a UI element in
// order to setup the internal state of the provisioner and perform
// any validation necessary for the provisioner.
Prepare
(
interface
{},
Ui
)
Prepare
(
...
interface
{}
)
// Provision is called to actually provision the machine. A UI is
// given to communicate with the user, and a communicator is given that
...
...
packer/provisioner_test.go
View file @
6b87c42e
...
...
@@ -4,15 +4,13 @@ import "testing"
type
TestProvisioner
struct
{
prepCalled
bool
prepConfig
interface
{}
prepUi
Ui
prepConfigs
[]
interface
{}
provCalled
bool
}
func
(
t
*
TestProvisioner
)
Prepare
(
config
interface
{},
ui
Ui
)
{
func
(
t
*
TestProvisioner
)
Prepare
(
config
s
...
interface
{}
)
{
t
.
prepCalled
=
true
t
.
prepConfig
=
config
t
.
prepUi
=
ui
t
.
prepConfigs
=
configs
}
func
(
t
*
TestProvisioner
)
Provision
(
Ui
,
Communicator
)
{
...
...
packer/rpc/provisioner.go
View file @
6b87c42e
...
...
@@ -18,8 +18,7 @@ type ProvisionerServer struct {
}
type
ProvisionerPrepareArgs
struct
{
Config
interface
{}
RPCAddress
string
Configs
[]
interface
{}
}
type
ProvisionerProvisionArgs
struct
{
...
...
@@ -29,12 +28,8 @@ type ProvisionerProvisionArgs struct {
func
Provisioner
(
client
*
rpc
.
Client
)
*
provisioner
{
return
&
provisioner
{
client
}
}
func
(
p
*
provisioner
)
Prepare
(
config
interface
{},
ui
packer
.
Ui
)
{
// TODO: Error handling
server
:=
rpc
.
NewServer
()
RegisterUi
(
server
,
ui
)
args
:=
&
ProvisionerPrepareArgs
{
config
,
serveSingleConn
(
server
)}
func
(
p
*
provisioner
)
Prepare
(
configs
...
interface
{})
{
args
:=
&
ProvisionerPrepareArgs
{
configs
}
p
.
client
.
Call
(
"Provisioner.Prepare"
,
args
,
new
(
interface
{}))
}
...
...
@@ -49,14 +44,7 @@ func (p *provisioner) Provision(ui packer.Ui, comm packer.Communicator) {
}
func
(
p
*
ProvisionerServer
)
Prepare
(
args
*
ProvisionerPrepareArgs
,
reply
*
interface
{})
error
{
client
,
err
:=
rpc
.
Dial
(
"tcp"
,
args
.
RPCAddress
)
if
err
!=
nil
{
return
err
}
ui
:=
&
Ui
{
client
}
p
.
p
.
Prepare
(
args
.
Config
,
ui
)
p
.
p
.
Prepare
(
args
.
Configs
...
)
return
nil
}
...
...
packer/rpc/provisioner_test.go
View file @
6b87c42e
...
...
@@ -9,17 +9,15 @@ import (
type
testProvisioner
struct
{
prepareCalled
bool
prepareConfig
interface
{}
prepareUi
packer
.
Ui
prepareConfigs
[]
interface
{}
provCalled
bool
provComm
packer
.
Communicator
provUi
packer
.
Ui
}
func
(
p
*
testProvisioner
)
Prepare
(
config
interface
{},
ui
packer
.
Ui
)
{
func
(
p
*
testProvisioner
)
Prepare
(
config
s
...
interface
{}
)
{
p
.
prepareCalled
=
true
p
.
prepareConfig
=
config
p
.
prepareUi
=
ui
p
.
prepareConfigs
=
configs
}
func
(
p
*
testProvisioner
)
Provision
(
ui
packer
.
Ui
,
comm
packer
.
Communicator
)
{
...
...
@@ -45,17 +43,13 @@ func TestProvisionerRPC(t *testing.T) {
// Test Prepare
config
:=
42
ui
:=
&
testUi
{}
pClient
:=
Provisioner
(
client
)
pClient
.
Prepare
(
config
,
ui
)
pClient
.
Prepare
(
config
)
assert
.
True
(
p
.
prepareCalled
,
"prepare should be called"
)
assert
.
Equal
(
p
.
prepareConfig
,
42
,
"prepare should be called with right arg"
)
p
.
prepareUi
.
Say
(
"foo"
)
assert
.
True
(
ui
.
sayCalled
,
"say should be called"
)
assert
.
Equal
(
p
.
prepareConfigs
,
[]
interface
{}{
42
},
"prepare should be called with right arg"
)
// Test Provision
ui
=
&
testUi
{}
ui
:
=
&
testUi
{}
comm
:=
&
testCommunicator
{}
pClient
.
Provision
(
ui
,
comm
)
assert
.
True
(
p
.
provCalled
,
"provision should be called"
)
...
...
provisioner/shell/provisioner.go
View file @
6b87c42e
...
...
@@ -29,9 +29,11 @@ type Provisioner struct {
config
config
}
func
(
p
*
Provisioner
)
Prepare
(
raw
interface
{},
ui
packer
.
Ui
)
{
func
(
p
*
Provisioner
)
Prepare
(
raw
s
...
interface
{}
)
{
// TODO: errors
_
=
mapstructure
.
Decode
(
raw
,
&
p
.
config
)
for
_
,
raw
:=
range
raws
{
_
=
mapstructure
.
Decode
(
raw
,
&
p
.
config
)
}
if
p
.
config
.
RemotePath
==
""
{
p
.
config
.
RemotePath
=
DefaultRemotePath
...
...
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