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
3cd7379d
Commit
3cd7379d
authored
Nov 02, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/amazon/*: warnings
parent
82cbf13f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
139 additions
and
46 deletions
+139
-46
builder/amazon/chroot/builder.go
builder/amazon/chroot/builder.go
+5
-5
builder/amazon/chroot/builder_test.go
builder/amazon/chroot/builder_test.go
+32
-8
builder/amazon/ebs/builder.go
builder/amazon/ebs/builder.go
+5
-5
builder/amazon/ebs/builder_test.go
builder/amazon/ebs/builder_test.go
+20
-5
builder/amazon/instance/builder.go
builder/amazon/instance/builder.go
+5
-5
builder/amazon/instance/builder_test.go
builder/amazon/instance/builder_test.go
+72
-18
No files found.
builder/amazon/chroot/builder.go
View file @
3cd7379d
...
...
@@ -45,15 +45,15 @@ type Builder struct {
runner
multistep
.
Runner
}
func
(
b
*
Builder
)
Prepare
(
raws
...
interface
{})
error
{
func
(
b
*
Builder
)
Prepare
(
raws
...
interface
{})
([]
string
,
error
)
{
md
,
err
:=
common
.
DecodeConfig
(
&
b
.
config
,
raws
...
)
if
err
!=
nil
{
return
err
return
nil
,
err
}
b
.
config
.
tpl
,
err
=
packer
.
NewConfigTemplate
()
if
err
!=
nil
{
return
err
return
nil
,
err
}
b
.
config
.
tpl
.
UserVars
=
b
.
config
.
PackerUserVars
b
.
config
.
tpl
.
Funcs
(
awscommon
.
TemplateFuncs
)
...
...
@@ -140,11 +140,11 @@ func (b *Builder) Prepare(raws ...interface{}) error {
}
if
errs
!=
nil
&&
len
(
errs
.
Errors
)
>
0
{
return
errs
return
nil
,
errs
}
log
.
Println
(
common
.
ScrubConfig
(
b
.
config
,
b
.
config
.
AccessKey
,
b
.
config
.
SecretKey
))
return
nil
return
nil
,
nil
}
func
(
b
*
Builder
)
Run
(
ui
packer
.
Ui
,
hook
packer
.
Hook
,
cache
packer
.
Cache
)
(
packer
.
Artifact
,
error
)
{
...
...
builder/amazon/chroot/builder_test.go
View file @
3cd7379d
...
...
@@ -26,7 +26,10 @@ func TestBuilderPrepare_AMIName(t *testing.T) {
// Test good
config
[
"ami_name"
]
=
"foo"
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -34,7 +37,10 @@ func TestBuilderPrepare_AMIName(t *testing.T) {
// Test bad
config
[
"ami_name"
]
=
"foo {{"
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
...
...
@@ -42,7 +48,10 @@ func TestBuilderPrepare_AMIName(t *testing.T) {
// Test bad
delete
(
config
,
"ami_name"
)
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
...
...
@@ -53,7 +62,10 @@ func TestBuilderPrepare_ChrootMounts(t *testing.T) {
config
:=
testConfig
()
config
[
"chroot_mounts"
]
=
nil
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Errorf
(
"err: %s"
,
err
)
}
...
...
@@ -61,7 +73,10 @@ func TestBuilderPrepare_ChrootMounts(t *testing.T) {
config
[
"chroot_mounts"
]
=
[][]
string
{
[]
string
{
"bad"
},
}
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
...
...
@@ -71,13 +86,19 @@ func TestBuilderPrepare_SourceAmi(t *testing.T) {
config
:=
testConfig
()
config
[
"source_ami"
]
=
""
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
config
[
"source_ami"
]
=
"foo"
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Errorf
(
"err: %s"
,
err
)
}
...
...
@@ -88,7 +109,10 @@ func TestBuilderPrepare_CommandWrapper(t *testing.T) {
config
:=
testConfig
()
config
[
"command_wrapper"
]
=
"echo hi; {{.Command}}"
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Errorf
(
"err: %s"
,
err
)
}
...
...
builder/amazon/ebs/builder.go
View file @
3cd7379d
...
...
@@ -33,15 +33,15 @@ type Builder struct {
runner
multistep
.
Runner
}
func
(
b
*
Builder
)
Prepare
(
raws
...
interface
{})
error
{
func
(
b
*
Builder
)
Prepare
(
raws
...
interface
{})
([]
string
,
error
)
{
md
,
err
:=
common
.
DecodeConfig
(
&
b
.
config
,
raws
...
)
if
err
!=
nil
{
return
err
return
nil
,
err
}
b
.
config
.
tpl
,
err
=
packer
.
NewConfigTemplate
()
if
err
!=
nil
{
return
err
return
nil
,
err
}
b
.
config
.
tpl
.
UserVars
=
b
.
config
.
PackerUserVars
b
.
config
.
tpl
.
Funcs
(
awscommon
.
TemplateFuncs
)
...
...
@@ -53,11 +53,11 @@ func (b *Builder) Prepare(raws ...interface{}) error {
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
RunConfig
.
Prepare
(
b
.
config
.
tpl
)
...
)
if
errs
!=
nil
&&
len
(
errs
.
Errors
)
>
0
{
return
errs
return
nil
,
errs
}
log
.
Println
(
common
.
ScrubConfig
(
b
.
config
,
b
.
config
.
AccessKey
,
b
.
config
.
SecretKey
))
return
nil
return
nil
,
nil
}
func
(
b
*
Builder
)
Run
(
ui
packer
.
Ui
,
hook
packer
.
Hook
,
cache
packer
.
Cache
)
(
packer
.
Artifact
,
error
)
{
...
...
builder/amazon/ebs/builder_test.go
View file @
3cd7379d
...
...
@@ -31,7 +31,10 @@ func TestBuilder_Prepare_BadType(t *testing.T) {
"access_key"
:
[]
string
{},
}
err
:=
b
.
Prepare
(
c
)
warnings
,
err
:=
b
.
Prepare
(
c
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
==
nil
{
t
.
Fatalf
(
"prepare should fail"
)
}
...
...
@@ -43,7 +46,10 @@ func TestBuilderPrepare_AMIName(t *testing.T) {
// Test good
config
[
"ami_name"
]
=
"foo"
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -51,7 +57,10 @@ func TestBuilderPrepare_AMIName(t *testing.T) {
// Test bad
config
[
"ami_name"
]
=
"foo {{"
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
...
...
@@ -59,7 +68,10 @@ func TestBuilderPrepare_AMIName(t *testing.T) {
// Test bad
delete
(
config
,
"ami_name"
)
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
...
...
@@ -71,7 +83,10 @@ func TestBuilderPrepare_InvalidKey(t *testing.T) {
// Add a random key
config
[
"i_should_not_be_valid"
]
=
true
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
...
...
builder/amazon/instance/builder.go
View file @
3cd7379d
...
...
@@ -45,15 +45,15 @@ type Builder struct {
runner
multistep
.
Runner
}
func
(
b
*
Builder
)
Prepare
(
raws
...
interface
{})
error
{
func
(
b
*
Builder
)
Prepare
(
raws
...
interface
{})
([]
string
,
error
)
{
md
,
err
:=
common
.
DecodeConfig
(
&
b
.
config
,
raws
...
)
if
err
!=
nil
{
return
err
return
nil
,
err
}
b
.
config
.
tpl
,
err
=
packer
.
NewConfigTemplate
()
if
err
!=
nil
{
return
err
return
nil
,
err
}
b
.
config
.
tpl
.
UserVars
=
b
.
config
.
PackerUserVars
b
.
config
.
tpl
.
Funcs
(
awscommon
.
TemplateFuncs
)
...
...
@@ -156,11 +156,11 @@ func (b *Builder) Prepare(raws ...interface{}) error {
}
if
errs
!=
nil
&&
len
(
errs
.
Errors
)
>
0
{
return
errs
return
nil
,
errs
}
log
.
Println
(
common
.
ScrubConfig
(
b
.
config
,
b
.
config
.
AccessKey
,
b
.
config
.
SecretKey
))
return
nil
return
nil
,
nil
}
func
(
b
*
Builder
)
Run
(
ui
packer
.
Ui
,
hook
packer
.
Hook
,
cache
packer
.
Cache
)
(
packer
.
Artifact
,
error
)
{
...
...
builder/amazon/instance/builder_test.go
View file @
3cd7379d
...
...
@@ -40,19 +40,28 @@ func TestBuilderPrepare_AccountId(t *testing.T) {
config
:=
testConfig
()
config
[
"account_id"
]
=
""
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
config
[
"account_id"
]
=
"foo"
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Errorf
(
"err: %s"
,
err
)
}
config
[
"account_id"
]
=
"0123-0456-7890"
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
...
...
@@ -68,7 +77,10 @@ func TestBuilderPrepare_AMIName(t *testing.T) {
// Test good
config
[
"ami_name"
]
=
"foo"
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -76,7 +88,10 @@ func TestBuilderPrepare_AMIName(t *testing.T) {
// Test bad
config
[
"ami_name"
]
=
"foo {{"
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
...
...
@@ -84,7 +99,10 @@ func TestBuilderPrepare_AMIName(t *testing.T) {
// Test bad
delete
(
config
,
"ami_name"
)
b
=
Builder
{}
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
...
...
@@ -95,7 +113,10 @@ func TestBuilderPrepare_BundleDestination(t *testing.T) {
config
:=
testConfig
()
config
[
"bundle_destination"
]
=
""
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
...
...
@@ -110,7 +131,10 @@ func TestBuilderPrepare_BundlePrefix(t *testing.T) {
config
:=
testConfig
()
config
[
"bundle_prefix"
]
=
""
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"err: %s"
,
err
)
}
...
...
@@ -126,7 +150,10 @@ func TestBuilderPrepare_InvalidKey(t *testing.T) {
// Add a random key
config
[
"i_should_not_be_valid"
]
=
true
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
...
...
@@ -137,13 +164,19 @@ func TestBuilderPrepare_S3Bucket(t *testing.T) {
config
:=
testConfig
()
config
[
"s3_bucket"
]
=
""
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
config
[
"s3_bucket"
]
=
"foo"
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Errorf
(
"err: %s"
,
err
)
}
...
...
@@ -154,13 +187,19 @@ func TestBuilderPrepare_X509CertPath(t *testing.T) {
config
:=
testConfig
()
config
[
"x509_cert_path"
]
=
""
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
config
[
"x509_cert_path"
]
=
"i/am/a/file/that/doesnt/exist"
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
==
nil
{
t
.
Error
(
"should have error"
)
}
...
...
@@ -172,7 +211,10 @@ func TestBuilderPrepare_X509CertPath(t *testing.T) {
defer
os
.
Remove
(
tf
.
Name
())
config
[
"x509_cert_path"
]
=
tf
.
Name
()
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -183,13 +225,19 @@ func TestBuilderPrepare_X509KeyPath(t *testing.T) {
config
:=
testConfig
()
config
[
"x509_key_path"
]
=
""
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
config
[
"x509_key_path"
]
=
"i/am/a/file/that/doesnt/exist"
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
==
nil
{
t
.
Error
(
"should have error"
)
}
...
...
@@ -201,7 +249,10 @@ func TestBuilderPrepare_X509KeyPath(t *testing.T) {
defer
os
.
Remove
(
tf
.
Name
())
config
[
"x509_key_path"
]
=
tf
.
Name
()
err
=
b
.
Prepare
(
config
)
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
@@ -212,7 +263,10 @@ func TestBuilderPrepare_X509UploadPath(t *testing.T) {
config
:=
testConfig
()
config
[
"x509_upload_path"
]
=
""
err
:=
b
.
Prepare
(
config
)
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
...
...
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