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
c9748b8e
Commit
c9748b8e
authored
Jun 26, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
post-processor/vagrant: the proper post-processor is actually run
parent
f4c9f960
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
3 deletions
+65
-3
post-processor/vagrant/aws_test.go
post-processor/vagrant/aws_test.go
+1
-1
post-processor/vagrant/post-processor.go
post-processor/vagrant/post-processor.go
+35
-2
post-processor/vagrant/post-processor_test.go
post-processor/vagrant/post-processor_test.go
+29
-0
No files found.
post-processor/vagrant/aws_test.go
View file @
c9748b8e
...
...
@@ -5,7 +5,7 @@ import (
"testing"
)
func
TestPostProcessor_ImplementsPostProcessor
(
t
*
testing
.
T
)
{
func
Test
AWSBox
PostProcessor_ImplementsPostProcessor
(
t
*
testing
.
T
)
{
var
raw
interface
{}
raw
=
&
AWSBoxPostProcessor
{}
if
_
,
ok
:=
raw
.
(
packer
.
PostProcessor
);
!
ok
{
...
...
post-processor/vagrant/post-processor.go
View file @
c9748b8e
...
...
@@ -4,6 +4,8 @@
package
vagrant
import
(
"fmt"
"github.com/mitchellh/mapstructure"
"github.com/mitchellh/packer/packer"
)
...
...
@@ -11,16 +13,47 @@ var builtins = map[string]string{
"mitchellh.amazonebs"
:
"aws"
,
}
type
Config
struct
{}
type
Config
struct
{
OutputPath
string
`mapstructure:"output"`
}
type
PostProcessor
struct
{
config
Config
}
func
(
p
*
PostProcessor
)
Configure
(
raw
interface
{})
error
{
err
:=
mapstructure
.
Decode
(
raw
,
&
p
.
config
)
if
err
!=
nil
{
return
err
}
if
p
.
config
.
OutputPath
==
""
{
return
fmt
.
Errorf
(
"`output` must be specified."
)
}
return
nil
}
func
(
p
*
PostProcessor
)
PostProcess
(
ui
packer
.
Ui
,
artifact
packer
.
Artifact
)
(
packer
.
Artifact
,
error
)
{
return
nil
,
nil
ppName
,
ok
:=
builtins
[
artifact
.
BuilderId
()]
if
!
ok
{
return
nil
,
fmt
.
Errorf
(
"Unknown artifact type, can't build box: %s"
,
artifact
.
BuilderId
())
}
// Get the actual PostProcessor implementation for this type
var
pp
packer
.
PostProcessor
switch
ppName
{
case
"aws"
:
pp
=
new
(
AWSBoxPostProcessor
)
default
:
return
nil
,
fmt
.
Errorf
(
"Vagrant box post-processor not found: %s"
,
ppName
)
}
// Prepare and run the post-processor
config
:=
map
[
string
]
string
{
"output"
:
p
.
config
.
OutputPath
}
if
err
:=
pp
.
Configure
(
config
);
err
!=
nil
{
return
nil
,
err
}
return
pp
.
PostProcess
(
ui
,
artifact
)
}
post-processor/vagrant/post-processor_test.go
0 → 100644
View file @
c9748b8e
package
vagrant
import
(
"github.com/mitchellh/packer/packer"
"testing"
)
func
testConfig
()
map
[
string
]
interface
{}
{
return
map
[
string
]
interface
{}{}
}
func
TestPostProcessor_ImplementsPostProcessor
(
t
*
testing
.
T
)
{
var
raw
interface
{}
raw
=
&
PostProcessor
{}
if
_
,
ok
:=
raw
.
(
packer
.
PostProcessor
);
!
ok
{
t
.
Fatalf
(
"AWS PostProcessor should be a PostProcessor"
)
}
}
func
TestBuilderPrepare_OutputPath
(
t
*
testing
.
T
)
{
var
p
PostProcessor
c
:=
testConfig
()
delete
(
c
,
"output"
)
err
:=
p
.
Configure
(
c
)
if
err
==
nil
{
t
.
Fatalf
(
"configure should fail"
)
}
}
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