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
7a956e1a
Commit
7a956e1a
authored
Dec 27, 2013
by
Jack Pearkes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
builder/digitalocean: add private_networking option for droplets
parent
037a744b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
6 deletions
+41
-6
builder/digitalocean/api.go
builder/digitalocean/api.go
+2
-1
builder/digitalocean/builder.go
builder/digitalocean/builder.go
+5
-4
builder/digitalocean/builder_test.go
builder/digitalocean/builder_test.go
+33
-0
builder/digitalocean/step_create_droplet.go
builder/digitalocean/step_create_droplet.go
+1
-1
No files found.
builder/digitalocean/api.go
View file @
7a956e1a
...
...
@@ -90,13 +90,14 @@ func (d DigitalOceanClient) DestroyKey(id uint) error {
}
// Creates a droplet and returns it's id
func
(
d
DigitalOceanClient
)
CreateDroplet
(
name
string
,
size
uint
,
image
uint
,
region
uint
,
keyId
uint
)
(
uint
,
error
)
{
func
(
d
DigitalOceanClient
)
CreateDroplet
(
name
string
,
size
uint
,
image
uint
,
region
uint
,
keyId
uint
,
privateNetworking
bool
)
(
uint
,
error
)
{
params
:=
url
.
Values
{}
params
.
Set
(
"name"
,
name
)
params
.
Set
(
"size_id"
,
fmt
.
Sprintf
(
"%v"
,
size
))
params
.
Set
(
"image_id"
,
fmt
.
Sprintf
(
"%v"
,
image
))
params
.
Set
(
"region_id"
,
fmt
.
Sprintf
(
"%v"
,
region
))
params
.
Set
(
"ssh_key_ids"
,
fmt
.
Sprintf
(
"%v"
,
keyId
))
params
.
Set
(
"private_networking"
,
fmt
.
Sprintf
(
"%v"
,
privateNetworking
))
body
,
err
:=
NewRequest
(
d
,
"droplets/new"
,
params
)
if
err
!=
nil
{
...
...
builder/digitalocean/builder.go
View file @
7a956e1a
...
...
@@ -30,10 +30,11 @@ type config struct {
SizeID
uint
`mapstructure:"size_id"`
ImageID
uint
`mapstructure:"image_id"`
SnapshotName
string
`mapstructure:"snapshot_name"`
DropletName
string
`mapstructure:"droplet_name"`
SSHUsername
string
`mapstructure:"ssh_username"`
SSHPort
uint
`mapstructure:"ssh_port"`
PrivateNetworking
bool
`mapstructure:"private_networking"`
SnapshotName
string
`mapstructure:"snapshot_name"`
DropletName
string
`mapstructure:"droplet_name"`
SSHUsername
string
`mapstructure:"ssh_username"`
SSHPort
uint
`mapstructure:"ssh_port"`
RawSSHTimeout
string
`mapstructure:"ssh_timeout"`
RawStateTimeout
string
`mapstructure:"state_timeout"`
...
...
builder/digitalocean/builder_test.go
View file @
7a956e1a
...
...
@@ -356,6 +356,39 @@ func TestBuilderPrepare_StateTimeout(t *testing.T) {
}
func
TestBuilderPrepare_PrivateNetworking
(
t
*
testing
.
T
)
{
var
b
Builder
config
:=
testConfig
()
// Test default
warnings
,
err
:=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
if
b
.
config
.
PrivateNetworking
!=
false
{
t
.
Errorf
(
"invalid: %s"
,
b
.
config
.
PrivateNetworking
)
}
// Test set
config
[
"private_networking"
]
=
true
b
=
Builder
{}
warnings
,
err
=
b
.
Prepare
(
config
)
if
len
(
warnings
)
>
0
{
t
.
Fatalf
(
"bad: %#v"
,
warnings
)
}
if
err
!=
nil
{
t
.
Fatalf
(
"should not have error: %s"
,
err
)
}
if
b
.
config
.
PrivateNetworking
!=
true
{
t
.
Errorf
(
"invalid: %s"
,
b
.
config
.
PrivateNetworking
)
}
}
func
TestBuilderPrepare_SnapshotName
(
t
*
testing
.
T
)
{
var
b
Builder
config
:=
testConfig
()
...
...
builder/digitalocean/step_create_droplet.go
View file @
7a956e1a
...
...
@@ -19,7 +19,7 @@ func (s *stepCreateDroplet) Run(state multistep.StateBag) multistep.StepAction {
ui
.
Say
(
"Creating droplet..."
)
// Create the droplet based on configuration
dropletId
,
err
:=
client
.
CreateDroplet
(
c
.
DropletName
,
c
.
SizeID
,
c
.
ImageID
,
c
.
RegionID
,
sshKeyId
)
dropletId
,
err
:=
client
.
CreateDroplet
(
c
.
DropletName
,
c
.
SizeID
,
c
.
ImageID
,
c
.
RegionID
,
sshKeyId
,
c
.
PrivateNetworking
)
if
err
!=
nil
{
err
:=
fmt
.
Errorf
(
"Error creating droplet: %s"
,
err
)
...
...
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