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
89ab009c
Commit
89ab009c
authored
Dec 22, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
command/fix: add fixer to fix virtualbox to virtualbox-iso
parent
efac7070
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
0 deletions
+98
-0
command/fix/fixer.go
command/fix/fixer.go
+2
-0
command/fix/fixer_virtualbox_rename.go
command/fix/fixer_virtualbox_rename.go
+46
-0
command/fix/fixer_virtualbox_rename_test.go
command/fix/fixer_virtualbox_rename_test.go
+49
-0
command/fix/help.go
command/fix/help.go
+1
-0
No files found.
command/fix/fixer.go
View file @
89ab009c
...
...
@@ -24,6 +24,7 @@ func init() {
"createtime"
:
new
(
FixerCreateTime
),
"pp-vagrant-override"
:
new
(
FixerVagrantPPOverride
),
"virtualbox-gaattach"
:
new
(
FixerVirtualBoxGAAttach
),
"virtualbox-rename"
:
new
(
FixerVirtualBoxRename
),
}
FixerOrder
=
[]
string
{
...
...
@@ -31,5 +32,6 @@ func init() {
"createtime"
,
"virtualbox-gaattach"
,
"pp-vagrant-override"
,
"virtualbox-rename"
,
}
}
command/fix/fixer_virtualbox_rename.go
0 → 100644
View file @
89ab009c
package
fix
import
(
"github.com/mitchellh/mapstructure"
)
// FixerVirtualBoxRename changes "virtualbox" builders to "virtualbox-iso"
type
FixerVirtualBoxRename
struct
{}
func
(
FixerVirtualBoxRename
)
Fix
(
input
map
[
string
]
interface
{})
(
map
[
string
]
interface
{},
error
)
{
// The type we'll decode into; we only care about builders
type
template
struct
{
Builders
[]
map
[
string
]
interface
{}
}
// Decode the input into our structure, if we can
var
tpl
template
if
err
:=
mapstructure
.
Decode
(
input
,
&
tpl
);
err
!=
nil
{
return
nil
,
err
}
for
_
,
builder
:=
range
tpl
.
Builders
{
builderTypeRaw
,
ok
:=
builder
[
"type"
]
if
!
ok
{
continue
}
builderType
,
ok
:=
builderTypeRaw
.
(
string
)
if
!
ok
{
continue
}
if
builderType
!=
"virtualbox"
{
continue
}
builder
[
"type"
]
=
"virtualbox-iso"
}
input
[
"builders"
]
=
tpl
.
Builders
return
input
,
nil
}
func
(
FixerVirtualBoxRename
)
Synopsis
()
string
{
return
`Updates "virtualbox" builders to "virtualbox-iso"`
}
command/fix/fixer_virtualbox_rename_test.go
0 → 100644
View file @
89ab009c
package
fix
import
(
"reflect"
"testing"
)
func
TestFixerVirtualBoxRename_impl
(
t
*
testing
.
T
)
{
var
_
Fixer
=
new
(
FixerVirtualBoxRename
)
}
func
TestFixerVirtualBoxRename_Fix
(
t
*
testing
.
T
)
{
cases
:=
[]
struct
{
Input
map
[
string
]
interface
{}
Expected
map
[
string
]
interface
{}
}{
// No attach field
{
Input
:
map
[
string
]
interface
{}{
"type"
:
"virtualbox"
,
},
Expected
:
map
[
string
]
interface
{}{
"type"
:
"virtualbox-iso"
,
},
},
}
for
_
,
tc
:=
range
cases
{
var
f
FixerVirtualBoxRename
input
:=
map
[
string
]
interface
{}{
"builders"
:
[]
map
[
string
]
interface
{}{
tc
.
Input
},
}
expected
:=
map
[
string
]
interface
{}{
"builders"
:
[]
map
[
string
]
interface
{}{
tc
.
Expected
},
}
output
,
err
:=
f
.
Fix
(
input
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
if
!
reflect
.
DeepEqual
(
output
,
expected
)
{
t
.
Fatalf
(
"unexpected: %#v
\n
expected: %#v
\n
"
,
output
,
expected
)
}
}
}
command/fix/help.go
View file @
89ab009c
...
...
@@ -17,5 +17,6 @@ Fixes that are run:
to use "guest_additions_mode"
pp-vagrant-override Replaces old-style provider overrides for the Vagrant
post-processor to new-style as of Packer 0.5.0.
virtualbox-rename Updates "virtualbox" builders to "virtualbox-iso"
`
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