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
819986d1
Commit
819986d1
authored
May 29, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/docker: validate export path is not a dir [GH-2105]
parent
911a868a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
0 deletions
+22
-0
CHANGELOG.md
CHANGELOG.md
+1
-0
builder/docker/config.go
builder/docker/config.go
+8
-0
builder/docker/config_test.go
builder/docker/config_test.go
+13
-0
No files found.
CHANGELOG.md
View file @
819986d1
...
...
@@ -30,6 +30,7 @@ BUG FIXES:
*
builder/docker: Use
`docker exec`
for newer versions of Docker for
running scripts [GH-1993]
*
builder/docker: Fix crash that could occur at certain timed ctrl-c [GH-1838]
*
builder/docker: validate that
`export_path`
is not a directory [GH-2105]
*
builder/qemu: Add
`disk_discard`
option [GH-2120]
*
builder/virtualbox: Added SCSI support
*
builder/vmware: Case-insensitive match of MAC address to find IP [GH-1989]
...
...
builder/docker/config.go
View file @
819986d1
...
...
@@ -2,6 +2,7 @@ package docker
import
(
"fmt"
"os"
"github.com/mitchellh/mapstructure"
"github.com/mitchellh/packer/common"
...
...
@@ -79,6 +80,13 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
fmt
.
Errorf
(
"both commit and export_path cannot be set"
))
}
if
c
.
ExportPath
!=
""
{
if
fi
,
err
:=
os
.
Stat
(
c
.
ExportPath
);
err
==
nil
&&
fi
.
IsDir
()
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"export_path must be a file, not a directory"
))
}
}
if
errs
!=
nil
&&
len
(
errs
.
Errors
)
>
0
{
return
nil
,
nil
,
errs
}
...
...
builder/docker/config_test.go
View file @
819986d1
package
docker
import
(
"io/ioutil"
"os"
"testing"
)
...
...
@@ -42,6 +44,12 @@ func testConfigOk(t *testing.T, warns []string, err error) {
}
func
TestConfigPrepare_exportPath
(
t
*
testing
.
T
)
{
td
,
err
:=
ioutil
.
TempDir
(
""
,
"packer"
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
defer
os
.
RemoveAll
(
td
)
raw
:=
testConfig
()
// No export path
...
...
@@ -53,6 +61,11 @@ func TestConfigPrepare_exportPath(t *testing.T) {
raw
[
"export_path"
]
=
"good"
_
,
warns
,
errs
=
NewConfig
(
raw
)
testConfigOk
(
t
,
warns
,
errs
)
// Bad export path (directory)
raw
[
"export_path"
]
=
td
_
,
warns
,
errs
=
NewConfig
(
raw
)
testConfigErr
(
t
,
warns
,
errs
)
}
func
TestConfigPrepare_exportPathAndCommit
(
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