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
e5e30604
Commit
e5e30604
authored
Jul 16, 2013
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/amazon/common: RunConfig for launch info
parent
5aced3f3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
72 additions
and
53 deletions
+72
-53
builder/amazon/common/access_config.go
builder/amazon/common/access_config.go
+1
-1
builder/amazon/common/run_config.go
builder/amazon/common/run_config.go
+68
-0
builder/amazon/ebs/builder.go
builder/amazon/ebs/builder.go
+3
-52
No files found.
builder/amazon/common/access_config.go
View file @
e5e30604
...
...
@@ -16,6 +16,6 @@ func (c *AccessConfig) Auth() (aws.Auth, error) {
return
aws
.
GetAuth
(
c
.
AccessKey
,
c
.
SecretKey
)
}
func
(
c
*
AccessConfig
)
Validat
e
()
[]
error
{
func
(
c
*
AccessConfig
)
Prepar
e
()
[]
error
{
return
nil
}
builder/amazon/common/run_config.go
0 → 100644
View file @
e5e30604
package
common
import
(
"errors"
"fmt"
"github.com/mitchellh/goamz/aws"
"time"
)
// RunConfig contains configuration for running an instance from a source
// AMI and details on how to access that launched image.
type
RunConfig
struct
{
Region
string
SourceAmi
string
`mapstructure:"source_ami"`
InstanceType
string
`mapstructure:"instance_type"`
RawSSHTimeout
string
`mapstructure:"ssh_timeout"`
SSHUsername
string
`mapstructure:"ssh_username"`
SSHPort
int
`mapstructure:"ssh_port"`
SecurityGroupId
string
`mapstructure:"security_group_id"`
SubnetId
string
`mapstructure:"subnet_id"`
VpcId
string
`mapstructure:"vpc_id"`
// Unexported fields that are calculated from others
sshTimeout
time
.
Duration
}
func
(
c
*
RunConfig
)
Prepare
()
[]
error
{
// Defaults
if
c
.
SSHPort
==
0
{
c
.
SSHPort
=
22
}
if
c
.
RawSSHTimeout
==
""
{
c
.
RawSSHTimeout
=
"1m"
}
// Validation
var
err
error
errs
:=
make
([]
error
,
0
)
if
c
.
SourceAmi
==
""
{
errs
=
append
(
errs
,
errors
.
New
(
"A source_ami must be specified"
))
}
if
c
.
InstanceType
==
""
{
errs
=
append
(
errs
,
errors
.
New
(
"An instance_type must be specified"
))
}
if
c
.
Region
==
""
{
errs
=
append
(
errs
,
errors
.
New
(
"A region must be specified"
))
}
else
if
_
,
ok
:=
aws
.
Regions
[
c
.
Region
];
!
ok
{
errs
=
append
(
errs
,
fmt
.
Errorf
(
"Unknown region: %s"
,
c
.
Region
))
}
if
c
.
SSHUsername
==
""
{
errs
=
append
(
errs
,
errors
.
New
(
"An ssh_username must be specified"
))
}
c
.
sshTimeout
,
err
=
time
.
ParseDuration
(
c
.
RawSSHTimeout
)
if
err
!=
nil
{
errs
=
append
(
errs
,
fmt
.
Errorf
(
"Failed parsing ssh_timeout: %s"
,
err
))
}
return
errs
}
func
(
c
*
RunConfig
)
SSHTimeout
()
time
.
Duration
{
return
c
.
sshTimeout
}
builder/amazon/ebs/builder.go
View file @
e5e30604
...
...
@@ -16,7 +16,6 @@ import (
"github.com/mitchellh/packer/packer"
"log"
"text/template"
"time"
)
// The unique ID for this builder
...
...
@@ -24,25 +23,14 @@ const BuilderId = "mitchellh.amazonebs"
type
config
struct
{
awscommon
.
AccessConfig
`mapstructure:",squash"`
// Information for the source instance
Region
string
SourceAmi
string
`mapstructure:"source_ami"`
InstanceType
string
`mapstructure:"instance_type"`
SSHUsername
string
`mapstructure:"ssh_username"`
SSHPort
int
`mapstructure:"ssh_port"`
SecurityGroupId
string
`mapstructure:"security_group_id"`
VpcId
string
`mapstructure:"vpc_id"`
SubnetId
string
`mapstructure:"subnet_id"`
awscommon
.
RunConfig
`mapstructure:",squash"`
// Configuration of the resulting AMI
AMIName
string
`mapstructure:"ami_name"`
PackerDebug
bool
`mapstructure:"packer_debug"`
RawSSHTimeout
string
`mapstructure:"ssh_timeout"`
// Unexported fields that are calculated from others
sshTimeout
time
.
Duration
PackerDebug
bool
`mapstructure:"packer_debug"`
}
type
Builder
struct
{
...
...
@@ -59,44 +47,7 @@ func (b *Builder) Prepare(raws ...interface{}) error {
// Accumulate any errors
errs
:=
common
.
CheckUnusedConfig
(
md
)
if
b
.
config
.
SSHPort
==
0
{
b
.
config
.
SSHPort
=
22
}
if
b
.
config
.
RawSSHTimeout
==
""
{
b
.
config
.
RawSSHTimeout
=
"1m"
}
// Accumulate any errors
if
b
.
config
.
SourceAmi
==
""
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
errors
.
New
(
"A source_ami must be specified"
))
}
if
b
.
config
.
InstanceType
==
""
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
errors
.
New
(
"An instance_type must be specified"
))
}
if
b
.
config
.
Region
==
""
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
errors
.
New
(
"A region must be specified"
))
}
else
if
_
,
ok
:=
aws
.
Regions
[
b
.
config
.
Region
];
!
ok
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Unknown region: %s"
,
b
.
config
.
Region
))
}
if
b
.
config
.
SSHUsername
==
""
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
errors
.
New
(
"An ssh_username must be specified"
))
}
b
.
config
.
sshTimeout
,
err
=
time
.
ParseDuration
(
b
.
config
.
RawSSHTimeout
)
if
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Failed parsing ssh_timeout: %s"
,
err
))
}
if
b
.
config
.
AMIName
==
""
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
errors
.
New
(
"ami_name must be specified"
))
...
...
@@ -144,7 +95,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
&
common
.
StepConnectSSH
{
SSHAddress
:
sshAddress
,
SSHConfig
:
sshConfig
,
SSHWaitTimeout
:
b
.
config
.
sshTimeout
,
SSHWaitTimeout
:
b
.
config
.
SSHTimeout
()
,
},
&
common
.
StepProvision
{},
&
stepStopInstance
{},
...
...
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