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
0a6d8ed7
Commit
0a6d8ed7
authored
Jun 06, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: Add errors to Prepare
parent
09f5cd50
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
28 additions
and
13 deletions
+28
-13
packer/plugin/provisioner.go
packer/plugin/provisioner.go
+2
-2
packer/plugin/provisioner_test.go
packer/plugin/provisioner_test.go
+3
-1
packer/provisioner.go
packer/provisioner.go
+1
-1
packer/provisioner_test.go
packer/provisioner_test.go
+2
-1
packer/rpc/provisioner.go
packer/rpc/provisioner.go
+8
-4
packer/rpc/provisioner_test.go
packer/rpc/provisioner_test.go
+2
-1
provisioner/shell/provisioner.go
provisioner/shell/provisioner.go
+6
-2
provisioner/shell/provisioner_test.go
provisioner/shell/provisioner_test.go
+4
-1
No files found.
packer/plugin/provisioner.go
View file @
0a6d8ed7
...
@@ -13,13 +13,13 @@ type cmdProvisioner struct {
...
@@ -13,13 +13,13 @@ type cmdProvisioner struct {
client
*
client
client
*
client
}
}
func
(
c
*
cmdProvisioner
)
Prepare
(
configs
...
interface
{})
{
func
(
c
*
cmdProvisioner
)
Prepare
(
configs
...
interface
{})
error
{
defer
func
()
{
defer
func
()
{
r
:=
recover
()
r
:=
recover
()
c
.
checkExit
(
r
,
nil
)
c
.
checkExit
(
r
,
nil
)
}()
}()
c
.
p
.
Prepare
(
configs
...
)
return
c
.
p
.
Prepare
(
configs
...
)
}
}
func
(
c
*
cmdProvisioner
)
Provision
(
ui
packer
.
Ui
,
comm
packer
.
Communicator
)
{
func
(
c
*
cmdProvisioner
)
Provision
(
ui
packer
.
Ui
,
comm
packer
.
Communicator
)
{
...
...
packer/plugin/provisioner_test.go
View file @
0a6d8ed7
...
@@ -9,7 +9,9 @@ import (
...
@@ -9,7 +9,9 @@ import (
type
helperProvisioner
byte
type
helperProvisioner
byte
func
(
helperProvisioner
)
Prepare
(
...
interface
{})
{}
func
(
helperProvisioner
)
Prepare
(
...
interface
{})
error
{
return
nil
}
func
(
helperProvisioner
)
Provision
(
packer
.
Ui
,
packer
.
Communicator
)
{}
func
(
helperProvisioner
)
Provision
(
packer
.
Ui
,
packer
.
Communicator
)
{}
...
...
packer/provisioner.go
View file @
0a6d8ed7
...
@@ -6,7 +6,7 @@ type Provisioner interface {
...
@@ -6,7 +6,7 @@ type Provisioner interface {
// Prepare is called with a set of configurations to setup the
// Prepare is called with a set of configurations to setup the
// internal state of the provisioner. The multiple configurations
// internal state of the provisioner. The multiple configurations
// should be merged in some sane way.
// should be merged in some sane way.
Prepare
(
...
interface
{})
Prepare
(
...
interface
{})
error
// Provision is called to actually provision the machine. A UI is
// Provision is called to actually provision the machine. A UI is
// given to communicate with the user, and a communicator is given that
// given to communicate with the user, and a communicator is given that
...
...
packer/provisioner_test.go
View file @
0a6d8ed7
...
@@ -8,9 +8,10 @@ type TestProvisioner struct {
...
@@ -8,9 +8,10 @@ type TestProvisioner struct {
provCalled
bool
provCalled
bool
}
}
func
(
t
*
TestProvisioner
)
Prepare
(
configs
...
interface
{})
{
func
(
t
*
TestProvisioner
)
Prepare
(
configs
...
interface
{})
error
{
t
.
prepCalled
=
true
t
.
prepCalled
=
true
t
.
prepConfigs
=
configs
t
.
prepConfigs
=
configs
return
nil
}
}
func
(
t
*
TestProvisioner
)
Provision
(
Ui
,
Communicator
)
{
func
(
t
*
TestProvisioner
)
Provision
(
Ui
,
Communicator
)
{
...
...
packer/rpc/provisioner.go
View file @
0a6d8ed7
...
@@ -28,9 +28,13 @@ type ProvisionerProvisionArgs struct {
...
@@ -28,9 +28,13 @@ type ProvisionerProvisionArgs struct {
func
Provisioner
(
client
*
rpc
.
Client
)
*
provisioner
{
func
Provisioner
(
client
*
rpc
.
Client
)
*
provisioner
{
return
&
provisioner
{
client
}
return
&
provisioner
{
client
}
}
}
func
(
p
*
provisioner
)
Prepare
(
configs
...
interface
{})
{
func
(
p
*
provisioner
)
Prepare
(
configs
...
interface
{})
(
err
error
)
{
args
:=
&
ProvisionerPrepareArgs
{
configs
}
args
:=
&
ProvisionerPrepareArgs
{
configs
}
p
.
client
.
Call
(
"Provisioner.Prepare"
,
args
,
new
(
interface
{}))
if
cerr
:=
p
.
client
.
Call
(
"Provisioner.Prepare"
,
args
,
&
err
);
cerr
!=
nil
{
err
=
cerr
}
return
}
}
func
(
p
*
provisioner
)
Provision
(
ui
packer
.
Ui
,
comm
packer
.
Communicator
)
{
func
(
p
*
provisioner
)
Provision
(
ui
packer
.
Ui
,
comm
packer
.
Communicator
)
{
...
@@ -43,8 +47,8 @@ func (p *provisioner) Provision(ui packer.Ui, comm packer.Communicator) {
...
@@ -43,8 +47,8 @@ func (p *provisioner) Provision(ui packer.Ui, comm packer.Communicator) {
p
.
client
.
Call
(
"Provisioner.Provision"
,
args
,
new
(
interface
{}))
p
.
client
.
Call
(
"Provisioner.Provision"
,
args
,
new
(
interface
{}))
}
}
func
(
p
*
ProvisionerServer
)
Prepare
(
args
*
ProvisionerPrepareArgs
,
reply
*
interface
{}
)
error
{
func
(
p
*
ProvisionerServer
)
Prepare
(
args
*
ProvisionerPrepareArgs
,
reply
*
error
)
error
{
p
.
p
.
Prepare
(
args
.
Configs
...
)
*
reply
=
p
.
p
.
Prepare
(
args
.
Configs
...
)
return
nil
return
nil
}
}
...
...
packer/rpc/provisioner_test.go
View file @
0a6d8ed7
...
@@ -15,9 +15,10 @@ type testProvisioner struct {
...
@@ -15,9 +15,10 @@ type testProvisioner struct {
provUi
packer
.
Ui
provUi
packer
.
Ui
}
}
func
(
p
*
testProvisioner
)
Prepare
(
configs
...
interface
{})
{
func
(
p
*
testProvisioner
)
Prepare
(
configs
...
interface
{})
error
{
p
.
prepareCalled
=
true
p
.
prepareCalled
=
true
p
.
prepareConfigs
=
configs
p
.
prepareConfigs
=
configs
return
nil
}
}
func
(
p
*
testProvisioner
)
Provision
(
ui
packer
.
Ui
,
comm
packer
.
Communicator
)
{
func
(
p
*
testProvisioner
)
Provision
(
ui
packer
.
Ui
,
comm
packer
.
Communicator
)
{
...
...
provisioner/shell/provisioner.go
View file @
0a6d8ed7
...
@@ -29,15 +29,19 @@ type Provisioner struct {
...
@@ -29,15 +29,19 @@ type Provisioner struct {
config
config
config
config
}
}
func
(
p
*
Provisioner
)
Prepare
(
raws
...
interface
{})
{
func
(
p
*
Provisioner
)
Prepare
(
raws
...
interface
{})
error
{
// TODO: errors
// TODO: errors
for
_
,
raw
:=
range
raws
{
for
_
,
raw
:=
range
raws
{
_
=
mapstructure
.
Decode
(
raw
,
&
p
.
config
)
if
err
:=
mapstructure
.
Decode
(
raw
,
&
p
.
config
);
err
!=
nil
{
return
err
}
}
}
if
p
.
config
.
RemotePath
==
""
{
if
p
.
config
.
RemotePath
==
""
{
p
.
config
.
RemotePath
=
DefaultRemotePath
p
.
config
.
RemotePath
=
DefaultRemotePath
}
}
return
nil
}
}
func
(
p
*
Provisioner
)
Provision
(
ui
packer
.
Ui
,
comm
packer
.
Communicator
)
{
func
(
p
*
Provisioner
)
Provision
(
ui
packer
.
Ui
,
comm
packer
.
Communicator
)
{
...
...
provisioner/shell/provisioner_test.go
View file @
0a6d8ed7
...
@@ -17,7 +17,10 @@ func TestProvisionerPrepare_Defaults(t *testing.T) {
...
@@ -17,7 +17,10 @@ func TestProvisionerPrepare_Defaults(t *testing.T) {
raw
:=
map
[
string
]
interface
{}{}
raw
:=
map
[
string
]
interface
{}{}
p
:=
&
Provisioner
{}
p
:=
&
Provisioner
{}
p
.
Prepare
(
raw
,
nil
)
err
:=
p
.
Prepare
(
raw
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
if
p
.
config
.
RemotePath
!=
DefaultRemotePath
{
if
p
.
config
.
RemotePath
!=
DefaultRemotePath
{
t
.
Errorf
(
"unexpected remote path: %s"
,
p
.
config
.
RemotePath
)
t
.
Errorf
(
"unexpected remote path: %s"
,
p
.
config
.
RemotePath
)
...
...
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