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
eaf76618
Commit
eaf76618
authored
Dec 19, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
post-processor/vagrant: compression_level is an int
parent
ac36b33f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
12 deletions
+16
-12
post-processor/vagrant/virtualbox.go
post-processor/vagrant/virtualbox.go
+16
-12
No files found.
post-processor/vagrant/virtualbox.go
View file @
eaf76618
...
@@ -13,7 +13,6 @@ import (
...
@@ -13,7 +13,6 @@ import (
"os"
"os"
"path/filepath"
"path/filepath"
"regexp"
"regexp"
"strconv"
)
)
type
VBoxBoxConfig
struct
{
type
VBoxBoxConfig
struct
{
...
@@ -21,7 +20,7 @@ type VBoxBoxConfig struct {
...
@@ -21,7 +20,7 @@ type VBoxBoxConfig struct {
OutputPath
string
`mapstructure:"output"`
OutputPath
string
`mapstructure:"output"`
VagrantfileTemplate
string
`mapstructure:"vagrantfile_template"`
VagrantfileTemplate
string
`mapstructure:"vagrantfile_template"`
CompressionLevel
string
`mapstructure:"compression_level"`
CompressionLevel
int
`mapstructure:"compression_level"`
tpl
*
packer
.
ConfigTemplate
tpl
*
packer
.
ConfigTemplate
}
}
...
@@ -46,13 +45,26 @@ func (p *VBoxBoxPostProcessor) Configure(raws ...interface{}) error {
...
@@ -46,13 +45,26 @@ func (p *VBoxBoxPostProcessor) Configure(raws ...interface{}) error {
}
}
p
.
config
.
tpl
.
UserVars
=
p
.
config
.
PackerUserVars
p
.
config
.
tpl
.
UserVars
=
p
.
config
.
PackerUserVars
// Defaults
found
:=
false
for
_
,
k
:=
range
md
.
Keys
{
println
(
k
)
if
k
==
"compression_level"
{
found
=
true
break
}
}
if
!
found
{
p
.
config
.
CompressionLevel
=
flate
.
DefaultCompression
}
// Accumulate any errors
// Accumulate any errors
errs
:=
common
.
CheckUnusedConfig
(
md
)
errs
:=
common
.
CheckUnusedConfig
(
md
)
validates
:=
map
[
string
]
*
string
{
validates
:=
map
[
string
]
*
string
{
"output"
:
&
p
.
config
.
OutputPath
,
"output"
:
&
p
.
config
.
OutputPath
,
"vagrantfile_template"
:
&
p
.
config
.
VagrantfileTemplate
,
"vagrantfile_template"
:
&
p
.
config
.
VagrantfileTemplate
,
"compression_level"
:
&
p
.
config
.
CompressionLevel
,
}
}
for
n
,
ptr
:=
range
validates
{
for
n
,
ptr
:=
range
validates
{
...
@@ -145,14 +157,6 @@ func (p *VBoxBoxPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifac
...
@@ -145,14 +157,6 @@ func (p *VBoxBoxPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifac
vf
.
Write
([]
byte
(
vagrantfileContents
))
vf
.
Write
([]
byte
(
vagrantfileContents
))
vf
.
Close
()
vf
.
Close
()
var
level
int
=
flate
.
DefaultCompression
if
p
.
config
.
CompressionLevel
!=
""
{
level
,
err
=
strconv
.
Atoi
(
p
.
config
.
CompressionLevel
)
if
err
!=
nil
{
return
nil
,
false
,
err
}
}
// Create the metadata
// Create the metadata
metadata
:=
map
[
string
]
string
{
"provider"
:
"virtualbox"
}
metadata
:=
map
[
string
]
string
{
"provider"
:
"virtualbox"
}
if
err
:=
WriteMetadata
(
dir
,
metadata
);
err
!=
nil
{
if
err
:=
WriteMetadata
(
dir
,
metadata
);
err
!=
nil
{
...
@@ -167,7 +171,7 @@ func (p *VBoxBoxPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifac
...
@@ -167,7 +171,7 @@ func (p *VBoxBoxPostProcessor) PostProcess(ui packer.Ui, artifact packer.Artifac
// Compress the directory to the given output path
// Compress the directory to the given output path
ui
.
Message
(
fmt
.
Sprintf
(
"Compressing box..."
))
ui
.
Message
(
fmt
.
Sprintf
(
"Compressing box..."
))
if
err
:=
DirToBox
(
outputPath
,
dir
,
ui
,
l
evel
);
err
!=
nil
{
if
err
:=
DirToBox
(
outputPath
,
dir
,
ui
,
p
.
config
.
CompressionL
evel
);
err
!=
nil
{
return
nil
,
false
,
err
return
nil
,
false
,
err
}
}
...
...
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