Skip to content

Commit 54b6198

Browse files
committed
Merge pull request #5 from QuentinPerez/scw-integration
Scw integration
2 parents 1feb12f + b4134f3 commit 54b6198

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ $> curl --silent http://212.47.248.251 | head -n1 # you can also open your brows
118118
### master (unreleased)
119119

120120
* Sleep only when we stop an host ([#4](https://github.com/scaleway/docker-machine-driver-scaleway/issues/4))
121+
* Loads credentials from `~/.scwrc` if available ([#2](https://github.com/scaleway/docker-machine-driver-scaleway/issues/2))
121122
* Support of `create`
122123
* Support of `start`
123124
* Support of `stop`

driver/scaleway.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/docker/machine/libmachine/ssh"
1515
"github.com/docker/machine/libmachine/state"
1616
"github.com/scaleway/scaleway-cli/pkg/api"
17+
"github.com/scaleway/scaleway-cli/pkg/config"
1718
)
1819

1920
const (
@@ -57,7 +58,17 @@ func (d *Driver) getClient() (cl *api.ScalewayAPI, err error) {
5758
func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) (err error) {
5859
d.Token, d.Organization = flags.String("scaleway-token"), flags.String("scaleway-organization")
5960
if d.Token == "" || d.Organization == "" {
60-
return fmt.Errorf("You must provide organization and token")
61+
config, cfgErr := config.GetConfig()
62+
if cfgErr == nil {
63+
if d.Token == "" {
64+
d.Token = config.Token
65+
}
66+
if d.Organization == "" {
67+
d.Organization = config.Organization
68+
}
69+
} else {
70+
return fmt.Errorf("You must provide organization and token")
71+
}
6172
}
6273
d.commercialType = flags.String("scaleway-commercial-type")
6374
d.name = flags.String("scaleway-name")

0 commit comments

Comments
 (0)