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
0363a1cd
Commit
0363a1cd
authored
Jul 29, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/virtualbox,vmware: use DownloadableURL
parent
3ae0b2f0
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
188 deletions
+9
-188
CHANGELOG.md
CHANGELOG.md
+3
-0
builder/virtualbox/builder.go
builder/virtualbox/builder.go
+4
-69
builder/virtualbox/builder_test.go
builder/virtualbox/builder_test.go
+0
-56
builder/vmware/builder.go
builder/vmware/builder.go
+2
-35
builder/vmware/builder_test.go
builder/vmware/builder_test.go
+0
-28
No files found.
CHANGELOG.md
View file @
0363a1cd
## 0.2.2 (unreleased)
BUG FIXES:
*
builder/virtualbox,vmware: relative paths work properly as URL
configurations. [GH-215]
## 0.2.1 (July 26, 2013)
...
...
builder/virtualbox/builder.go
View file @
0363a1cd
...
...
@@ -7,7 +7,6 @@ import (
"github.com/mitchellh/packer/builder/common"
"github.com/mitchellh/packer/packer"
"log"
"net/url"
"os"
"os/exec"
"path/filepath"
...
...
@@ -153,42 +152,10 @@ func (b *Builder) Prepare(raws ...interface{}) error {
errs
=
packer
.
MultiErrorAppend
(
errs
,
errors
.
New
(
"An iso_url must be specified."
))
}
else
{
url
,
err
:=
url
.
Parse
(
b
.
config
.
ISOUrl
)
b
.
config
.
ISOUrl
,
err
=
common
.
DownloadableURL
(
b
.
config
.
ISOUrl
)
if
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"iso_url is not a valid URL: %s"
,
err
))
}
else
{
if
url
.
Scheme
==
""
{
url
.
Scheme
=
"file"
}
if
url
.
Scheme
==
"file"
{
if
_
,
err
:=
os
.
Stat
(
url
.
Path
);
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"iso_url points to bad file: %s"
,
err
))
}
}
else
{
supportedSchemes
:=
[]
string
{
"file"
,
"http"
,
"https"
}
scheme
:=
strings
.
ToLower
(
url
.
Scheme
)
found
:=
false
for
_
,
supported
:=
range
supportedSchemes
{
if
scheme
==
supported
{
found
=
true
break
}
}
if
!
found
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Unsupported URL scheme in iso_url: %s"
,
scheme
))
}
}
}
if
errs
==
nil
||
len
(
errs
.
Errors
)
==
0
{
// Put the URL back together since we may have modified it
b
.
config
.
ISOUrl
=
url
.
String
()
errs
,
fmt
.
Errorf
(
"iso_url: %s"
,
err
))
}
}
...
...
@@ -197,42 +164,10 @@ func (b *Builder) Prepare(raws ...interface{}) error {
}
if
b
.
config
.
GuestAdditionsURL
!=
""
{
url
,
err
:=
url
.
Parse
(
b
.
config
.
GuestAdditionsURL
)
b
.
config
.
GuestAdditionsURL
,
err
=
common
.
DownloadableURL
(
b
.
config
.
GuestAdditionsURL
)
if
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"guest_additions_url is not a valid URL: %s"
,
err
))
}
else
{
if
url
.
Scheme
==
""
{
url
.
Scheme
=
"file"
}
if
url
.
Scheme
==
"file"
{
if
_
,
err
:=
os
.
Stat
(
url
.
Path
);
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"guest_additions_url points to bad file: %s"
,
err
))
}
}
else
{
supportedSchemes
:=
[]
string
{
"file"
,
"http"
,
"https"
}
scheme
:=
strings
.
ToLower
(
url
.
Scheme
)
found
:=
false
for
_
,
supported
:=
range
supportedSchemes
{
if
scheme
==
supported
{
found
=
true
break
}
}
if
!
found
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Unsupported URL scheme in guest_additions_url: %s"
,
scheme
))
}
}
}
if
errs
==
nil
||
len
(
errs
.
Errors
)
==
0
{
// Put the URL back together since we may have modified it
b
.
config
.
GuestAdditionsURL
=
url
.
String
()
errs
,
fmt
.
Errorf
(
"guest_additions_url: %s"
,
err
))
}
}
...
...
builder/virtualbox/builder_test.go
View file @
0363a1cd
...
...
@@ -209,39 +209,11 @@ func TestBuilderPrepare_GuestAdditionsURL(t *testing.T) {
t
.
Fatalf
(
"should be empty: %s"
,
b
.
config
.
GuestAdditionsURL
)
}
config
[
"guest_additions_url"
]
=
"i/am/a/file/that/doesnt/exist"
err
=
b
.
Prepare
(
config
)
if
err
==
nil
{
t
.
Error
(
"should have error"
)
}
config
[
"guest_additions_url"
]
=
"file:i/am/a/file/that/doesnt/exist"
err
=
b
.
Prepare
(
config
)
if
err
==
nil
{
t
.
Error
(
"should have error"
)
}
config
[
"guest_additions_url"
]
=
"http://www.packer.io"
err
=
b
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Errorf
(
"should not have error: %s"
,
err
)
}
tf
,
err
:=
ioutil
.
TempFile
(
""
,
"packer"
)
if
err
!=
nil
{
t
.
Fatalf
(
"error tempfile: %s"
,
err
)
}
defer
os
.
Remove
(
tf
.
Name
())
config
[
"guest_additions_url"
]
=
tf
.
Name
()
err
=
b
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
if
b
.
config
.
GuestAdditionsURL
!=
"file://"
+
tf
.
Name
()
{
t
.
Fatalf
(
"guest_additions_url should be modified: %s"
,
b
.
config
.
GuestAdditionsURL
)
}
}
func
TestBuilderPrepare_HTTPPort
(
t
*
testing
.
T
)
{
...
...
@@ -347,39 +319,11 @@ func TestBuilderPrepare_ISOUrl(t *testing.T) {
t
.
Fatal
(
"should have error"
)
}
config
[
"iso_url"
]
=
"i/am/a/file/that/doesnt/exist"
err
=
b
.
Prepare
(
config
)
if
err
==
nil
{
t
.
Error
(
"should have error"
)
}
config
[
"iso_url"
]
=
"file:i/am/a/file/that/doesnt/exist"
err
=
b
.
Prepare
(
config
)
if
err
==
nil
{
t
.
Error
(
"should have error"
)
}
config
[
"iso_url"
]
=
"http://www.packer.io"
err
=
b
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Errorf
(
"should not have error: %s"
,
err
)
}
tf
,
err
:=
ioutil
.
TempFile
(
""
,
"packer"
)
if
err
!=
nil
{
t
.
Fatalf
(
"error tempfile: %s"
,
err
)
}
defer
os
.
Remove
(
tf
.
Name
())
config
[
"iso_url"
]
=
tf
.
Name
()
err
=
b
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
if
b
.
config
.
ISOUrl
!=
"file://"
+
tf
.
Name
()
{
t
.
Fatalf
(
"iso_url should be modified: %s"
,
b
.
config
.
ISOUrl
)
}
}
func
TestBuilderPrepare_OutputDir
(
t
*
testing
.
T
)
{
...
...
builder/vmware/builder.go
View file @
0363a1cd
...
...
@@ -8,7 +8,6 @@ import (
"github.com/mitchellh/packer/packer"
"log"
"math/rand"
"net/url"
"os"
"path/filepath"
"strings"
...
...
@@ -150,42 +149,10 @@ func (b *Builder) Prepare(raws ...interface{}) error {
errs
=
packer
.
MultiErrorAppend
(
errs
,
errors
.
New
(
"An iso_url must be specified."
))
}
else
{
url
,
err
:=
url
.
Parse
(
b
.
config
.
ISOUrl
)
b
.
config
.
ISOUrl
,
err
=
common
.
DownloadableURL
(
b
.
config
.
ISOUrl
)
if
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"iso_url is not a valid URL: %s"
,
err
))
}
else
{
if
url
.
Scheme
==
""
{
url
.
Scheme
=
"file"
}
if
url
.
Scheme
==
"file"
{
if
_
,
err
:=
os
.
Stat
(
url
.
Path
);
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"iso_url points to bad file: %s"
,
err
))
}
}
else
{
supportedSchemes
:=
[]
string
{
"file"
,
"http"
,
"https"
}
scheme
:=
strings
.
ToLower
(
url
.
Scheme
)
found
:=
false
for
_
,
supported
:=
range
supportedSchemes
{
if
scheme
==
supported
{
found
=
true
break
}
}
if
!
found
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Unsupported URL scheme in iso_url: %s"
,
scheme
))
}
}
}
if
errs
==
nil
||
len
(
errs
.
Errors
)
==
0
{
// Put the URL back together since we may have modified it
b
.
config
.
ISOUrl
=
url
.
String
()
errs
,
fmt
.
Errorf
(
"iso_url: %s"
,
err
))
}
}
...
...
builder/vmware/builder_test.go
View file @
0363a1cd
...
...
@@ -238,39 +238,11 @@ func TestBuilderPrepare_ISOUrl(t *testing.T) {
t
.
Fatal
(
"should have error"
)
}
config
[
"iso_url"
]
=
"i/am/a/file/that/doesnt/exist"
err
=
b
.
Prepare
(
config
)
if
err
==
nil
{
t
.
Error
(
"should have error"
)
}
config
[
"iso_url"
]
=
"file:i/am/a/file/that/doesnt/exist"
err
=
b
.
Prepare
(
config
)
if
err
==
nil
{
t
.
Error
(
"should have error"
)
}
config
[
"iso_url"
]
=
"http://www.packer.io"
err
=
b
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Errorf
(
"should not have error: %s"
,
err
)
}
tf
,
err
:=
ioutil
.
TempFile
(
""
,
"packer"
)
if
err
!=
nil
{
t
.
Fatalf
(
"error tempfile: %s"
,
err
)
}
defer
os
.
Remove
(
tf
.
Name
())
config
[
"iso_url"
]
=
tf
.
Name
()
err
=
b
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
if
b
.
config
.
ISOUrl
!=
"file://"
+
tf
.
Name
()
{
t
.
Fatalf
(
"iso_url should be modified: %s"
,
b
.
config
.
ISOUrl
)
}
}
func
TestBuilderPrepare_OutputDir
(
t
*
testing
.
T
)
{
...
...
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