From 052949cfbc03163e787ee6b7ba6170e0e9d88188 Mon Sep 17 00:00:00 2001 From: telyn Date: Tue, 8 Jan 2019 10:29:11 +0000 Subject: [PATCH 1/3] add bytemark-cluster flag --- driver/bytemark.go | 5 ++++- driver/driver.go | 3 ++- driver/flags.go | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/driver/bytemark.go b/driver/bytemark.go index 2dec259..cba35ed 100644 --- a/driver/bytemark.go +++ b/driver/bytemark.go @@ -72,7 +72,10 @@ func (d *Driver) getClient() (lib.Client, error) { if err != nil { return nil, fmt.Errorf("Could not find a token: %s. Please set BYTEMARK_AUTH_TOKEN environment variable", err) } - client, err := lib.New() + urls := lib.EndpointURLs{ + Brain: d.ClusterURL, + } + client, err := lib.NewWithURLs(urls) if err != nil { return nil, fmt.Errorf("Could not create client: %s", err) } diff --git a/driver/driver.go b/driver/driver.go index 5895baf..6933acc 100644 --- a/driver/driver.go +++ b/driver/driver.go @@ -18,7 +18,8 @@ type Driver struct { spec brain.VirtualMachineSpec - Token string + ClusterURL string + Token string client lib.Client vmCached *brain.VirtualMachine diff --git a/driver/flags.go b/driver/flags.go index 35f4585..e0ee070 100644 --- a/driver/flags.go +++ b/driver/flags.go @@ -10,6 +10,12 @@ import ( // "docker hosts create" func (d *Driver) GetCreateFlags() []mcnflag.Flag { return []mcnflag.Flag{ + mcnflag.StringFlag{ + Name: "bytemark-cluster", + Usage: "HTTP(S) root URL of cluster endpoint", + Value: "https://uk0.bigv.io", + EnvVar: "BYTEMARK_CLUSTER_URL", + }, mcnflag.StringFlag{ Name: "bytemark-zone", Usage: "Zone", @@ -68,6 +74,7 @@ func (d *Driver) setServerSpecFromFlags(flags drivers.DriverOptions) { // SetConfigFromFlags initializes the driver based on the command line flags. func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) (err error) { + d.ClusterURL = flags.String("bytemark-cluster") d.setServerSpecFromFlags(flags) d.Token = flags.String("bytemark-token") From 82bea0b6c488e4d8954e46ed8b27ea86a9b005c5 Mon Sep 17 00:00:00 2001 From: telyn Date: Wed, 9 Jan 2019 16:21:37 +0000 Subject: [PATCH 2/3] add backward-compatibility with machines created prior to cluster-url flag by defaulting it in getClient --- driver/bytemark.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/driver/bytemark.go b/driver/bytemark.go index cba35ed..9f4a76c 100644 --- a/driver/bytemark.go +++ b/driver/bytemark.go @@ -72,6 +72,9 @@ func (d *Driver) getClient() (lib.Client, error) { if err != nil { return nil, fmt.Errorf("Could not find a token: %s. Please set BYTEMARK_AUTH_TOKEN environment variable", err) } + if d.ClusterURL == "" { + d.ClusterURL = lib.DefaultURLs().Brain + } urls := lib.EndpointURLs{ Brain: d.ClusterURL, } From 0b4609dba726a8cc99ce33b44ca692fef2149108 Mon Sep 17 00:00:00 2001 From: telyn Date: Wed, 9 Jan 2019 16:21:52 +0000 Subject: [PATCH 3/3] add changelog entry and improve --debug logging --- CHANGELOG.md | 5 +++++ driver/driver.go | 2 ++ 2 files changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d1385f..100560e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [0.2] +### Added +* Added `bytemark-cluster` flag to set the API endpoint to use. +* Supplying the `debug` flag now causes bytemark-client's debug output to be output too. + ## [0.1] ### Added diff --git a/driver/driver.go b/driver/driver.go index 6933acc..f8d917f 100644 --- a/driver/driver.go +++ b/driver/driver.go @@ -6,6 +6,7 @@ import ( "github.com/BytemarkHosting/bytemark-client/lib" "github.com/BytemarkHosting/bytemark-client/lib/brain" + bmlog "github.com/BytemarkHosting/bytemark-client/util/log" "github.com/docker/machine/libmachine/drivers" "github.com/docker/machine/libmachine/state" ) @@ -28,6 +29,7 @@ type Driver struct { // NewDriver creates a Driver with the specified storePath. func NewDriver(machineName string, storePath string) *Driver { + bmlog.DebugLevel = 5 defaultDiscs := brain.Discs{ brain.Disc{ Label: "disk-1",