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
502076c9
Commit
502076c9
authored
Jun 13, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/googlecompute: use helper/comm
parent
669f3018
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
29 deletions
+12
-29
builder/googlecompute/builder.go
builder/googlecompute/builder.go
+5
-4
builder/googlecompute/config.go
builder/googlecompute/config.go
+4
-22
builder/googlecompute/ssh.go
builder/googlecompute/ssh.go
+2
-2
builder/googlecompute/step_create_instance.go
builder/googlecompute/step_create_instance.go
+1
-1
No files found.
builder/googlecompute/builder.go
View file @
502076c9
...
@@ -8,6 +8,7 @@ import (
...
@@ -8,6 +8,7 @@ import (
"github.com/mitchellh/multistep"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/helper/communicator"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/packer"
)
)
...
@@ -60,10 +61,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
...
@@ -60,10 +61,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
&
StepInstanceInfo
{
&
StepInstanceInfo
{
Debug
:
b
.
config
.
PackerDebug
,
Debug
:
b
.
config
.
PackerDebug
,
},
},
&
comm
on
.
StepConnectSSH
{
&
comm
unicator
.
StepConnect
{
SSHAddress
:
sshAddress
,
Config
:
&
b
.
config
.
Comm
,
SSH
Config
:
sshConfig
,
SSH
Address
:
sshAddress
,
SSH
WaitTimeout
:
b
.
config
.
sshTimeout
,
SSH
Config
:
sshConfig
,
},
},
new
(
common
.
StepProvision
),
new
(
common
.
StepProvision
),
new
(
StepTeardownInstance
),
new
(
StepTeardownInstance
),
...
...
builder/googlecompute/config.go
View file @
502076c9
...
@@ -7,6 +7,7 @@ import (
...
@@ -7,6 +7,7 @@ import (
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/common/uuid"
"github.com/mitchellh/packer/common/uuid"
"github.com/mitchellh/packer/helper/communicator"
"github.com/mitchellh/packer/helper/config"
"github.com/mitchellh/packer/helper/config"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/template/interpolate"
"github.com/mitchellh/packer/template/interpolate"
...
@@ -17,6 +18,7 @@ import (
...
@@ -17,6 +18,7 @@ import (
// state of the config object.
// state of the config object.
type
Config
struct
{
type
Config
struct
{
common
.
PackerConfig
`mapstructure:",squash"`
common
.
PackerConfig
`mapstructure:",squash"`
Comm
communicator
.
Config
`mapstructure:",squash"`
AccountFile
string
`mapstructure:"account_file"`
AccountFile
string
`mapstructure:"account_file"`
ProjectId
string
`mapstructure:"project_id"`
ProjectId
string
`mapstructure:"project_id"`
...
@@ -31,16 +33,12 @@ type Config struct {
...
@@ -31,16 +33,12 @@ type Config struct {
Network
string
`mapstructure:"network"`
Network
string
`mapstructure:"network"`
SourceImage
string
`mapstructure:"source_image"`
SourceImage
string
`mapstructure:"source_image"`
SourceImageProjectId
string
`mapstructure:"source_image_project_id"`
SourceImageProjectId
string
`mapstructure:"source_image_project_id"`
SSHUsername
string
`mapstructure:"ssh_username"`
SSHPort
uint
`mapstructure:"ssh_port"`
RawSSHTimeout
string
`mapstructure:"ssh_timeout"`
RawStateTimeout
string
`mapstructure:"state_timeout"`
RawStateTimeout
string
`mapstructure:"state_timeout"`
Tags
[]
string
`mapstructure:"tags"`
Tags
[]
string
`mapstructure:"tags"`
Zone
string
`mapstructure:"zone"`
Zone
string
`mapstructure:"zone"`
account
accountFile
account
accountFile
privateKeyBytes
[]
byte
privateKeyBytes
[]
byte
sshTimeout
time
.
Duration
stateTimeout
time
.
Duration
stateTimeout
time
.
Duration
ctx
*
interpolate
.
Context
ctx
*
interpolate
.
Context
}
}
...
@@ -88,20 +86,12 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
...
@@ -88,20 +86,12 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
c
.
MachineType
=
"n1-standard-1"
c
.
MachineType
=
"n1-standard-1"
}
}
if
c
.
RawSSHTimeout
==
""
{
c
.
RawSSHTimeout
=
"5m"
}
if
c
.
RawStateTimeout
==
""
{
if
c
.
RawStateTimeout
==
""
{
c
.
RawStateTimeout
=
"5m"
c
.
RawStateTimeout
=
"5m"
}
}
if
c
.
SSHUsername
==
""
{
if
c
.
Comm
.
SSHUsername
==
""
{
c
.
SSHUsername
=
"root"
c
.
Comm
.
SSHUsername
=
"root"
}
if
c
.
SSHPort
==
0
{
c
.
SSHPort
=
22
}
}
var
errs
*
packer
.
MultiError
var
errs
*
packer
.
MultiError
...
@@ -122,14 +112,6 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
...
@@ -122,14 +112,6 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
errs
,
errors
.
New
(
"a zone must be specified"
))
errs
,
errors
.
New
(
"a zone must be specified"
))
}
}
// Process timeout settings.
sshTimeout
,
err
:=
time
.
ParseDuration
(
c
.
RawSSHTimeout
)
if
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
fmt
.
Errorf
(
"Failed parsing ssh_timeout: %s"
,
err
))
}
c
.
sshTimeout
=
sshTimeout
stateTimeout
,
err
:=
time
.
ParseDuration
(
c
.
RawStateTimeout
)
stateTimeout
,
err
:=
time
.
ParseDuration
(
c
.
RawStateTimeout
)
if
err
!=
nil
{
if
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
errs
=
packer
.
MultiErrorAppend
(
...
...
builder/googlecompute/ssh.go
View file @
502076c9
...
@@ -10,7 +10,7 @@ import (
...
@@ -10,7 +10,7 @@ import (
func
sshAddress
(
state
multistep
.
StateBag
)
(
string
,
error
)
{
func
sshAddress
(
state
multistep
.
StateBag
)
(
string
,
error
)
{
config
:=
state
.
Get
(
"config"
)
.
(
*
Config
)
config
:=
state
.
Get
(
"config"
)
.
(
*
Config
)
ipAddress
:=
state
.
Get
(
"instance_ip"
)
.
(
string
)
ipAddress
:=
state
.
Get
(
"instance_ip"
)
.
(
string
)
return
fmt
.
Sprintf
(
"%s:%d"
,
ipAddress
,
config
.
SSHPort
),
nil
return
fmt
.
Sprintf
(
"%s:%d"
,
ipAddress
,
config
.
Comm
.
SSHPort
),
nil
}
}
// sshConfig returns the ssh configuration.
// sshConfig returns the ssh configuration.
...
@@ -24,7 +24,7 @@ func sshConfig(state multistep.StateBag) (*ssh.ClientConfig, error) {
...
@@ -24,7 +24,7 @@ func sshConfig(state multistep.StateBag) (*ssh.ClientConfig, error) {
}
}
return
&
ssh
.
ClientConfig
{
return
&
ssh
.
ClientConfig
{
User
:
config
.
SSHUsername
,
User
:
config
.
Comm
.
SSHUsername
,
Auth
:
[]
ssh
.
AuthMethod
{
Auth
:
[]
ssh
.
AuthMethod
{
ssh
.
PublicKeys
(
signer
),
ssh
.
PublicKeys
(
signer
),
},
},
...
...
builder/googlecompute/step_create_instance.go
View file @
502076c9
...
@@ -32,7 +32,7 @@ func (config *Config) getInstanceMetadata(sshPublicKey string) map[string]string
...
@@ -32,7 +32,7 @@ func (config *Config) getInstanceMetadata(sshPublicKey string) map[string]string
// Merge any existing ssh keys with our public key
// Merge any existing ssh keys with our public key
sshMetaKey
:=
"sshKeys"
sshMetaKey
:=
"sshKeys"
sshKeys
:=
fmt
.
Sprintf
(
"%s:%s"
,
config
.
SSHUsername
,
sshPublicKey
)
sshKeys
:=
fmt
.
Sprintf
(
"%s:%s"
,
config
.
Comm
.
SSHUsername
,
sshPublicKey
)
if
confSshKeys
,
exists
:=
instanceMetadata
[
sshMetaKey
];
exists
{
if
confSshKeys
,
exists
:=
instanceMetadata
[
sshMetaKey
];
exists
{
sshKeys
=
fmt
.
Sprintf
(
"%s
\n
%s"
,
sshKeys
,
confSshKeys
)
sshKeys
=
fmt
.
Sprintf
(
"%s
\n
%s"
,
sshKeys
,
confSshKeys
)
}
}
...
...
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