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
e24cbc18
Commit
e24cbc18
authored
Jul 29, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/amazon/chroot: extract the source AMI info
parent
7f854902
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
0 deletions
+55
-0
builder/amazon/chroot/builder.go
builder/amazon/chroot/builder.go
+3
-0
builder/amazon/chroot/step_source_ami_info.go
builder/amazon/chroot/step_source_ami_info.go
+52
-0
No files found.
builder/amazon/chroot/builder.go
View file @
e24cbc18
...
...
@@ -21,6 +21,8 @@ const BuilderId = "mitchellh.amazon.chroot"
type
Config
struct
{
common
.
PackerConfig
`mapstructure:",squash"`
awscommon
.
AccessConfig
`mapstructure:",squash"`
SourceAmi
string
`mapstructure:"source_ami"`
}
type
Builder
struct
{
...
...
@@ -71,6 +73,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
// Build the steps
steps
:=
[]
multistep
.
Step
{
&
StepCheckEC2
{},
&
StepSourceAMIInfo
{},
}
// Run!
...
...
builder/amazon/chroot/step_source_ami_info.go
0 → 100644
View file @
e24cbc18
package
chroot
import
(
"fmt"
"github.com/mitchellh/goamz/ec2"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
)
// StepSourceAMIInfo extracts critical information from the source AMI
// that is used throughout the AMI creation process.
//
// Produces:
// source_image *ec2.Image - the source AMI info
type
StepSourceAMIInfo
struct
{}
func
(
s
*
StepSourceAMIInfo
)
Run
(
state
map
[
string
]
interface
{})
multistep
.
StepAction
{
config
:=
state
[
"config"
]
.
(
*
Config
)
ec2conn
:=
state
[
"ec2"
]
.
(
*
ec2
.
EC2
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
ui
.
Say
(
"Inspecting the source AMI..."
)
imageResp
,
err
:=
ec2conn
.
Images
([]
string
{
config
.
SourceAmi
},
ec2
.
NewFilter
())
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error querying AMI: %s"
,
err
)
state
[
"error"
]
=
err
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
}
if
len
(
imageResp
.
Images
)
==
0
{
err
:=
fmt
.
Errorf
(
"Source AMI '%s' was not found!"
,
config
.
SourceAmi
)
state
[
"error"
]
=
err
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
}
image
:=
imageResp
.
Images
[
0
]
// It must be EBS-backed otherwise the build won't work
if
image
.
RootDeviceType
!=
"ebs"
{
err
:=
fmt
.
Errorf
(
"The root device of the source AMI must be EBS-backed."
)
state
[
"error"
]
=
err
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
}
state
[
"source_image"
]
=
image
return
multistep
.
ActionContinue
}
func
(
s
*
StepSourceAMIInfo
)
Cleanup
(
map
[
string
]
interface
{})
{}
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