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
341cfb2c
Commit
341cfb2c
authored
Jun 17, 2013
by
Jack Pearkes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/digitalocean: improve error messages from DO api
parent
477ac8cd
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
4 deletions
+16
-4
builder/digitalocean/api.go
builder/digitalocean/api.go
+6
-2
builder/digitalocean/step_create_droplet.go
builder/digitalocean/step_create_droplet.go
+4
-1
builder/digitalocean/step_create_ssh_key.go
builder/digitalocean/step_create_ssh_key.go
+6
-1
No files found.
builder/digitalocean/api.go
View file @
341cfb2c
...
@@ -156,7 +156,7 @@ func NewRequest(d DigitalOceanClient, path string, params string) (map[string]in
...
@@ -156,7 +156,7 @@ func NewRequest(d DigitalOceanClient, path string, params string) (map[string]in
// Catch all non-200 status and return an error
// Catch all non-200 status and return an error
if
resp
.
StatusCode
!=
200
{
if
resp
.
StatusCode
!=
200
{
err
=
errors
.
New
(
fmt
.
Sprintf
(
"
recieved non-200 status from digitalo
cean: %d"
,
resp
.
StatusCode
))
err
=
errors
.
New
(
fmt
.
Sprintf
(
"
Recieved non-200 HTTP status from DigitalO
cean: %d"
,
resp
.
StatusCode
))
log
.
Printf
(
"response from digital ocean: %v"
,
decodedResponse
)
log
.
Printf
(
"response from digital ocean: %v"
,
decodedResponse
)
return
decodedResponse
,
err
return
decodedResponse
,
err
}
}
...
@@ -170,7 +170,11 @@ func NewRequest(d DigitalOceanClient, path string, params string) (map[string]in
...
@@ -170,7 +170,11 @@ func NewRequest(d DigitalOceanClient, path string, params string) (map[string]in
// Catch all non-OK statuses from DO and return an error
// Catch all non-OK statuses from DO and return an error
status
:=
decodedResponse
[
"status"
]
status
:=
decodedResponse
[
"status"
]
if
status
!=
"OK"
{
if
status
!=
"OK"
{
err
=
errors
.
New
(
fmt
.
Sprintf
(
"recieved non-OK status from digitalocean: %d"
,
status
))
// Get the actual error message if there is one
if
status
==
"ERROR"
{
status
=
decodedResponse
[
"error_message"
]
}
err
=
errors
.
New
(
fmt
.
Sprintf
(
"Recieved bad status from DigitalOcean: %v"
,
status
))
log
.
Printf
(
"response from digital ocean: %v"
,
decodedResponse
)
log
.
Printf
(
"response from digital ocean: %v"
,
decodedResponse
)
return
decodedResponse
,
err
return
decodedResponse
,
err
}
}
...
...
builder/digitalocean/step_create_droplet.go
View file @
341cfb2c
...
@@ -63,8 +63,11 @@ func (s *stepCreateDroplet) Cleanup(state map[string]interface{}) {
...
@@ -63,8 +63,11 @@ func (s *stepCreateDroplet) Cleanup(state map[string]interface{}) {
err
:=
client
.
DestroyDroplet
(
s
.
dropletId
)
err
:=
client
.
DestroyDroplet
(
s
.
dropletId
)
curlstr
:=
fmt
.
Sprintf
(
"curl '%v/droplets/%v/destroy?client_id=%v&api_key=%v'"
,
DIGITALOCEAN_API_URL
,
s
.
dropletId
,
c
.
ClientID
,
c
.
APIKey
)
if
err
!=
nil
{
if
err
!=
nil
{
ui
.
Error
(
fmt
.
Sprintf
(
ui
.
Error
(
fmt
.
Sprintf
(
"Error destroying droplet. Please destroy it manually: %v"
,
s
.
dropletId
))
"Error destroying droplet. Please destroy it manually: %v"
,
curlstr
))
}
}
}
}
builder/digitalocean/step_create_ssh_key.go
View file @
341cfb2c
...
@@ -71,12 +71,17 @@ func (s *stepCreateSSHKey) Cleanup(state map[string]interface{}) {
...
@@ -71,12 +71,17 @@ func (s *stepCreateSSHKey) Cleanup(state map[string]interface{}) {
client
:=
state
[
"client"
]
.
(
*
DigitalOceanClient
)
client
:=
state
[
"client"
]
.
(
*
DigitalOceanClient
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
ui
:=
state
[
"ui"
]
.
(
packer
.
Ui
)
c
:=
state
[
"config"
]
.
(
config
)
ui
.
Say
(
"Deleting temporary ssh key..."
)
ui
.
Say
(
"Deleting temporary ssh key..."
)
err
:=
client
.
DestroyKey
(
s
.
keyId
)
err
:=
client
.
DestroyKey
(
s
.
keyId
)
curlstr
:=
fmt
.
Sprintf
(
"curl '%v/ssh_keys/%v/destroy?client_id=%v&api_key=%v'"
,
DIGITALOCEAN_API_URL
,
s
.
keyId
,
c
.
ClientID
,
c
.
APIKey
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Printf
(
"Error cleaning up ssh key: %v"
,
err
.
Error
())
log
.
Printf
(
"Error cleaning up ssh key: %v"
,
err
.
Error
())
ui
.
Error
(
fmt
.
Sprintf
(
ui
.
Error
(
fmt
.
Sprintf
(
"Error cleaning up ssh key. Please delete the key manually: %v"
,
s
.
keyId
))
"Error cleaning up ssh key. Please delete the key manually: %v"
,
curlstr
))
}
}
}
}
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