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
caa518b2
Commit
caa518b2
authored
Jun 29, 2015
by
Chris Bednarski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2358 from mitchellh/b-do-private-network
Detect the first public IPv4 address for Digital Ocean
parents
61753d37
51804e91
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
5 deletions
+20
-5
builder/digitalocean/step_droplet_info.go
builder/digitalocean/step_droplet_info.go
+20
-5
No files found.
builder/digitalocean/step_droplet_info.go
View file @
caa518b2
...
@@ -14,11 +14,11 @@ func (s *stepDropletInfo) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -14,11 +14,11 @@ func (s *stepDropletInfo) Run(state multistep.StateBag) multistep.StepAction {
client
:=
state
.
Get
(
"client"
)
.
(
*
godo
.
Client
)
client
:=
state
.
Get
(
"client"
)
.
(
*
godo
.
Client
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
ui
:=
state
.
Get
(
"ui"
)
.
(
packer
.
Ui
)
c
:=
state
.
Get
(
"config"
)
.
(
Config
)
c
:=
state
.
Get
(
"config"
)
.
(
Config
)
dropletI
d
:=
state
.
Get
(
"droplet_id"
)
.
(
int
)
dropletI
D
:=
state
.
Get
(
"droplet_id"
)
.
(
int
)
ui
.
Say
(
"Waiting for droplet to become active..."
)
ui
.
Say
(
"Waiting for droplet to become active..."
)
err
:=
waitForDropletState
(
"active"
,
dropletI
d
,
client
,
c
.
StateTimeout
)
err
:=
waitForDropletState
(
"active"
,
dropletI
D
,
client
,
c
.
StateTimeout
)
if
err
!=
nil
{
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error waiting for droplet to become active: %s"
,
err
)
err
:=
fmt
.
Errorf
(
"Error waiting for droplet to become active: %s"
,
err
)
state
.
Put
(
"error"
,
err
)
state
.
Put
(
"error"
,
err
)
...
@@ -27,7 +27,7 @@ func (s *stepDropletInfo) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -27,7 +27,7 @@ func (s *stepDropletInfo) Run(state multistep.StateBag) multistep.StepAction {
}
}
// Set the IP on the state for later
// Set the IP on the state for later
droplet
,
_
,
err
:=
client
.
Droplets
.
Get
(
dropletI
d
)
droplet
,
_
,
err
:=
client
.
Droplets
.
Get
(
dropletI
D
)
if
err
!=
nil
{
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error retrieving droplet: %s"
,
err
)
err
:=
fmt
.
Errorf
(
"Error retrieving droplet: %s"
,
err
)
state
.
Put
(
"error"
,
err
)
state
.
Put
(
"error"
,
err
)
...
@@ -39,13 +39,28 @@ func (s *stepDropletInfo) Run(state multistep.StateBag) multistep.StepAction {
...
@@ -39,13 +39,28 @@ func (s *stepDropletInfo) Run(state multistep.StateBag) multistep.StepAction {
invalid
:=
droplet
.
Networks
==
nil
||
invalid
:=
droplet
.
Networks
==
nil
||
len
(
droplet
.
Networks
.
V4
)
==
0
len
(
droplet
.
Networks
.
V4
)
==
0
if
invalid
{
if
invalid
{
err
:=
fmt
.
Errorf
(
"IPv4 address not found for droplet!"
)
err
:=
fmt
.
Errorf
(
"IPv4 address not found for droplet"
)
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
}
// Find a public IPv4 network
foundNetwork
:=
false
for
_
,
network
:=
range
droplet
.
Networks
.
V4
{
if
network
.
Type
==
"public"
{
state
.
Put
(
"droplet_ip"
,
network
.
IPAddress
)
foundNetwork
=
true
break
}
}
if
!
foundNetwork
{
err
:=
fmt
.
Errorf
(
"Count not find a public IPv4 address for this droplet"
)
state
.
Put
(
"error"
,
err
)
state
.
Put
(
"error"
,
err
)
ui
.
Error
(
err
.
Error
())
ui
.
Error
(
err
.
Error
())
return
multistep
.
ActionHalt
return
multistep
.
ActionHalt
}
}
state
.
Put
(
"droplet_ip"
,
droplet
.
Networks
.
V4
[
0
]
.
IPAddress
)
return
multistep
.
ActionContinue
return
multistep
.
ActionContinue
}
}
...
...
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