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
d73cbd37
Commit
d73cbd37
authored
Dec 24, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/vmware/common: make the dir private for LocalOutputDir
parent
50f8b2c1
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
18 deletions
+21
-18
builder/vmware/common/output_dir_local.go
builder/vmware/common/output_dir_local.go
+7
-7
builder/vmware/common/step_output_dir_test.go
builder/vmware/common/step_output_dir_test.go
+14
-11
No files found.
builder/vmware/common/output_dir_local.go
View file @
d73cbd37
...
@@ -8,11 +8,11 @@ import (
...
@@ -8,11 +8,11 @@ import (
// LocalOutputDir is an OutputDir implementation where the directory
// LocalOutputDir is an OutputDir implementation where the directory
// is on the local machine.
// is on the local machine.
type
LocalOutputDir
struct
{
type
LocalOutputDir
struct
{
D
ir
string
d
ir
string
}
}
func
(
d
*
LocalOutputDir
)
DirExists
()
(
bool
,
error
)
{
func
(
d
*
LocalOutputDir
)
DirExists
()
(
bool
,
error
)
{
_
,
err
:=
os
.
Stat
(
d
.
D
ir
)
_
,
err
:=
os
.
Stat
(
d
.
d
ir
)
return
err
==
nil
,
nil
return
err
==
nil
,
nil
}
}
...
@@ -29,11 +29,11 @@ func (d *LocalOutputDir) ListFiles() ([]string, error) {
...
@@ -29,11 +29,11 @@ func (d *LocalOutputDir) ListFiles() ([]string, error) {
return
nil
return
nil
}
}
return
files
,
filepath
.
Walk
(
d
.
D
ir
,
visit
)
return
files
,
filepath
.
Walk
(
d
.
d
ir
,
visit
)
}
}
func
(
d
*
LocalOutputDir
)
MkdirAll
()
error
{
func
(
d
*
LocalOutputDir
)
MkdirAll
()
error
{
return
os
.
MkdirAll
(
d
.
D
ir
,
0755
)
return
os
.
MkdirAll
(
d
.
d
ir
,
0755
)
}
}
func
(
d
*
LocalOutputDir
)
Remove
(
path
string
)
error
{
func
(
d
*
LocalOutputDir
)
Remove
(
path
string
)
error
{
...
@@ -41,13 +41,13 @@ func (d *LocalOutputDir) Remove(path string) error {
...
@@ -41,13 +41,13 @@ func (d *LocalOutputDir) Remove(path string) error {
}
}
func
(
d
*
LocalOutputDir
)
RemoveAll
()
error
{
func
(
d
*
LocalOutputDir
)
RemoveAll
()
error
{
return
os
.
RemoveAll
(
d
.
D
ir
)
return
os
.
RemoveAll
(
d
.
d
ir
)
}
}
func
(
d
*
LocalOutputDir
)
SetOutputDir
(
path
string
)
{
func
(
d
*
LocalOutputDir
)
SetOutputDir
(
path
string
)
{
d
.
D
ir
=
path
d
.
d
ir
=
path
}
}
func
(
d
*
LocalOutputDir
)
String
()
string
{
func
(
d
*
LocalOutputDir
)
String
()
string
{
return
d
.
D
ir
return
d
.
d
ir
}
}
builder/vmware/common/step_output_dir_test.go
View file @
d73cbd37
...
@@ -13,7 +13,10 @@ func testOutputDir(t *testing.T) *LocalOutputDir {
...
@@ -13,7 +13,10 @@ func testOutputDir(t *testing.T) *LocalOutputDir {
t
.
Fatalf
(
"err: %s"
,
err
)
t
.
Fatalf
(
"err: %s"
,
err
)
}
}
os
.
RemoveAll
(
td
)
os
.
RemoveAll
(
td
)
return
&
LocalOutputDir
{
Dir
:
td
}
result
:=
new
(
LocalOutputDir
)
result
.
SetOutputDir
(
td
)
return
result
}
}
func
TestStepOutputDir_impl
(
t
*
testing
.
T
)
{
func
TestStepOutputDir_impl
(
t
*
testing
.
T
)
{
...
@@ -34,13 +37,13 @@ func TestStepOutputDir(t *testing.T) {
...
@@ -34,13 +37,13 @@ func TestStepOutputDir(t *testing.T) {
if
_
,
ok
:=
state
.
GetOk
(
"error"
);
ok
{
if
_
,
ok
:=
state
.
GetOk
(
"error"
);
ok
{
t
.
Fatal
(
"should NOT have error"
)
t
.
Fatal
(
"should NOT have error"
)
}
}
if
_
,
err
:=
os
.
Stat
(
dir
.
D
ir
);
err
!=
nil
{
if
_
,
err
:=
os
.
Stat
(
dir
.
d
ir
);
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
t
.
Fatalf
(
"err: %s"
,
err
)
}
}
// Test the cleanup
// Test the cleanup
step
.
Cleanup
(
state
)
step
.
Cleanup
(
state
)
if
_
,
err
:=
os
.
Stat
(
dir
.
D
ir
);
err
!=
nil
{
if
_
,
err
:=
os
.
Stat
(
dir
.
d
ir
);
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
t
.
Fatalf
(
"err: %s"
,
err
)
}
}
}
}
...
@@ -53,7 +56,7 @@ func TestStepOutputDir_existsNoForce(t *testing.T) {
...
@@ -53,7 +56,7 @@ func TestStepOutputDir_existsNoForce(t *testing.T) {
state
.
Put
(
"dir"
,
dir
)
state
.
Put
(
"dir"
,
dir
)
// Make sure the dir exists
// Make sure the dir exists
if
err
:=
os
.
MkdirAll
(
dir
.
D
ir
,
0755
);
err
!=
nil
{
if
err
:=
os
.
MkdirAll
(
dir
.
d
ir
,
0755
);
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
t
.
Fatalf
(
"err: %s"
,
err
)
}
}
...
@@ -67,7 +70,7 @@ func TestStepOutputDir_existsNoForce(t *testing.T) {
...
@@ -67,7 +70,7 @@ func TestStepOutputDir_existsNoForce(t *testing.T) {
// Test the cleanup
// Test the cleanup
step
.
Cleanup
(
state
)
step
.
Cleanup
(
state
)
if
_
,
err
:=
os
.
Stat
(
dir
.
D
ir
);
err
!=
nil
{
if
_
,
err
:=
os
.
Stat
(
dir
.
d
ir
);
err
!=
nil
{
t
.
Fatal
(
"should not delete dir"
)
t
.
Fatal
(
"should not delete dir"
)
}
}
}
}
...
@@ -81,7 +84,7 @@ func TestStepOutputDir_existsForce(t *testing.T) {
...
@@ -81,7 +84,7 @@ func TestStepOutputDir_existsForce(t *testing.T) {
state
.
Put
(
"dir"
,
dir
)
state
.
Put
(
"dir"
,
dir
)
// Make sure the dir exists
// Make sure the dir exists
if
err
:=
os
.
MkdirAll
(
dir
.
D
ir
,
0755
);
err
!=
nil
{
if
err
:=
os
.
MkdirAll
(
dir
.
d
ir
,
0755
);
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
t
.
Fatalf
(
"err: %s"
,
err
)
}
}
...
@@ -92,7 +95,7 @@ func TestStepOutputDir_existsForce(t *testing.T) {
...
@@ -92,7 +95,7 @@ func TestStepOutputDir_existsForce(t *testing.T) {
if
_
,
ok
:=
state
.
GetOk
(
"error"
);
ok
{
if
_
,
ok
:=
state
.
GetOk
(
"error"
);
ok
{
t
.
Fatal
(
"should NOT have error"
)
t
.
Fatal
(
"should NOT have error"
)
}
}
if
_
,
err
:=
os
.
Stat
(
dir
.
D
ir
);
err
!=
nil
{
if
_
,
err
:=
os
.
Stat
(
dir
.
d
ir
);
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
t
.
Fatalf
(
"err: %s"
,
err
)
}
}
}
}
...
@@ -111,14 +114,14 @@ func TestStepOutputDir_cancel(t *testing.T) {
...
@@ -111,14 +114,14 @@ func TestStepOutputDir_cancel(t *testing.T) {
if
_
,
ok
:=
state
.
GetOk
(
"error"
);
ok
{
if
_
,
ok
:=
state
.
GetOk
(
"error"
);
ok
{
t
.
Fatal
(
"should NOT have error"
)
t
.
Fatal
(
"should NOT have error"
)
}
}
if
_
,
err
:=
os
.
Stat
(
dir
.
D
ir
);
err
!=
nil
{
if
_
,
err
:=
os
.
Stat
(
dir
.
d
ir
);
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
t
.
Fatalf
(
"err: %s"
,
err
)
}
}
// Test cancel/halt
// Test cancel/halt
state
.
Put
(
multistep
.
StateCancelled
,
true
)
state
.
Put
(
multistep
.
StateCancelled
,
true
)
step
.
Cleanup
(
state
)
step
.
Cleanup
(
state
)
if
_
,
err
:=
os
.
Stat
(
dir
.
D
ir
);
err
==
nil
{
if
_
,
err
:=
os
.
Stat
(
dir
.
d
ir
);
err
==
nil
{
t
.
Fatal
(
"directory should not exist"
)
t
.
Fatal
(
"directory should not exist"
)
}
}
}
}
...
@@ -137,14 +140,14 @@ func TestStepOutputDir_halt(t *testing.T) {
...
@@ -137,14 +140,14 @@ func TestStepOutputDir_halt(t *testing.T) {
if
_
,
ok
:=
state
.
GetOk
(
"error"
);
ok
{
if
_
,
ok
:=
state
.
GetOk
(
"error"
);
ok
{
t
.
Fatal
(
"should NOT have error"
)
t
.
Fatal
(
"should NOT have error"
)
}
}
if
_
,
err
:=
os
.
Stat
(
dir
.
D
ir
);
err
!=
nil
{
if
_
,
err
:=
os
.
Stat
(
dir
.
d
ir
);
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
t
.
Fatalf
(
"err: %s"
,
err
)
}
}
// Test cancel/halt
// Test cancel/halt
state
.
Put
(
multistep
.
StateHalted
,
true
)
state
.
Put
(
multistep
.
StateHalted
,
true
)
step
.
Cleanup
(
state
)
step
.
Cleanup
(
state
)
if
_
,
err
:=
os
.
Stat
(
dir
.
D
ir
);
err
==
nil
{
if
_
,
err
:=
os
.
Stat
(
dir
.
d
ir
);
err
==
nil
{
t
.
Fatal
(
"directory should not exist"
)
t
.
Fatal
(
"directory should not exist"
)
}
}
}
}
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