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) {
corePP
:=
build
.
postProcessors
[
0
][
0
]
pp
:=
corePP
.
processor
.
(
*
TestPostProcessor
)
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
)
{
...
...
packer/plugin/post_processor.go
View file @
807896d6
...
...
@@ -10,13 +10,13 @@ type cmdPostProcessor struct {
client
*
Client
}
func
(
c
*
cmdPostProcessor
)
Configure
(
config
interface
{})
error
{
func
(
c
*
cmdPostProcessor
)
Configure
(
config
...
interface
{})
error
{
defer
func
()
{
r
:=
recover
()
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
)
{
...
...
packer/plugin/post_processor_test.go
View file @
807896d6
...
...
@@ -8,7 +8,7 @@ import (
type
helperPostProcessor
byte
func
(
helperPostProcessor
)
Configure
(
interface
{})
error
{
func
(
helperPostProcessor
)
Configure
(
...
interface
{})
error
{
return
nil
}
...
...
packer/post_processor.go
View file @
807896d6
...
...
@@ -9,7 +9,7 @@ type PostProcessor interface {
// Configure is responsible for setting up configuration, storing
// the state for later, and returning and errors, such as validation
// errors.
Configure
(
interface
{})
error
Configure
(
...
interface
{})
error
// PostProcess takes a previously created Artifact and produces another
// 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 {
artifactId
string
keep
bool
configCalled
bool
configVal
interface
{}
configVal
[]
interface
{}
ppCalled
bool
ppArtifact
Artifact
ppUi
Ui
}
func
(
pp
*
TestPostProcessor
)
Configure
(
v
interface
{})
error
{
func
(
pp
*
TestPostProcessor
)
Configure
(
v
...
interface
{})
error
{
pp
.
configCalled
=
true
pp
.
configVal
=
v
return
nil
...
...
packer/rpc/post_processor.go
View file @
807896d6
...
...
@@ -17,6 +17,10 @@ type PostProcessorServer struct {
p
packer
.
PostProcessor
}
type
PostProcessorConfigureArgs
struct
{
Configs
[]
interface
{}
}
type
PostProcessorProcessResponse
struct
{
Err
error
Keep
bool
...
...
@@ -26,8 +30,9 @@ type PostProcessorProcessResponse struct {
func
PostProcessor
(
client
*
rpc
.
Client
)
*
postProcessor
{
return
&
postProcessor
{
client
}
}
func
(
p
*
postProcessor
)
Configure
(
raw
interface
{})
(
err
error
)
{
if
cerr
:=
p
.
client
.
Call
(
"PostProcessor.Configure"
,
&
raw
,
&
err
);
cerr
!=
nil
{
func
(
p
*
postProcessor
)
Configure
(
raw
...
interface
{})
(
err
error
)
{
args
:=
&
PostProcessorConfigureArgs
{
Configs
:
raw
}
if
cerr
:=
p
.
client
.
Call
(
"PostProcessor.Configure"
,
args
,
&
err
);
cerr
!=
nil
{
err
=
cerr
}
...
...
@@ -60,8 +65,8 @@ func (p *postProcessor) PostProcess(ui packer.Ui, a packer.Artifact) (packer.Art
return
Artifact
(
client
),
response
.
Keep
,
nil
}
func
(
p
*
PostProcessorServer
)
Configure
(
raw
*
interface
{}
,
reply
*
error
)
error
{
*
reply
=
p
.
p
.
Configure
(
*
raw
)
func
(
p
*
PostProcessorServer
)
Configure
(
args
*
PostProcessorConfigureArgs
,
reply
*
error
)
error
{
*
reply
=
p
.
p
.
Configure
(
args
.
Configs
...
)
if
*
reply
!=
nil
{
*
reply
=
NewBasicError
(
*
reply
)
}
...
...
packer/rpc/post_processor_test.go
View file @
807896d6
...
...
@@ -3,6 +3,7 @@ package rpc
import
(
"github.com/mitchellh/packer/packer"
"net/rpc"
"reflect"
"testing"
)
...
...
@@ -10,13 +11,13 @@ var testPostProcessorArtifact = new(testArtifact)
type
TestPostProcessor
struct
{
configCalled
bool
configVal
interface
{}
configVal
[]
interface
{}
ppCalled
bool
ppArtifact
packer
.
Artifact
ppUi
packer
.
Ui
}
func
(
pp
*
TestPostProcessor
)
Configure
(
v
interface
{})
error
{
func
(
pp
*
TestPostProcessor
)
Configure
(
v
...
interface
{})
error
{
pp
.
configCalled
=
true
pp
.
configVal
=
v
return
nil
...
...
@@ -56,7 +57,7 @@ func TestPostProcessorRPC(t *testing.T) {
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
)
}
...
...
post-processor/vagrant/aws.go
View file @
807896d6
...
...
@@ -24,10 +24,12 @@ type AWSBoxPostProcessor struct {
config
AWSBoxConfig
}
func
(
p
*
AWSBoxPostProcessor
)
Configure
(
raw
interface
{})
error
{
err
:=
mapstructure
.
Decode
(
raw
,
&
p
.
config
)
if
err
!=
nil
{
return
err
func
(
p
*
AWSBoxPostProcessor
)
Configure
(
raws
...
interface
{})
error
{
for
_
,
raw
:=
range
raws
{
err
:=
mapstructure
.
Decode
(
raw
,
&
p
.
config
)
if
err
!=
nil
{
return
err
}
}
return
nil
...
...
post-processor/vagrant/post-processor.go
View file @
807896d6
...
...
@@ -26,23 +26,26 @@ type PostProcessor struct {
premade
map
[
string
]
packer
.
PostProcessor
}
func
(
p
*
PostProcessor
)
Configure
(
raw
interface
{})
error
{
err
:=
mapstructure
.
Decode
(
raw
,
&
p
.
config
)
if
err
!=
nil
{
return
err
func
(
p
*
PostProcessor
)
Configure
(
raws
...
interface
{})
error
{
for
_
,
raw
:=
range
raws
{
err
:=
mapstructure
.
Decode
(
raw
,
&
p
.
config
)
if
err
!=
nil
{
return
err
}
}
if
p
.
config
.
OutputPath
==
""
{
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
{
return
fmt
.
Errorf
(
"output invalid template: %s"
,
err
)
}
// TODO(mitchellh): Properly handle multiple raw configs
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
}
...
...
post-processor/vagrant/virtualbox.go
View file @
807896d6
...
...
@@ -28,10 +28,12 @@ type VBoxBoxPostProcessor struct {
config
VBoxBoxConfig
}
func
(
p
*
VBoxBoxPostProcessor
)
Configure
(
raw
interface
{})
error
{
err
:=
mapstructure
.
Decode
(
raw
,
&
p
.
config
)
if
err
!=
nil
{
return
err
func
(
p
*
VBoxBoxPostProcessor
)
Configure
(
raws
...
interface
{})
error
{
for
_
,
raw
:=
range
raws
{
err
:=
mapstructure
.
Decode
(
raw
,
&
p
.
config
)
if
err
!=
nil
{
return
err
}
}
return
nil
...
...
@@ -179,6 +181,6 @@ func (p *VBoxBoxPostProcessor) renameOVF(dir string) error {
var
defaultVBoxVagrantfile
=
`
Vagrant.configure("2") do |config|
config.vm.base_mac = "{{ .BaseMacAddress }}"
config.vm.base_mac = "{{ .BaseMacAddress }}"
end
`
post-processor/vagrant/vmware.go
View file @
807896d6
...
...
@@ -20,12 +20,15 @@ type VMwareBoxPostProcessor struct {
config
VMwareBoxConfig
}
func
(
p
*
VMwareBoxPostProcessor
)
Configure
(
raw
interface
{})
error
{
err
:=
mapstructure
.
Decode
(
raw
,
&
p
.
config
)
if
err
!=
nil
{
return
err
func
(
p
*
VMwareBoxPostProcessor
)
Configure
(
raws
...
interface
{})
error
{
for
_
,
raw
:=
range
raws
{
err
:=
mapstructure
.
Decode
(
raw
,
&
p
.
config
)
if
err
!=
nil
{
return
err
}
}
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