Skip to content

Commit

Permalink
Merge branch 'set-cluster-from-cmdline' into 'develop'
Browse files Browse the repository at this point in the history
add bytemark-cluster flag

See merge request open-source/docker-machine-driver-bytemark!8
  • Loading branch information
Hannah Pirie committed Jan 10, 2019
2 parents fe5bb52 + 0b4609d commit 0b88560
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
8 changes: 7 additions & 1 deletion driver/bytemark.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ 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()
if d.ClusterURL == "" {
d.ClusterURL = lib.DefaultURLs().Brain
}
urls := lib.EndpointURLs{
Brain: d.ClusterURL,
}
client, err := lib.NewWithURLs(urls)
if err != nil {
return nil, fmt.Errorf("Could not create client: %s", err)
}
Expand Down
5 changes: 4 additions & 1 deletion driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -18,7 +19,8 @@ type Driver struct {

spec brain.VirtualMachineSpec

Token string
ClusterURL string
Token string

client lib.Client
vmCached *brain.VirtualMachine
Expand All @@ -27,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",
Expand Down
7 changes: 7 additions & 0 deletions driver/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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")

Expand Down

0 comments on commit 0b88560

Please sign in to comment.