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
a60039e7
Commit
a60039e7
authored
Nov 26, 2014
by
Seth Vargo
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1650 from vtolstov/digitalocean
fix digitalocean v2 api content-type when using json
parents
31a1aa48
1e87e796
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
7 deletions
+16
-7
builder/digitalocean/api_v2.go
builder/digitalocean/api_v2.go
+15
-6
builder/digitalocean/builder.go
builder/digitalocean/builder.go
+1
-1
No files found.
builder/digitalocean/api_v2.go
View file @
a60039e7
...
@@ -262,8 +262,10 @@ func (d DigitalOceanClientV2) DropletStatus(id uint) (string, string, error) {
...
@@ -262,8 +262,10 @@ func (d DigitalOceanClientV2) DropletStatus(id uint) (string, string, error) {
}
}
var
ip
string
var
ip
string
if
len
(
res
.
Droplet
.
Networks
.
V4
)
>
0
{
for
_
,
n
:=
range
res
.
Droplet
.
Networks
.
V4
{
ip
=
res
.
Droplet
.
Networks
.
V4
[
0
]
.
IPAddr
if
n
.
Type
==
"public"
{
ip
=
n
.
IPAddr
}
}
}
return
ip
,
res
.
Droplet
.
Status
,
err
return
ip
,
res
.
Droplet
.
Status
,
err
...
@@ -285,17 +287,21 @@ func NewRequestV2(d DigitalOceanClientV2, path string, method string, req interf
...
@@ -285,17 +287,21 @@ func NewRequestV2(d DigitalOceanClientV2, path string, method string, req interf
enc
.
Encode
(
req
)
enc
.
Encode
(
req
)
defer
buf
.
Reset
()
defer
buf
.
Reset
()
request
,
err
=
http
.
NewRequest
(
method
,
url
,
buf
)
request
,
err
=
http
.
NewRequest
(
method
,
url
,
buf
)
request
.
Header
.
Add
(
"Content-Type"
,
"application/json"
)
}
else
{
}
else
{
request
,
err
=
http
.
NewRequest
(
method
,
url
,
nil
)
request
,
err
=
http
.
NewRequest
(
method
,
url
,
nil
)
}
}
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
// Add the authentication parameters
// Add the authentication parameters
request
.
Header
.
Add
(
"Authorization"
,
"Bearer "
+
d
.
APIToken
)
request
.
Header
.
Add
(
"Authorization"
,
"Bearer "
+
d
.
APIToken
)
if
buf
!=
nil
{
log
.
Printf
(
"sending new request to digitalocean: %s buffer: %s"
,
url
,
buf
)
}
else
{
log
.
Printf
(
"sending new request to digitalocean: %s"
,
url
)
log
.
Printf
(
"sending new request to digitalocean: %s"
,
url
)
}
resp
,
err
:=
client
.
Do
(
request
)
resp
,
err
:=
client
.
Do
(
request
)
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
...
@@ -325,7 +331,10 @@ func NewRequestV2(d DigitalOceanClientV2, path string, method string, req interf
...
@@ -325,7 +331,10 @@ func NewRequestV2(d DigitalOceanClientV2, path string, method string, req interf
return
errors
.
New
(
fmt
.
Sprintf
(
"Failed to decode JSON response %s (HTTP %v) from DigitalOcean: %s"
,
err
.
Error
(),
return
errors
.
New
(
fmt
.
Sprintf
(
"Failed to decode JSON response %s (HTTP %v) from DigitalOcean: %s"
,
err
.
Error
(),
resp
.
StatusCode
,
body
))
resp
.
StatusCode
,
body
))
}
}
switch
resp
.
StatusCode
{
case
403
,
401
,
429
,
422
,
404
,
503
,
500
:
return
errors
.
New
(
fmt
.
Sprintf
(
"digitalocean request error: %+v"
,
res
))
}
return
nil
return
nil
}
}
...
...
builder/digitalocean/builder.go
View file @
a60039e7
...
@@ -17,7 +17,7 @@ import (
...
@@ -17,7 +17,7 @@ import (
)
)
// see https://api.digitalocean.com/images/?client_id=[client_id]&api_key=[api_key]
// see https://api.digitalocean.com/images/?client_id=[client_id]&api_key=[api_key]
// name="Ubuntu 12.04.4 x64", id=
3101045
,
// name="Ubuntu 12.04.4 x64", id=
6374128
,
const
DefaultImage
=
"ubuntu-12-04-x64"
const
DefaultImage
=
"ubuntu-12-04-x64"
// see https://api.digitalocean.com/regions/?client_id=[client_id]&api_key=[api_key]
// see https://api.digitalocean.com/regions/?client_id=[client_id]&api_key=[api_key]
...
...
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