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
807896d6
Commit
807896d6
authored
Jul 01, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
packer: PostProcessor can take multiple configs
parent
944d59af
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
49 additions
and
33 deletions
+49
-33
packer/build_test.go
packer/build_test.go
+1
-1
packer/plugin/post_processor.go
packer/plugin/post_processor.go
+2
-2
packer/plugin/post_processor_test.go
packer/plugin/post_processor_test.go
+1
-1
packer/post_processor.go
packer/post_processor.go
+1
-1
packer/post_processor_test.go
packer/post_processor_test.go
+2
-2
packer/rpc/post_processor.go
packer/rpc/post_processor.go
+9
-4
packer/rpc/post_processor_test.go
packer/rpc/post_processor_test.go
+4
-3
post-processor/vagrant/aws.go
post-processor/vagrant/aws.go
+6
-4
post-processor/vagrant/post-processor.go
post-processor/vagrant/post-processor.go
+9
-6
post-processor/vagrant/virtualbox.go
post-processor/vagrant/virtualbox.go
+7
-5
post-processor/vagrant/vmware.go
post-processor/vagrant/vmware.go
+7
-4
No files found.
packer/build_test.go
View file @
807896d6
...
@@ -59,7 +59,7 @@ func TestBuild_Prepare(t *testing.T) {
...
@@ -59,7 +59,7 @@ func TestBuild_Prepare(t *testing.T) {
corePP
:=
build
.
postProcessors
[
0
][
0
]
corePP
:=
build
.
postProcessors
[
0
][
0
]
pp
:=
corePP
.
processor
.
(
*
TestPostProcessor
)
pp
:=
corePP
.
processor
.
(
*
TestPostProcessor
)
assert
.
True
(
pp
.
configCalled
,
"config should be called"
)
assert
.
True
(
pp
.
configCalled
,
"config should be called"
)
assert
.
Equal
(
pp
.
configVal
,
42
,
"config should have right value"
)
assert
.
Equal
(
pp
.
configVal
,
[]
interface
{}{
42
}
,
"config should have right value"
)
}
}
func
TestBuild_Prepare_Twice
(
t
*
testing
.
T
)
{
func
TestBuild_Prepare_Twice
(
t
*
testing
.
T
)
{
...
...
packer/plugin/post_processor.go
View file @
807896d6
...
@@ -10,13 +10,13 @@ type cmdPostProcessor struct {
...
@@ -10,13 +10,13 @@ type cmdPostProcessor struct {
client
*
Client
client
*
Client
}
}
func
(
c
*
cmdPostProcessor
)
Configure
(
config
interface
{})
error
{
func
(
c
*
cmdPostProcessor
)
Configure
(
config
...
interface
{})
error
{
defer
func
()
{
defer
func
()
{
r
:=
recover
()
r
:=
recover
()
c
.
checkExit
(
r
,
nil
)
c
.
checkExit
(
r
,
nil
)
}()
}()
return
c
.
p
.
Configure
(
config
)
return
c
.
p
.
Configure
(
config
...
)
}
}
func
(
c
*
cmdPostProcessor
)
PostProcess
(
ui
packer
.
Ui
,
a
packer
.
Artifact
)
(
packer
.
Artifact
,
bool
,
error
)
{
func
(
c
*
cmdPostProcessor
)
PostProcess
(
ui
packer
.
Ui
,
a
packer
.
Artifact
)
(
packer
.
Artifact
,
bool
,
error
)
{
...
...
packer/plugin/post_processor_test.go
View file @
807896d6
...
@@ -8,7 +8,7 @@ import (
...
@@ -8,7 +8,7 @@ import (
type
helperPostProcessor
byte
type
helperPostProcessor
byte
func
(
helperPostProcessor
)
Configure
(
interface
{})
error
{
func
(
helperPostProcessor
)
Configure
(
...
interface
{})
error
{
return
nil
return
nil
}
}
...
...
packer/post_processor.go
View file @
807896d6
...
@@ -9,7 +9,7 @@ type PostProcessor interface {
...
@@ -9,7 +9,7 @@ type PostProcessor interface {
// Configure is responsible for setting up configuration, storing
// Configure is responsible for setting up configuration, storing
// the state for later, and returning and errors, such as validation
// the state for later, and returning and errors, such as validation
// errors.
// errors.
Configure
(
interface
{})
error
Configure
(
...
interface
{})
error
// PostProcess takes a previously created Artifact and produces another
// PostProcess takes a previously created Artifact and produces another
// Artifact. If an error occurs, it should return that error. If `keep`
// Artifact. If an error occurs, it should return that error. If `keep`
...
...
packer/post_processor_test.go
View file @
807896d6
...
@@ -4,13 +4,13 @@ type TestPostProcessor struct {
...
@@ -4,13 +4,13 @@ type TestPostProcessor struct {
artifactId
string
artifactId
string
keep
bool
keep
bool
configCalled
bool
configCalled
bool
configVal
interface
{}
configVal
[]
interface
{}
ppCalled
bool
ppCalled
bool
ppArtifact
Artifact
ppArtifact
Artifact
ppUi
Ui
ppUi
Ui
}
}
func
(
pp
*
TestPostProcessor
)
Configure
(
v
interface
{})
error
{
func
(
pp
*
TestPostProcessor
)
Configure
(
v
...
interface
{})
error
{
pp
.
configCalled
=
true
pp
.
configCalled
=
true
pp
.
configVal
=
v
pp
.
configVal
=
v
return
nil
return
nil
...
...
packer/rpc/post_processor.go
View file @
807896d6
...
@@ -17,6 +17,10 @@ type PostProcessorServer struct {
...
@@ -17,6 +17,10 @@ type PostProcessorServer struct {
p
packer
.
PostProcessor
p
packer
.
PostProcessor
}
}
type
PostProcessorConfigureArgs
struct
{
Configs
[]
interface
{}
}
type
PostProcessorProcessResponse
struct
{
type
PostProcessorProcessResponse
struct
{
Err
error
Err
error
Keep
bool
Keep
bool
...
@@ -26,8 +30,9 @@ type PostProcessorProcessResponse struct {
...
@@ -26,8 +30,9 @@ type PostProcessorProcessResponse struct {
func
PostProcessor
(
client
*
rpc
.
Client
)
*
postProcessor
{
func
PostProcessor
(
client
*
rpc
.
Client
)
*
postProcessor
{
return
&
postProcessor
{
client
}
return
&
postProcessor
{
client
}
}
}
func
(
p
*
postProcessor
)
Configure
(
raw
interface
{})
(
err
error
)
{
func
(
p
*
postProcessor
)
Configure
(
raw
...
interface
{})
(
err
error
)
{
if
cerr
:=
p
.
client
.
Call
(
"PostProcessor.Configure"
,
&
raw
,
&
err
);
cerr
!=
nil
{
args
:=
&
PostProcessorConfigureArgs
{
Configs
:
raw
}
if
cerr
:=
p
.
client
.
Call
(
"PostProcessor.Configure"
,
args
,
&
err
);
cerr
!=
nil
{
err
=
cerr
err
=
cerr
}
}
...
@@ -60,8 +65,8 @@ func (p *postProcessor) PostProcess(ui packer.Ui, a packer.Artifact) (packer.Art
...
@@ -60,8 +65,8 @@ func (p *postProcessor) PostProcess(ui packer.Ui, a packer.Artifact) (packer.Art
return
Artifact
(
client
),
response
.
Keep
,
nil
return
Artifact
(
client
),
response
.
Keep
,
nil
}
}
func
(
p
*
PostProcessorServer
)
Configure
(
raw
*
interface
{}
,
reply
*
error
)
error
{
func
(
p
*
PostProcessorServer
)
Configure
(
args
*
PostProcessorConfigureArgs
,
reply
*
error
)
error
{
*
reply
=
p
.
p
.
Configure
(
*
raw
)
*
reply
=
p
.
p
.
Configure
(
args
.
Configs
...
)
if
*
reply
!=
nil
{
if
*
reply
!=
nil
{
*
reply
=
NewBasicError
(
*
reply
)
*
reply
=
NewBasicError
(
*
reply
)
}
}
...
...
packer/rpc/post_processor_test.go
View file @
807896d6
...
@@ -3,6 +3,7 @@ package rpc
...
@@ -3,6 +3,7 @@ package rpc
import
(
import
(
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/packer"
"net/rpc"
"net/rpc"
"reflect"
"testing"
"testing"
)
)
...
@@ -10,13 +11,13 @@ var testPostProcessorArtifact = new(testArtifact)
...
@@ -10,13 +11,13 @@ var testPostProcessorArtifact = new(testArtifact)
type
TestPostProcessor
struct
{
type
TestPostProcessor
struct
{
configCalled
bool
configCalled
bool
configVal
interface
{}
configVal
[]
interface
{}
ppCalled
bool
ppCalled
bool
ppArtifact
packer
.
Artifact
ppArtifact
packer
.
Artifact
ppUi
packer
.
Ui
ppUi
packer
.
Ui
}
}
func
(
pp
*
TestPostProcessor
)
Configure
(
v
interface
{})
error
{
func
(
pp
*
TestPostProcessor
)
Configure
(
v
...
interface
{})
error
{
pp
.
configCalled
=
true
pp
.
configCalled
=
true
pp
.
configVal
=
v
pp
.
configVal
=
v
return
nil
return
nil
...
@@ -56,7 +57,7 @@ func TestPostProcessorRPC(t *testing.T) {
...
@@ -56,7 +57,7 @@ func TestPostProcessorRPC(t *testing.T) {
t
.
Fatal
(
"config should be called"
)
t
.
Fatal
(
"config should be called"
)
}
}
if
p
.
configVal
!=
42
{
if
!
reflect
.
DeepEqual
(
p
.
configVal
,
[]
interface
{}{
42
})
{
t
.
Fatalf
(
"unknown config value: %#v"
,
p
.
configVal
)
t
.
Fatalf
(
"unknown config value: %#v"
,
p
.
configVal
)
}
}
...
...
post-processor/vagrant/aws.go
View file @
807896d6
...
@@ -24,10 +24,12 @@ type AWSBoxPostProcessor struct {
...
@@ -24,10 +24,12 @@ type AWSBoxPostProcessor struct {
config
AWSBoxConfig
config
AWSBoxConfig
}
}
func
(
p
*
AWSBoxPostProcessor
)
Configure
(
raw
interface
{})
error
{
func
(
p
*
AWSBoxPostProcessor
)
Configure
(
raws
...
interface
{})
error
{
err
:=
mapstructure
.
Decode
(
raw
,
&
p
.
config
)
for
_
,
raw
:=
range
raws
{
if
err
!=
nil
{
err
:=
mapstructure
.
Decode
(
raw
,
&
p
.
config
)
return
err
if
err
!=
nil
{
return
err
}
}
}
return
nil
return
nil
...
...
post-processor/vagrant/post-processor.go
View file @
807896d6
...
@@ -26,23 +26,26 @@ type PostProcessor struct {
...
@@ -26,23 +26,26 @@ type PostProcessor struct {
premade
map
[
string
]
packer
.
PostProcessor
premade
map
[
string
]
packer
.
PostProcessor
}
}
func
(
p
*
PostProcessor
)
Configure
(
raw
interface
{})
error
{
func
(
p
*
PostProcessor
)
Configure
(
raws
...
interface
{})
error
{
err
:=
mapstructure
.
Decode
(
raw
,
&
p
.
config
)
for
_
,
raw
:=
range
raws
{
if
err
!=
nil
{
err
:=
mapstructure
.
Decode
(
raw
,
&
p
.
config
)
return
err
if
err
!=
nil
{
return
err
}
}
}
if
p
.
config
.
OutputPath
==
""
{
if
p
.
config
.
OutputPath
==
""
{
p
.
config
.
OutputPath
=
"packer_{{.Provider}}.box"
p
.
config
.
OutputPath
=
"packer_{{.Provider}}.box"
}
}
_
,
err
=
template
.
New
(
"output"
)
.
Parse
(
p
.
config
.
OutputPath
)
_
,
err
:
=
template
.
New
(
"output"
)
.
Parse
(
p
.
config
.
OutputPath
)
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
"output invalid template: %s"
,
err
)
return
fmt
.
Errorf
(
"output invalid template: %s"
,
err
)
}
}
// TODO(mitchellh): Properly handle multiple raw configs
var
mapConfig
map
[
string
]
interface
{}
var
mapConfig
map
[
string
]
interface
{}
if
err
:=
mapstructure
.
Decode
(
raw
,
&
mapConfig
);
err
!=
nil
{
if
err
:=
mapstructure
.
Decode
(
raw
s
[
0
]
,
&
mapConfig
);
err
!=
nil
{
return
err
return
err
}
}
...
...
post-processor/vagrant/virtualbox.go
View file @
807896d6
...
@@ -28,10 +28,12 @@ type VBoxBoxPostProcessor struct {
...
@@ -28,10 +28,12 @@ type VBoxBoxPostProcessor struct {
config
VBoxBoxConfig
config
VBoxBoxConfig
}
}
func
(
p
*
VBoxBoxPostProcessor
)
Configure
(
raw
interface
{})
error
{
func
(
p
*
VBoxBoxPostProcessor
)
Configure
(
raws
...
interface
{})
error
{
err
:=
mapstructure
.
Decode
(
raw
,
&
p
.
config
)
for
_
,
raw
:=
range
raws
{
if
err
!=
nil
{
err
:=
mapstructure
.
Decode
(
raw
,
&
p
.
config
)
return
err
if
err
!=
nil
{
return
err
}
}
}
return
nil
return
nil
...
@@ -179,6 +181,6 @@ func (p *VBoxBoxPostProcessor) renameOVF(dir string) error {
...
@@ -179,6 +181,6 @@ func (p *VBoxBoxPostProcessor) renameOVF(dir string) error {
var
defaultVBoxVagrantfile
=
`
var
defaultVBoxVagrantfile
=
`
Vagrant.configure("2") do |config|
Vagrant.configure("2") do |config|
config.vm.base_mac = "{{ .BaseMacAddress }}"
config.vm.base_mac = "{{ .BaseMacAddress }}"
end
end
`
`
post-processor/vagrant/vmware.go
View file @
807896d6
...
@@ -20,12 +20,15 @@ type VMwareBoxPostProcessor struct {
...
@@ -20,12 +20,15 @@ type VMwareBoxPostProcessor struct {
config
VMwareBoxConfig
config
VMwareBoxConfig
}
}
func
(
p
*
VMwareBoxPostProcessor
)
Configure
(
raw
interface
{})
error
{
func
(
p
*
VMwareBoxPostProcessor
)
Configure
(
raws
...
interface
{})
error
{
err
:=
mapstructure
.
Decode
(
raw
,
&
p
.
config
)
for
_
,
raw
:=
range
raws
{
if
err
!=
nil
{
err
:=
mapstructure
.
Decode
(
raw
,
&
p
.
config
)
return
err
if
err
!=
nil
{
return
err
}
}
}
return
nil
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