Skip to content

Commit 13905d9

Browse files
author
Quentin Perez
authored
Merge pull request #59 from QuentinPerez/add-region
Add region
2 parents 302a096 + d4d4ef2 commit 13905d9

File tree

93 files changed

+8302
-1368
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+8302
-1368
lines changed

Godeps/Godeps.json

+67-51
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+7-2
Original file line numberDiff line numberDiff line change
@@ -73,20 +73,23 @@ Options:
7373
--scaleway-debug Enables Scaleway client debugging [$SCALEWAY_DEBUG]
7474
--scaleway-image "ubuntu-xenial" Specifies the image [$SCALEWAY_IMAGE]
7575
--scaleway-ip Specifies the IP address [$SCALEWAY_IP]
76+
--scaleway-ipv6 Enable ipv6 [$SCALEWAY_IPV6]
7677
--scaleway-name Assign a name [$SCALEWAY_NAME]
7778
--scaleway-organization Scaleway organization [$SCALEWAY_ORGANIZATION]
7879
--scaleway-port "22" Specifies SSH port [$SCALEWAY_PORT]
80+
--scaleway-region "par1" Specifies the location (par1,ams1) [$SCALEWAY_REGION]
7981
--scaleway-token Scaleway token [$SCALEWAY_TOKEN]
8082
--scaleway-user "root" Specifies SSH user name [$SCALEWAY_USER]
8183
--scaleway-volumes Attach additional volume (e.g., 50G) [$SCALEWAY_VOLUMES]
82-
--swarm Configure Machine with Swarm
84+
--swarm Configure Machine to join a Swarm cluster
8385
--swarm-addr addr to advertise for Swarm (default: detect and use the machine IP)
8486
--swarm-discovery Discovery service to use with Swarm
8587
--swarm-experimental Enable Swarm experimental features
8688
--swarm-host "tcp://0.0.0.0:3376" ip/socket to listen on for Swarm master
8789
--swarm-image "swarm:latest" Specify Docker image to use for Swarm [$MACHINE_SWARM_IMAGE]
90+
--swarm-join-opt [--swarm-join-opt option --swarm-join-opt option] Define arbitrary flags for Swarm join
8891
--swarm-master Configure Machine to be a Swarm master
89-
--swarm-opt [--swarm-opt option --swarm-opt option] Define arbitrary flags for swarm
92+
--swarm-opt [--swarm-opt option --swarm-opt option] Define arbitrary flags for Swarm master
9093
--swarm-strategy "spread" Define a default scheduling strategy for Swarm
9194
--tls-san [--tls-san option --tls-san option] Support extra SANs for TLS certs
9295
```
@@ -250,6 +253,8 @@ root@ab197ef8bd3c:/# exit
250253

251254
### master (unreleased)
252255

256+
* Add `--scaleway-region` to start server on different location e.g. `ams1` (Amsterdam)
257+
* Fix `user-agent` format
253258
* Add `--scaleway-ipv6` ([#50](https://github.com/scaleway/docker-machine-driver-scaleway/issues/50))
254259
* Add `--scaleway-port`
255260
* Add `--scaleway-user`

driver/scaleway.go

+18-6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/docker/machine/libmachine/state"
1818
"github.com/moul/anonuuid"
1919
"github.com/scaleway/scaleway-cli/pkg/api"
20+
"github.com/scaleway/scaleway-cli/pkg/clilogger"
2021
"github.com/scaleway/scaleway-cli/pkg/config"
2122
)
2223

@@ -37,6 +38,7 @@ type Driver struct {
3738
IPID string
3839
Token string
3940
CommercialType string
41+
Region string
4042
name string
4143
image string
4244
ip string
@@ -56,9 +58,12 @@ func (d *Driver) DriverName() string {
5658
return fmt.Sprintf("scaleway(%v)", d.CommercialType)
5759
}
5860

59-
func (d *Driver) getClient() (cl *api.ScalewayAPI, err error) {
61+
func (d *Driver) getClient(region string) (cl *api.ScalewayAPI, err error) {
6062
if scwAPI == nil {
61-
scwAPI, err = api.NewScalewayAPI(d.Organization, d.Token, "docker-machine-driver-scaleway/"+VERSION)
63+
if region == "" {
64+
region = "par1"
65+
}
66+
scwAPI, err = api.NewScalewayAPI(d.Organization, d.Token, "docker-machine-driver-scaleway/"+VERSION, region, clilogger.SetupLogger)
6267
}
6368
cl = scwAPI
6469
return
@@ -86,6 +91,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) (err error) {
8691
}
8792
}
8893
d.CommercialType = flags.String("scaleway-commercial-type")
94+
d.Region = flags.String("scaleway-region")
8995
d.name = flags.String("scaleway-name")
9096
d.image = flags.String("scaleway-image")
9197
d.ip = flags.String("scaleway-ip")
@@ -127,6 +133,12 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
127133
Usage: "Specifies the commercial type",
128134
Value: "VC1S",
129135
},
136+
mcnflag.StringFlag{
137+
EnvVar: "SCALEWAY_REGION",
138+
Name: "scaleway-region",
139+
Usage: "Specifies the location (par1,ams1)",
140+
Value: "par1",
141+
},
130142
mcnflag.StringFlag{
131143
EnvVar: "SCALEWAY_IMAGE",
132144
Name: "scaleway-image",
@@ -236,7 +248,7 @@ func (d *Driver) Create() (err error) {
236248
return
237249
}
238250
log.Infof("Creating server...")
239-
cl, err = d.getClient()
251+
cl, err = d.getClient(d.Region)
240252
if err != nil {
241253
return
242254
}
@@ -274,7 +286,7 @@ func (d *Driver) GetState() (st state.State, err error) {
274286
var cl *api.ScalewayAPI
275287

276288
st = state.Error
277-
cl, err = d.getClient()
289+
cl, err = d.getClient(d.Region)
278290
if err != nil {
279291
return
280292
}
@@ -314,7 +326,7 @@ func (d *Driver) GetURL() (string, error) {
314326
func (d *Driver) postAction(action string) (err error) {
315327
var cl *api.ScalewayAPI
316328

317-
cl, err = d.getClient()
329+
cl, err = d.getClient(d.Region)
318330
if err != nil {
319331
return
320332
}
@@ -331,7 +343,7 @@ func (d *Driver) Kill() error {
331343
func (d *Driver) Remove() (err error) {
332344
var cl *api.ScalewayAPI
333345

334-
cl, err = d.getClient()
346+
cl, err = d.getClient(d.Region)
335347
if err != nil {
336348
return
337349
}

0 commit comments

Comments
 (0)