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
d4c9ed43
Commit
d4c9ed43
authored
Jan 31, 2014
by
Prasanna Santhanam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formatted googlecompute builder as per `make format`
parent
0e98b2a2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
56 deletions
+56
-56
builder/googlecompute/builder.go
builder/googlecompute/builder.go
+25
-25
builder/googlecompute/step_create_instance.go
builder/googlecompute/step_create_instance.go
+6
-6
builder/googlecompute/step_create_ssh_key.go
builder/googlecompute/step_create_ssh_key.go
+18
-18
builder/googlecompute/step_instance_info.go
builder/googlecompute/step_instance_info.go
+7
-7
No files found.
builder/googlecompute/builder.go
View file @
d4c9ed43
...
...
@@ -3,12 +3,12 @@
package
googlecompute
import
(
"log"
"time"
"fmt"
"fmt"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/common"
"github.com/mitchellh/packer/packer"
"log"
"time"
)
// The unique ID for this builder.
...
...
@@ -48,28 +48,28 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
state
.
Put
(
"ui"
,
ui
)
// Build the steps.
steps
:=
[]
multistep
.
Step
{
&
StepCreateSSHKey
{
Debug
:
b
.
config
.
PackerDebug
,
DebugKeyPath
:
fmt
.
Sprintf
(
"gce_%s.pem"
,
b
.
config
.
PackerBuildName
),
},
&
StepCreateInstance
{
Debug
:
b
.
config
.
PackerDebug
,
},
&
StepInstanceInfo
{
Debug
:
b
.
config
.
PackerDebug
,
},
&
common
.
StepConnectSSH
{
SSHAddress
:
sshAddress
,
SSHConfig
:
sshConfig
,
SSHWaitTimeout
:
5
*
time
.
Minute
,
},
new
(
common
.
StepProvision
),
new
(
StepUpdateGsutil
),
new
(
StepCreateImage
),
new
(
StepUploadImage
),
new
(
StepRegisterImage
),
}
steps
:=
[]
multistep
.
Step
{
&
StepCreateSSHKey
{
Debug
:
b
.
config
.
PackerDebug
,
DebugKeyPath
:
fmt
.
Sprintf
(
"gce_%s.pem"
,
b
.
config
.
PackerBuildName
),
},
&
StepCreateInstance
{
Debug
:
b
.
config
.
PackerDebug
,
},
&
StepInstanceInfo
{
Debug
:
b
.
config
.
PackerDebug
,
},
&
common
.
StepConnectSSH
{
SSHAddress
:
sshAddress
,
SSHConfig
:
sshConfig
,
SSHWaitTimeout
:
5
*
time
.
Minute
,
},
new
(
common
.
StepProvision
),
new
(
StepUpdateGsutil
),
new
(
StepCreateImage
),
new
(
StepUploadImage
),
new
(
StepRegisterImage
),
}
// Run the steps.
if
b
.
config
.
PackerDebug
{
...
...
builder/googlecompute/step_create_instance.go
View file @
d4c9ed43
...
...
@@ -13,7 +13,7 @@ import (
// StepCreateInstance represents a Packer build step that creates GCE instances.
type
StepCreateInstance
struct
{
instanceName
string
Debug
bool
Debug
bool
}
// Run executes the Packer build step that creates a GCE instance.
...
...
@@ -57,11 +57,11 @@ func (s *StepCreateInstance) Run(state multistep.StateBag) multistep.StepAction
ui
.
Message
(
"Instance has been created!"
)
if
s
.
Debug
{
if
name
!=
""
{
ui
.
Message
(
fmt
.
Sprintf
(
"Instance: %s started in %s"
,
name
,
config
.
Zone
))
}
}
if
s
.
Debug
{
if
name
!=
""
{
ui
.
Message
(
fmt
.
Sprintf
(
"Instance: %s started in %s"
,
name
,
config
.
Zone
))
}
}
// Things succeeded, store the name so we can remove it later
state
.
Put
(
"instance_name"
,
name
)
...
...
builder/googlecompute/step_create_ssh_key.go
View file @
d4c9ed43
package
googlecompute
import
(
"code.google.com/p/go.crypto/ssh"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"os"
"fmt"
"code.google.com/p/go.crypto/ssh"
"github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer"
"os"
)
// StepCreateSSHKey represents a Packer build step that generates SSH key pairs.
type
StepCreateSSHKey
struct
{
key
int
Debug
bool
DebugKeyPath
string
key
int
Debug
bool
DebugKeyPath
string
}
// Run executes the Packer build step that generates SSH key pairs.
...
...
@@ -45,20 +45,20 @@ func (s *StepCreateSSHKey) Run(state multistep.StateBag) multistep.StepAction {
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
}
state
.
Put
(
"ssh_private_key"
,
string
(
pem
.
EncodeToMemory
(
&
priv_blk
)))
state
.
Put
(
"ssh_public_key"
,
string
(
ssh
.
MarshalAuthorizedKey
(
pub
)))
state
.
Put
(
"ssh_private_key"
,
string
(
pem
.
EncodeToMemory
(
&
priv_blk
)))
state
.
Put
(
"ssh_public_key"
,
string
(
ssh
.
MarshalAuthorizedKey
(
pub
)))
if
s
.
Debug
{
ui
.
Message
(
fmt
.
Sprintf
(
"Saving key for debug purposes: %s"
,
s
.
DebugKeyPath
))
f
,
err
:=
os
.
OpenFile
(
s
.
DebugKeyPath
,
os
.
O_WRONLY
|
os
.
O_CREATE
|
os
.
O_TRUNC
,
0600
)
if
err
!=
nil
{
state
.
Put
(
"error"
,
fmt
.
Errorf
(
"Error saving debug key: %s"
,
err
))
return
multistep
.
ActionHalt
}
// Write out the key
pem
.
Encode
(
f
,
&
priv_blk
)
f
.
Close
()
}
if
s
.
Debug
{
ui
.
Message
(
fmt
.
Sprintf
(
"Saving key for debug purposes: %s"
,
s
.
DebugKeyPath
))
f
,
err
:=
os
.
OpenFile
(
s
.
DebugKeyPath
,
os
.
O_WRONLY
|
os
.
O_CREATE
|
os
.
O_TRUNC
,
0600
)
if
err
!=
nil
{
state
.
Put
(
"error"
,
fmt
.
Errorf
(
"Error saving debug key: %s"
,
err
))
return
multistep
.
ActionHalt
}
// Write out the key
pem
.
Encode
(
f
,
&
priv_blk
)
f
.
Close
()
}
return
multistep
.
ActionContinue
}
...
...
builder/googlecompute/step_instance_info.go
View file @
d4c9ed43
...
...
@@ -11,8 +11,8 @@ import (
// stepInstanceInfo represents a Packer build step that gathers GCE instance info.
type
StepInstanceInfo
struct
{
info
int
Debug
bool
info
int
Debug
bool
}
// Run executes the Packer build step that gathers GCE instance info.
...
...
@@ -47,11 +47,11 @@ func (s *StepInstanceInfo) Run(state multistep.StateBag) multistep.StepAction {
return
multistep
.
ActionHalt
}
if
s
.
Debug
{
if
ip
!=
""
{
ui
.
Message
(
fmt
.
Sprintf
(
"Public IP: %s"
,
ip
))
}
}
if
s
.
Debug
{
if
ip
!=
""
{
ui
.
Message
(
fmt
.
Sprintf
(
"Public IP: %s"
,
ip
))
}
}
ui
.
Message
(
fmt
.
Sprintf
(
"IP: %s"
,
ip
))
state
.
Put
(
"instance_ip"
,
ip
)
...
...
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