Skip to content

Commit 3d6f85e

Browse files
author
Quentin Brosse
committed
fix: clean and debug the provider (#107)
1 parent d1124af commit 3d6f85e

File tree

682 files changed

+214877
-47199
lines changed

Some content is hidden

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

682 files changed

+214877
-47199
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
*.a
44
*.so
55

6+
# Editors
7+
.idea
8+
69
# Folders
710
# _obj
811
# _test

.travis.yml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,13 @@ language: go
22

33
sudo: false
44

5-
env:
6-
global:
7-
- GO15VENDOREXPERIMENT=1
8-
95
go:
10-
- 1.5.3
11-
- 1.6.1
12-
- 1.x
6+
- 1.11
7+
- 1.12
8+
- 1.13
139

1410
before_install:
15-
- mkdir -p $GOPATH/bin
16-
- curl -L https://github.com/docker/machine/releases/download/v0.7.0/docker-machine-`uname -s`-`uname -m` > $GOPATH/bin/docker-machine && chmod +x $GOPATH/bin/docker-machine
17-
- go get github.com/Azure/go-ansiterm/winterm || true
18-
- go get github.com/docker/go-units || true
11+
- curl -L https://github.com/docker/machine/releases/download/v0.16.2/docker-machine-`uname -s`-`uname -m` > $GOPATH/bin/docker-machine && chmod +x $GOPATH/bin/docker-machine
1912

2013
install:
2114
- go install

Gopkg.lock

Lines changed: 0 additions & 176 deletions
This file was deleted.

Gopkg.toml

Lines changed: 0 additions & 34 deletions
This file was deleted.

driver/scaleway.go

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,24 @@ import (
99
"strings"
1010
"time"
1111

12-
"github.com/Sirupsen/logrus"
1312
"github.com/docker/machine/libmachine/drivers"
1413
"github.com/docker/machine/libmachine/log"
1514
"github.com/docker/machine/libmachine/mcnflag"
1615
"github.com/docker/machine/libmachine/ssh"
1716
"github.com/docker/machine/libmachine/state"
18-
"github.com/moul/anonuuid"
1917
"github.com/scaleway/scaleway-cli/pkg/api"
2018
"github.com/scaleway/scaleway-cli/pkg/clilogger"
2119
"github.com/scaleway/scaleway-cli/pkg/config"
20+
"github.com/sirupsen/logrus"
21+
"moul.io/anonuuid"
2222
)
2323

2424
const (
2525
// VERSION represents the semver version of the package
26-
VERSION = "v1.6"
27-
defaultImage = "265b32a3"
28-
defaultBootscript = ""
26+
VERSION = "v1.6"
27+
28+
// ubuntu_bionic will rase a 'too many candidates error'
29+
defaultImage = "ubuntu-bionic"
2930
)
3031

3132
var scwAPI *api.ScalewayAPI
@@ -79,7 +80,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) (err error) {
7980

8081
d.Token, d.Organization = flags.String("scaleway-token"), flags.String("scaleway-organization")
8182
if d.Token == "" || d.Organization == "" {
82-
config, cfgErr := config.GetConfig()
83+
config, cfgErr := config.GetConfig("")
8384
if cfgErr == nil {
8485
if d.Token == "" {
8586
d.Token = config.Token
@@ -151,7 +152,7 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
151152
EnvVar: "SCALEWAY_BOOTSCRIPT",
152153
Name: "scaleway-bootscript",
153154
Usage: "Specifies the bootscript",
154-
Value: defaultBootscript,
155+
Value: "",
155156
},
156157
mcnflag.StringFlag{
157158
EnvVar: "SCALEWAY_IP",
@@ -255,6 +256,7 @@ func (d *Driver) Create() (err error) {
255256
if err != nil {
256257
return
257258
}
259+
258260
log.Infof("Creating server...")
259261
cl, err = d.getClient(d.Region)
260262
if err != nil {
@@ -263,23 +265,50 @@ func (d *Driver) Create() (err error) {
263265
if err = d.resolveIP(cl); err != nil {
264266
return
265267
}
266-
d.ServerID, err = api.CreateServer(cl, &api.ConfigCreateServer{
268+
269+
config := &api.ConfigCreateServer{
267270
ImageName: d.image,
268271
CommercialType: d.CommercialType,
269272
Name: d.name,
270273
Bootscript: d.bootscript,
274+
BootType: "bootscript",
271275
AdditionalVolumes: d.volumes,
272276
IP: d.IPID,
273277
EnableIPV6: d.ipv6,
274278
Env: strings.Join([]string{"AUTHORIZED_KEY",
275279
strings.Replace(string(publicKey[:len(publicKey)-1]), " ", "_", -1)}, "="),
276-
})
280+
}
281+
if d.bootscript == "" {
282+
config.BootType = "local"
283+
}
284+
d.ServerID, err = api.CreateServer(cl, config)
285+
if err != nil {
286+
return
287+
}
288+
289+
log.Infof("Setting cloud-init config...")
290+
cloudInitConfig := fmt.Sprintf(`#cloud-config
291+
292+
# Some images do not have sudo installed by default.
293+
packages:
294+
- sudo
295+
296+
# Add root to sudoers.
297+
users:
298+
- name: root
299+
ssh-authorized-keys: [%s]
300+
sudo: ['ALL=(ALL) NOPASSWD:ALL']
301+
groups: sudo
302+
`, publicKey)
303+
err = cl.PatchUserdata(d.ServerID, "cloud-init", []byte(cloudInitConfig), false)
277304
if err != nil {
278305
return
279306
}
307+
280308
log.Infof("Starting server...")
281309
err = api.StartServer(cl, d.ServerID, false)
282310
d.created = true
311+
283312
return
284313
}
285314

go.mod

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
module github.com/scaleway/docker-machine-driver-scaleway
2+
3+
replace (
4+
github.com/Sirupsen/logrus => github.com/sirupsen/logrus v1.4.2
5+
github.com/docker/docker => github.com/docker/engine v1.4.2-0.20190822205725-ed20165a37b4
6+
github.com/renstrom/fuzzysearch v1.1.0 => github.com/lithammer/fuzzysearch v1.1.0
7+
)
8+
9+
go 1.11
10+
11+
require (
12+
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
13+
github.com/creack/goselect v0.1.1 // indirect
14+
github.com/docker/docker v1.13.2-0.20170601211448-f5ec1e2936dc // indirect
15+
github.com/docker/go-units v0.4.0 // indirect
16+
github.com/docker/machine v0.16.2
17+
github.com/dustin/go-humanize v1.0.0 // indirect
18+
github.com/google/go-cmp v0.3.1 // indirect
19+
github.com/gorilla/websocket v1.4.1 // indirect
20+
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
21+
github.com/mattn/go-isatty v0.0.11 // indirect
22+
github.com/moul/gotty-client v1.7.0 // indirect
23+
github.com/moul/http2curl v1.0.0 // indirect
24+
github.com/pkg/errors v0.8.1 // indirect
25+
github.com/renstrom/fuzzysearch v1.1.0 // indirect
26+
github.com/samalba/dockerclient v0.0.0-20160531175551-a30362618471 // indirect
27+
github.com/scaleway/scaleway-cli v1.10.2-0.20190910170054-f0ff7c3359bb
28+
github.com/sirupsen/logrus v1.4.2
29+
github.com/smartystreets/goconvey v1.6.4 // indirect
30+
golang.org/x/crypto v0.0.0-20191219195013-becbf705a915 // indirect
31+
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e // indirect
32+
golang.org/x/sys v0.0.0-20191224085550-c709ea063b76 // indirect
33+
gotest.tools v2.2.0+incompatible // indirect
34+
moul.io/anonuuid v1.2.1
35+
)

0 commit comments

Comments
 (0)