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
87717216
Commit
87717216
authored
Jul 24, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/amazon/instance: bundle volume and keep track of dir
parent
63474f47
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
5 deletions
+74
-5
builder/amazon/instance/builder.go
builder/amazon/instance/builder.go
+22
-5
builder/amazon/instance/builder_test.go
builder/amazon/instance/builder_test.go
+48
-0
builder/amazon/instance/step_bundle_volume.go
builder/amazon/instance/step_bundle_volume.go
+4
-0
No files found.
builder/amazon/instance/builder.go
View file @
87717216
...
...
@@ -26,11 +26,14 @@ type Config struct {
awscommon
.
AccessConfig
`mapstructure:",squash"`
awscommon
.
RunConfig
`mapstructure:",squash"`
AccountId
string
`mapstructure:"account_id"`
BundleVolCommand
string
`mapstructure:"bundle_vol_command"`
X509CertPath
string
`mapstructure:"x509_cert_path"`
X509KeyPath
string
`mapstructure:"x509_key_path"`
X509UploadPath
string
`mapstructure:"x509_upload_path"`
AccountId
string
`mapstructure:"account_id"`
BundleDestination
string
`mapstructure:"bundle_destination"`
BundlePrefix
string
`mapstructure:"bundle_prefix"`
BundleVolCommand
string
`mapstructure:"bundle_vol_command"`
S3Bucket
string
`mapstructure:"s3_bucket"`
X509CertPath
string
`mapstructure:"x509_cert_path"`
X509KeyPath
string
`mapstructure:"x509_key_path"`
X509UploadPath
string
`mapstructure:"x509_upload_path"`
}
type
Builder
struct
{
...
...
@@ -44,6 +47,14 @@ func (b *Builder) Prepare(raws ...interface{}) error {
return
err
}
if
b
.
config
.
BundleDestination
==
""
{
b
.
config
.
BundleDestination
=
"/tmp"
}
if
b
.
config
.
BundlePrefix
==
""
{
b
.
config
.
BundlePrefix
=
"image"
}
// Accumulate any errors
errs
:=
common
.
CheckUnusedConfig
(
md
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
AccessConfig
.
Prepare
()
...
)
...
...
@@ -62,9 +73,15 @@ func (b *Builder) Prepare(raws ...interface{}) error {
"-c {{.CertPath}} "
+
"-r {{.Architecture}} "
+
"-e {{.PrivatePath}} "
+
"-d {{.Destination}} "
+
"-p {{.Prefix}} "
+
"--batch"
}
if
b
.
config
.
S3Bucket
==
""
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
errors
.
New
(
"s3_bucket is required"
))
}
if
b
.
config
.
X509CertPath
==
""
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
errors
.
New
(
"x509_cert_path is required"
))
}
else
if
_
,
err
:=
os
.
Stat
(
b
.
config
.
X509CertPath
);
err
!=
nil
{
...
...
builder/amazon/instance/builder_test.go
View file @
87717216
...
...
@@ -17,6 +17,7 @@ func testConfig() map[string]interface{} {
"account_id"
:
"foo"
,
"instance_type"
:
"m1.small"
,
"region"
:
"us-east-1"
,
"s3_bucket"
:
"foo"
,
"source_ami"
:
"foo"
,
"ssh_username"
:
"bob"
,
"x509_cert_path"
:
tf
.
Name
(),
...
...
@@ -60,6 +61,36 @@ func TestBuilderPrepare_AccountId(t *testing.T) {
}
}
func
TestBuilderPrepare_BundleDestination
(
t
*
testing
.
T
)
{
b
:=
&
Builder
{}
config
:=
testConfig
()
config
[
"bundle_destination"
]
=
""
err
:=
b
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
if
b
.
config
.
BundleDestination
!=
"/tmp"
{
t
.
Fatalf
(
"bad: %s"
,
b
.
config
.
BundleDestination
)
}
}
func
TestBuilderPrepare_BundlePrefix
(
t
*
testing
.
T
)
{
b
:=
&
Builder
{}
config
:=
testConfig
()
config
[
"bundle_prefix"
]
=
""
err
:=
b
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
if
b
.
config
.
BundlePrefix
!=
"image"
{
t
.
Fatalf
(
"bad: %s"
,
b
.
config
.
BundlePrefix
)
}
}
func
TestBuilderPrepare_InvalidKey
(
t
*
testing
.
T
)
{
var
b
Builder
config
:=
testConfig
()
...
...
@@ -72,6 +103,23 @@ func TestBuilderPrepare_InvalidKey(t *testing.T) {
}
}
func
TestBuilderPrepare_S3Bucket
(
t
*
testing
.
T
)
{
b
:=
&
Builder
{}
config
:=
testConfig
()
config
[
"s3_bucket"
]
=
""
err
:=
b
.
Prepare
(
config
)
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
config
[
"s3_bucket"
]
=
"foo"
err
=
b
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Errorf
(
"err: %s"
,
err
)
}
}
func
TestBuilderPrepare_X509CertPath
(
t
*
testing
.
T
)
{
b
:=
&
Builder
{}
config
:=
testConfig
()
...
...
builder/amazon/instance/step_bundle_volume.go
View file @
87717216
...
...
@@ -13,7 +13,9 @@ type bundleCmdData struct {
AccountId
string
Architecture
string
CertPath
string
Destination
string
KeyPath
string
Prefix
string
PrivatePath
string
}
...
...
@@ -52,7 +54,9 @@ func (s *StepBundleVolume) Run(state map[string]interface{}) multistep.StepActio
AccountId
:
config
.
AccountId
,
Architecture
:
instance
.
Architecture
,
CertPath
:
x509RemoteCertPath
,
Destination
:
config
.
BundleDestination
,
KeyPath
:
x509RemoteKeyPath
,
Prefix
:
config
.
BundlePrefix
,
PrivatePath
:
config
.
X509UploadPath
,
}
t
:=
template
.
Must
(
template
.
New
(
"bundleCmd"
)
.
Parse
(
config
.
BundleVolCommand
))
...
...
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