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
aa694072
Commit
aa694072
authored
Sep 18, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
post-processor/vagrant: simplify logic, only send overrides to PP
[GH-413] /cc @jasonberanek
parent
6fc89e95
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
25 deletions
+32
-25
post-processor/vagrant/post-processor.go
post-processor/vagrant/post-processor.go
+32
-25
No files found.
post-processor/vagrant/post-processor.go
View file @
aa694072
...
...
@@ -24,15 +24,12 @@ type Config struct {
}
type
PostProcessor
struct
{
config
Config
premade
map
[
string
]
packer
.
PostProcessor
rawConfigs
[
]
interface
{}
config
Config
premade
map
[
string
]
packer
.
PostProcessor
extraConfig
map
[
string
]
interface
{}
}
func
(
p
*
PostProcessor
)
Configure
(
raws
...
interface
{})
error
{
// Store the raw configs for usage later
p
.
rawConfigs
=
raws
_
,
err
:=
common
.
DecodeConfig
(
&
p
.
config
,
raws
...
)
if
err
!=
nil
{
return
err
...
...
@@ -57,11 +54,8 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
}
// Store extra configuration we'll send to each post-processor type
ppExtraConfig
:=
make
(
map
[
string
]
interface
{})
ppExtraConfig
[
"output"
]
=
p
.
config
.
OutputPath
// Store the extra configuration for post-processors
p
.
rawConfigs
=
append
(
p
.
rawConfigs
,
ppExtraConfig
)
p
.
extraConfig
=
make
(
map
[
string
]
interface
{})
p
.
extraConfig
[
"output"
]
=
p
.
config
.
OutputPath
// TODO(mitchellh): Properly handle multiple raw configs. This isn't
// very pressing at the moment because at the time of this comment
...
...
@@ -75,18 +69,14 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
p
.
premade
=
make
(
map
[
string
]
packer
.
PostProcessor
)
for
k
,
raw
:=
range
mapConfig
{
pp
:=
keyToPostProcessor
(
k
)
if
pp
==
nil
{
pp
,
err
:=
p
.
subPostProcessor
(
k
,
raw
,
p
.
extraConfig
)
if
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
err
)
continue
}
// Create the proper list of configurations
ppConfigs
:=
make
([]
interface
{},
len
(
p
.
rawConfigs
),
len
(
p
.
rawConfigs
)
+
1
)
copy
(
ppConfigs
,
p
.
rawConfigs
)
ppConfigs
=
append
(
ppConfigs
,
raw
)
if
err
:=
pp
.
Configure
(
ppConfigs
...
);
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
err
)
if
pp
==
nil
{
continue
}
p
.
premade
[
k
]
=
pp
...
...
@@ -110,20 +100,37 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifact) (pac
pp
,
ok
:=
p
.
premade
[
ppName
]
if
!
ok
{
log
.
Printf
(
"Premade post-processor for '%s' not found. Creating."
,
ppName
)
pp
=
keyToPostProcessor
(
ppName
)
if
pp
==
nil
{
return
nil
,
false
,
fmt
.
Errorf
(
"Vagrant box post-processor not found: %s"
,
ppName
)
}
if
err
:=
pp
.
Configure
(
p
.
rawConfigs
...
);
err
!=
nil
{
var
err
error
pp
,
err
=
p
.
subPostProcessor
(
ppName
,
nil
,
p
.
extraConfig
)
if
err
!=
nil
{
return
nil
,
false
,
err
}
if
pp
==
nil
{
return
nil
,
false
,
fmt
.
Errorf
(
"Vagrant box post-processor not found: %s"
,
ppName
)
}
}
ui
.
Say
(
fmt
.
Sprintf
(
"Creating Vagrant box for '%s' provider"
,
ppName
))
return
pp
.
PostProcess
(
ui
,
artifact
)
}
func
(
p
*
PostProcessor
)
subPostProcessor
(
key
string
,
specific
interface
{},
extra
map
[
string
]
interface
{})
(
packer
.
PostProcessor
,
error
)
{
pp
:=
keyToPostProcessor
(
key
)
if
pp
==
nil
{
return
nil
,
nil
}
if
err
:=
pp
.
Configure
(
extra
,
specific
);
err
!=
nil
{
return
nil
,
err
}
return
pp
,
nil
}
// keyToPostProcessor maps a configuration key to the actual post-processor
// it will be configuring. This returns a new instance of that post-processor.
func
keyToPostProcessor
(
key
string
)
packer
.
PostProcessor
{
switch
key
{
case
"aws"
:
...
...
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