Skip to content

Commit 7cf6431

Browse files
authored
Use new environment variables format in Docker-Machine (#13)
* Use new environment variables format in Docker-Machine * Locally build H1-CLI
1 parent 40c15e0 commit 7cf6431

5 files changed

Lines changed: 29 additions & 21 deletions

File tree

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,6 @@ jobs:
1818
- stage: build & test
1919
script:
2020
- docker build . -f e2e/Dockerfile -t machine-e2e
21-
- docker run -e HYPERONE_PROJECT="any" -e HYPERONE_TOKEN="$H1_TOKEN" -e H1_TOKEN="$H1_TOKEN" machine-e2e bats e2e/lifecycle.bats
21+
# HYPERONE_PROJECT and HYPERONE_ACCESS_TOKEN_SECRET required by Docker-Machine
22+
# HYPERONE_ACCESS_TOKEN_SECRET required by H1-CLI
23+
- docker run -e HYPERONE_PROJECT="any" -e HYPERONE_ACCESS_TOKEN_SECRET="$H1_TOKEN" machine-e2e bats e2e/lifecycle.bats

README.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Official documentation for Docker Machine is available on [website](https://docs
4343
To create a HyperOne Virtual Machine for Docker purposes just run this command:
4444

4545
```shell
46-
$ docker-machine create --driver hyperone --hyperone-token TOKEN --hyperone-project PROJECT vm
46+
$ docker-machine create --driver hyperone --hyperone-access-token-secret TOKEN --hyperone-project PROJECT vm
4747
Running pre-create checks...
4848
Creating machine...
4949
(vm) Creating HyperOne VM...
@@ -63,7 +63,6 @@ To see how to connect your Docker Client to the Docker Engine running on this vi
6363
Available options:
6464

6565
```shell
66-
$ docker-machine create -d hyperone -h
6766
Usage: docker-machine create [OPTIONS] [arg...]
6867

6968
Create a machine
@@ -81,13 +80,13 @@ Options:
8180
--engine-opt [--engine-opt option --engine-opt option] Specify arbitrary flags to include with the created engine in the form flag=value
8281
--engine-registry-mirror [--engine-registry-mirror option --engine-registry-mirror option] Specify registry mirrors to use [$ENGINE_REGISTRY_MIRROR]
8382
--engine-storage-driver Specify a storage driver to use with the engine
84-
--hyperone-disk-name "os-disk" HyperOne VM OS Disk Name [$HYPERONE_DIKE_NAME]
85-
--hyperone-disk-size "20" HyperOne VM OS Disk Size [$HYPERONE_DIKE_SIZE]
86-
--hyperone-disk-type "ssd" HyperOne VM OS Disk Type [$HYPERONE_DIKE_TYPE]
83+
--hyperone-access-token-secret HyperOne Access Token Secret [$HYPERONE_ACCESS_TOKEN_SECRET]
84+
--hyperone-disk-name "os-disk" HyperOne VM OS Disk Name [$HYPERONE_DISK_NAME]
85+
--hyperone-disk-size "20" HyperOne VM OS Disk Size [$HYPERONE_DISK_SIZE]
86+
--hyperone-disk-type "ssd" HyperOne VM OS Disk Type [$HYPERONE_DISK_TYPE]
8787
--hyperone-image "debian" HyperOne Image [$HYPERONE_IMAGE]
8888
--hyperone-project HyperOne Project [$HYPERONE_PROJECT]
8989
--hyperone-ssh-user "guru" SSH Username [$HYPERONE_SSH_USER]
90-
--hyperone-token HyperOne Token [$HYPERONE_TOKEN]
9190
--hyperone-type "a1.micro" HyperOne VM Type [$HYPERONE_TYPE]
9291
--swarm Configure Machine to join a Swarm cluster
9392
--swarm-addr addr to advertise for Swarm (default: detect and use the machine IP)
@@ -125,4 +124,4 @@ After the build is complete, ```docker-machine-driver-hyperone``` binary will be
125124
126125
### Running tests
127126
128-
For details how to run tests read the contents of the ```.travis.yml``` file.
127+
For details how to run tests read the contents of the ```.travis.yml``` file.

driver/hyperone.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ type Driver struct {
4343
func (d *Driver) GetCreateFlags() []mcnflag.Flag {
4444
return []mcnflag.Flag{
4545
mcnflag.StringFlag{
46-
EnvVar: "HYPERONE_TOKEN",
47-
Name: "hyperone-token",
48-
Usage: "HyperOne Token",
46+
EnvVar: "HYPERONE_ACCESS_TOKEN_SECRET",
47+
Name: "hyperone-access-token-secret",
48+
Usage: "HyperOne Access Token Secret",
4949
},
5050
mcnflag.StringFlag{
5151
EnvVar: "HYPERONE_PROJECT",
@@ -71,19 +71,19 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
7171
Value: defaultType,
7272
},
7373
mcnflag.StringFlag{
74-
EnvVar: "HYPERONE_DIKE_NAME",
74+
EnvVar: "HYPERONE_DISK_NAME",
7575
Name: "hyperone-disk-name",
7676
Usage: "HyperOne VM OS Disk Name",
7777
Value: defaultDiskName,
7878
},
7979
mcnflag.StringFlag{
80-
EnvVar: "HYPERONE_DIKE_TYPE",
80+
EnvVar: "HYPERONE_DISK_TYPE",
8181
Name: "hyperone-disk-type",
8282
Usage: "HyperOne VM OS Disk Type",
8383
Value: defaultDiskType,
8484
},
8585
mcnflag.IntFlag{
86-
EnvVar: "HYPERONE_DIKE_SIZE",
86+
EnvVar: "HYPERONE_DISK_SIZE",
8787
Name: "hyperone-disk-size",
8888
Usage: "HyperOne VM OS Disk Size",
8989
Value: defaultDiskSize,
@@ -97,7 +97,7 @@ func (d *Driver) DriverName() string {
9797
}
9898

9999
func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
100-
d.Token = flags.String("hyperone-token")
100+
d.Token = flags.String("hyperone-access-token-secret")
101101
d.Project = flags.String("hyperone-project")
102102
d.Image = flags.String("hyperone-image")
103103
d.Type = flags.String("hyperone-type")
@@ -107,7 +107,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
107107
d.SSHUser = flags.String("hyperone-ssh-user")
108108

109109
if d.Token == "" {
110-
return fmt.Errorf("hyperone driver requires the --hyperone-token option")
110+
return fmt.Errorf("hyperone driver requires the --hyperone-access-token-secret option")
111111
}
112112

113113
if d.Project == "" {

e2e/Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1+
FROM node:alpine as cli_builder
2+
RUN apk add --no-cache libstdc++
3+
RUN wget https://github.com/hyperonecom/h1-cli/archive/develop.tar.gz
4+
RUN tar xvzf develop.tar.gz
5+
WORKDIR /h1-cli-develop
6+
RUN npm install .
7+
RUN npx pkg -c package.json -t "node12-alpine" -o "./dist/h1" "./bin/h1"
8+
19
FROM golang:alpine
210
# Setup
3-
RUN apk add curl bats git make gcc musl-dev findutils grep docker
11+
COPY --from=cli_builder /h1-cli-develop/dist/h1 /bin/h1
12+
RUN apk add --no-cache libstdc++ curl bats git make gcc musl-dev findutils grep docker
413
RUN base="https://github.com/docker/machine/releases/latest/download" \
514
&& curl -L $base/docker-machine-$(uname -s)-$(uname -m) >/usr/local/bin/docker-machine \
615
&& chmod +x /usr/local/bin/docker-machine
7-
RUN curl -s -L "https://github.com/hyperonecom/h1-cli/releases/latest/download/h1-alpine" -o /bin/h1 \
8-
&& chmod +x /bin/h1
916
# Build
1017
WORKDIR /src
1118
ADD ./ /src/

e2e/lifecycle.bats

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
# delete any VM and disk with the text "machinebats" within the name.
55

66
# Required parameters
7-
: ${HYPERONE_TOKEN:?}
7+
: ${HYPERONE_ACCESS_TOKEN_SECRET:?}
88
: ${HYPERONE_PROJECT:?}
99
command -v h1 >/dev/null 2>&1 || {
1010
echo "'h1' must be installed" >&2
1111
exit 1
1212
}
1313

1414
USER_VARS="--hyperone-disk-name machinebats-os-disk"
15-
USER_VARS="${USER_VARS} --hyperone-token ${HYPERONE_TOKEN}"
15+
USER_VARS="${USER_VARS} --hyperone-access-token-secret ${HYPERONE_ACCESS_TOKEN_SECRET}"
1616
USER_VARS="${USER_VARS} --hyperone-project ${HYPERONE_PROJECT}"
1717

1818
hyperone_has_resource() {

0 commit comments

Comments
 (0)