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
bee87940
Commit
bee87940
authored
Dec 25, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/vmware: new artifact type that is common
parent
6f449abf
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
112 additions
and
6 deletions
+112
-6
builder/vmware/common/artifact.go
builder/vmware/common/artifact.go
+61
-0
builder/vmware/common/artifact_test.go
builder/vmware/common/artifact_test.go
+43
-0
builder/vmware/iso/artifact.go
builder/vmware/iso/artifact.go
+2
-3
builder/vmware/iso/builder.go
builder/vmware/iso/builder.go
+2
-3
builder/vmware/iso/output_dir.go
builder/vmware/iso/output_dir.go
+4
-0
No files found.
builder/vmware/common/artifact.go
0 → 100644
View file @
bee87940
package
common
import
(
"fmt"
"os"
"path/filepath"
"github.com/mitchellh/packer/packer"
)
// BuilderId for the local artifacts
const
BuilderId
=
"mitchellh.vmware"
// Artifact is the result of running the VMware builder, namely a set
// of files associated with the resulting machine.
type
localArtifact
struct
{
dir
string
f
[]
string
}
// NewLocalArtifact returns a VMware artifact containing the files
// in the given directory.
func
NewLocalArtifact
(
dir
string
)
(
packer
.
Artifact
,
error
)
{
files
:=
make
([]
string
,
0
,
5
)
visit
:=
func
(
path
string
,
info
os
.
FileInfo
,
err
error
)
error
{
if
!
info
.
IsDir
()
{
files
=
append
(
files
,
path
)
}
return
err
}
if
err
:=
filepath
.
Walk
(
dir
,
visit
);
err
!=
nil
{
return
nil
,
err
}
return
&
localArtifact
{
dir
:
dir
,
f
:
files
,
},
nil
}
func
(
a
*
localArtifact
)
BuilderId
()
string
{
return
BuilderId
}
func
(
a
*
localArtifact
)
Files
()
[]
string
{
return
a
.
f
}
func
(
*
localArtifact
)
Id
()
string
{
return
"VM"
}
func
(
a
*
localArtifact
)
String
()
string
{
return
fmt
.
Sprintf
(
"VM files in directory: %s"
,
a
.
dir
)
}
func
(
a
*
localArtifact
)
Destroy
()
error
{
return
os
.
RemoveAll
(
a
.
dir
)
}
builder/vmware/common/artifact_test.go
0 → 100644
View file @
bee87940
package
common
import
(
"io/ioutil"
"os"
"path/filepath"
"testing"
"github.com/mitchellh/packer/packer"
)
func
TestLocalArtifact_impl
(
t
*
testing
.
T
)
{
var
_
packer
.
Artifact
=
new
(
localArtifact
)
}
func
TestNewLocalArtifact
(
t
*
testing
.
T
)
{
td
,
err
:=
ioutil
.
TempDir
(
""
,
"packer"
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
defer
os
.
RemoveAll
(
td
)
err
=
ioutil
.
WriteFile
(
filepath
.
Join
(
td
,
"a"
),
[]
byte
(
"foo"
),
0644
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
if
err
:=
os
.
Mkdir
(
filepath
.
Join
(
td
,
"b"
),
0755
);
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
a
,
err
:=
NewLocalArtifact
(
td
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
if
a
.
BuilderId
()
!=
BuilderId
{
t
.
Fatalf
(
"bad: %#v"
,
a
.
BuilderId
())
}
if
len
(
a
.
Files
())
!=
1
{
t
.
Fatalf
(
"should length 1: %d"
,
len
(
a
.
Files
()))
}
}
builder/vmware/iso/artifact.go
View file @
bee87940
...
...
@@ -2,14 +2,13 @@ package iso
import
(
"fmt"
"os"
)
// Artifact is the result of running the VMware builder, namely a set
// of files associated with the resulting machine.
type
Artifact
struct
{
builderId
string
dir
string
dir
OutputDir
f
[]
string
}
...
...
@@ -30,5 +29,5 @@ func (a *Artifact) String() string {
}
func
(
a
*
Artifact
)
Destroy
()
error
{
return
os
.
RemoveAll
(
a
.
dir
)
return
a
.
dir
.
RemoveAll
(
)
}
builder/vmware/iso/builder.go
View file @
bee87940
...
...
@@ -16,7 +16,6 @@ import (
"time"
)
const
BuilderId
=
"mitchellh.vmware"
const
BuilderIdESX
=
"mitchellh.vmware-esx"
type
Builder
struct
{
...
...
@@ -454,14 +453,14 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
}
// Set the proper builder ID
builderId
:=
BuilderId
builderId
:=
vmwcommon
.
BuilderId
if
b
.
config
.
RemoteType
!=
""
{
builderId
=
BuilderIdESX
}
return
&
Artifact
{
builderId
:
builderId
,
dir
:
b
.
config
.
OutputD
ir
,
dir
:
d
ir
,
f
:
files
,
},
nil
}
...
...
builder/vmware/iso/output_dir.go
View file @
bee87940
...
...
@@ -60,3 +60,7 @@ func (d *localOutputDir) RemoveAll() error {
func
(
d
*
localOutputDir
)
SetOutputDir
(
path
string
)
{
d
.
dir
=
path
}
func
(
d
*
localOutputDir
)
String
()
string
{
return
d
.
dir
}
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