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
ec526d97
Commit
ec526d97
authored
Jul 30, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/amazon/chroot: more settings, validation
parent
cffb35ab
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
3 deletions
+37
-3
builder/amazon/chroot/builder.go
builder/amazon/chroot/builder.go
+15
-1
builder/amazon/chroot/builder_test.go
builder/amazon/chroot/builder_test.go
+20
-1
builder/amazon/chroot/step_attach_volume.go
builder/amazon/chroot/step_attach_volume.go
+2
-1
No files found.
builder/amazon/chroot/builder.go
View file @
ec526d97
...
...
@@ -24,7 +24,10 @@ type Config struct {
common
.
PackerConfig
`mapstructure:",squash"`
awscommon
.
AccessConfig
`mapstructure:",squash"`
SourceAmi
string
`mapstructure:"source_ami"`
SourceAmi
string
`mapstructure:"source_ami"`
AttachedDevicePath
string
`mapstructure:"attached_device_path"`
DevicePath
string
`mapstructure:"device_path"`
MountPath
string
`mapstructure:"mount_path"`
}
type
Builder
struct
{
...
...
@@ -39,11 +42,22 @@ func (b *Builder) Prepare(raws ...interface{}) error {
}
// Defaults
if
b
.
config
.
DevicePath
==
""
{
b
.
config
.
DevicePath
=
"/dev/sdh"
}
if
b
.
config
.
MountPath
==
""
{
b
.
config
.
MountPath
=
"/var/packer-amazon-chroot/volumes/{{.Device}}"
}
// Accumulate any errors
errs
:=
common
.
CheckUnusedConfig
(
md
)
errs
=
packer
.
MultiErrorAppend
(
errs
,
b
.
config
.
AccessConfig
.
Prepare
()
...
)
if
b
.
config
.
SourceAmi
==
""
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
errors
.
New
(
"source_ami is required."
))
}
if
errs
!=
nil
&&
len
(
errs
.
Errors
)
>
0
{
return
errs
}
...
...
builder/amazon/chroot/builder_test.go
View file @
ec526d97
...
...
@@ -6,7 +6,9 @@ import (
)
func
testConfig
()
map
[
string
]
interface
{}
{
return
map
[
string
]
interface
{}{}
return
map
[
string
]
interface
{}{
"source_ami"
:
"foo"
,
}
}
func
TestBuilder_ImplementsBuilder
(
t
*
testing
.
T
)
{
...
...
@@ -16,3 +18,20 @@ func TestBuilder_ImplementsBuilder(t *testing.T) {
t
.
Fatalf
(
"Builder should be a builder"
)
}
}
func
TestBuilderPrepare_SourceAmi
(
t
*
testing
.
T
)
{
b
:=
&
Builder
{}
config
:=
testConfig
()
config
[
"source_ami"
]
=
""
err
:=
b
.
Prepare
(
config
)
if
err
==
nil
{
t
.
Fatal
(
"should have error"
)
}
config
[
"source_ami"
]
=
"foo"
err
=
b
.
Prepare
(
config
)
if
err
!=
nil
{
t
.
Errorf
(
"err: %s"
,
err
)
}
}
builder/amazon/chroot/step_attach_volume.go
View file @
ec526d97
...
...
@@ -20,12 +20,13 @@ type StepAttachVolume struct {
}
func
(
s
*
StepAttachVolume
)
Run
(
state
map
[
string
]
interface
{})
multistep
.
StepAction
{
config
:=
state
[
"config"
]
.
(
*
Config
)
ec2conn
:=
state
[
"ec2"
]
.
(
*
ec2
.
EC2
)
instance
:=
state
[
"instance"
]
.
(
*
ec2
.
Instance
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
volumeId
:=
state
[
"volume_id"
]
.
(
string
)
device
:=
"/dev/sdh"
device
:=
config
.
DevicePath
ui
.
Say
(
"Attaching the root volume..."
)
_
,
err
:=
ec2conn
.
AttachVolume
(
volumeId
,
instance
.
InstanceId
,
device
)
...
...
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