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
5da56d2a
Commit
5da56d2a
authored
Jun 10, 2015
by
Mitchell Hashimoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/digitalocean: image, region, etc. required
parent
be8443d5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
43 deletions
+25
-43
builder/digitalocean/builder.go
builder/digitalocean/builder.go
+0
-12
builder/digitalocean/builder_acc_test.go
builder/digitalocean/builder_acc_test.go
+4
-1
builder/digitalocean/builder_test.go
builder/digitalocean/builder_test.go
+6
-18
builder/digitalocean/config.go
builder/digitalocean/config.go
+15
-12
No files found.
builder/digitalocean/builder.go
View file @
5da56d2a
...
...
@@ -14,18 +14,6 @@ import (
"golang.org/x/oauth2"
)
// see https://api.digitalocean.com/images/?client_id=[client_id]&api_key=[api_key]
// name="Ubuntu 12.04.4 x64", id=6374128,
const
DefaultImage
=
"ubuntu-12-04-x64"
// see https://api.digitalocean.com/regions/?client_id=[client_id]&api_key=[api_key]
// name="New York 3", id=8
const
DefaultRegion
=
"nyc3"
// see https://api.digitalocean.com/sizes/?client_id=[client_id]&api_key=[api_key]
// name="512MB", id=66 (the smallest droplet size)
const
DefaultSize
=
"512mb"
// The unique id for the builder
const
BuilderId
=
"pearkes.digitalocean"
...
...
builder/digitalocean/builder_acc_test.go
View file @
5da56d2a
...
...
@@ -24,7 +24,10 @@ func testAccPreCheck(t *testing.T) {
const
testBuilderAccBasic
=
`
{
"builders": [{
"type": "test"
"type": "test",
"region": "nyc2",
"size": "512mb",
"image": "ubuntu-12-04-x64"
}]
}
`
builder/digitalocean/builder_test.go
View file @
5da56d2a
...
...
@@ -60,12 +60,8 @@ func TestBuilderPrepare_Region(t *testing.T) {
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
if
b
.
config
.
Region
!=
DefaultRegion
{
t
.
Errorf
(
"found %s, expected %s"
,
b
.
config
.
Region
,
DefaultRegion
)
if
err
==
nil
{
t
.
Fatalf
(
"should error"
)
}
expected
:=
"sfo1"
...
...
@@ -95,12 +91,8 @@ func TestBuilderPrepare_Size(t *testing.T) {
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
if
b
.
config
.
Size
!=
DefaultSize
{
t
.
Errorf
(
"found %s, expected %s"
,
b
.
config
.
Size
,
DefaultSize
)
if
err
==
nil
{
t
.
Fatalf
(
"should error"
)
}
expected
:=
"1024mb"
...
...
@@ -130,12 +122,8 @@ func TestBuilderPrepare_Image(t *testing.T) {
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
if
b
.
config
.
Image
!=
DefaultImage
{
t
.
Errorf
(
"found %s, expected %s"
,
b
.
config
.
Image
,
DefaultImage
)
if
err
==
nil
{
t
.
Fatal
(
"should error"
)
}
expected
:=
"ubuntu-14-04-x64"
...
...
builder/digitalocean/config.go
View file @
5da56d2a
...
...
@@ -63,18 +63,6 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
c
.
APIToken
=
os
.
Getenv
(
"DIGITALOCEAN_API_TOKEN"
)
}
if
c
.
Region
==
""
{
c
.
Region
=
DefaultRegion
}
if
c
.
Size
==
""
{
c
.
Size
=
DefaultSize
}
if
c
.
Image
==
""
{
c
.
Image
=
DefaultImage
}
if
c
.
SnapshotName
==
""
{
// Default to packer-{{ unix timestamp (utc) }}
c
.
SnapshotName
=
"packer-{{timestamp}}"
...
...
@@ -114,6 +102,21 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
errs
,
errors
.
New
(
"api_token for auth must be specified"
))
}
if
c
.
Region
==
""
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
errors
.
New
(
"region is required"
))
}
if
c
.
Size
==
""
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
errors
.
New
(
"size is required"
))
}
if
c
.
Image
==
""
{
errs
=
packer
.
MultiErrorAppend
(
errs
,
errors
.
New
(
"image is required"
))
}
sshTimeout
,
err
:=
time
.
ParseDuration
(
c
.
RawSSHTimeout
)
if
err
!=
nil
{
errs
=
packer
.
MultiErrorAppend
(
...
...
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