Skip to content

Commit 964fc0c

Browse files
Merge pull request #2 from monochromata/master
Restructure packages for development builds and document building
2 parents 84746f4 + 5d1cee2 commit 964fc0c

File tree

3 files changed

+61
-13
lines changed

3 files changed

+61
-13
lines changed

README.md

Lines changed: 57 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,43 @@
1-
---
2-
description: Hetzner Cloud driver for machine
3-
keywords: machine, hetzner, Hetzner Cloud, driver
4-
title: Hetzner Cloud
5-
---
1+
# Hetzner Cloud Docker machine driver
62

7-
Create Docker machines on [Hetzner Cloud](https://docs.hetzner.cloud/).
3+
[![Go Report Card](https://goreportcard.com/badge/github.com/JonasProgrammer/docker-machine-driver-hetzner)](https://goreportcard.com/report/github.com/JonasProgrammer/docker-machine-driver-hetzner)
4+
[![License](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5+
6+
> This library adds the support for creating [Docker machines](https://github.com/docker/machine) hosted on the [Hetzner Cloud](hetzner.de/cloud).
87
98
You need to create a project-sepcific access token under `Access` > `API Tokens` in the project control panel
109
and pass that to `docker-machine create` with the `--hetzner-api-token` option.
1110

11+
12+
## Building
13+
14+
Use an up-to-date version of [go](https://golang.org/dl)
15+
16+
To use the driver, you can download the sources and build it locally:
17+
18+
# Get sources and build the binary at ~/go/bin/docker-machine-driver-hetzner
19+
go get github.com/jonasprogrammer/docker-machine-driver-hetzner
20+
21+
# Make the binary accessible to docker-machine
22+
export GOPATH=$(go env GOPATH)
23+
export GOBIN=$GOPATH/bin
24+
export PATH="$PATH:$GOBIN"
25+
26+
1227
## Usage
1328

14-
$ docker-machine create --driver hetzner --hetzner-api-token=QJhoRT38JfAUO037PWJ5Zt9iAABIxdxdh4gPqNkUGKIrUMd6I3cPIsfKozI513sy some-machine
29+
$ docker-machine create \
30+
--driver hetzner \
31+
--hetzner-api-token=QJhoRT38JfAUO037PWJ5Zt9iAABIxdxdh4gPqNkUGKIrUMd6I3cPIsfKozI513sy \
32+
some-machine
1533

1634
### Using environment variables
1735

18-
$ HETZNER_API_TOKEN=QJhoRT38JfAUO037PWJ5Zt9iAABIxdxdh4gPqNkUGKIrUMd6I3cPIsfKozI513sy HETZNER_IMAGE=centos-7 docker-machine create --driver hetzner some-machine
36+
$ HETZNER_API_TOKEN=QJhoRT38JfAUO037PWJ5Zt9iAABIxdxdh4gPqNkUGKIrUMd6I3cPIsfKozI513sy \
37+
&& HETZNER_IMAGE=centos-7 \
38+
&& docker-machine create \
39+
--driver hetzner \
40+
some-machine
1941

2042

2143
## Options
@@ -57,3 +79,30 @@ was used during creation.
5779
| `--hetzner-server-location` | `HETZNER_LOCATION` | - *(let Hetzner choose)* |
5880
| `--hetzner-existing-key-path` | `HETZNER_EXISTING_KEY_PATH` | - *(generate new keypair)* |
5981
| `--hetzner-existing-key-id` | `HETZNER_EXISTING_KEY_ID` | 0 *(upload new key)* |
82+
83+
84+
## Development
85+
86+
Fork this repository, yielding `github.com/<yourAccount>/docker-machine-driver-hetzner`.
87+
88+
# Get the sources of your fork and build it locally
89+
go get github.com/<yourAccount>/docker-machine-driver-hetzner
90+
91+
# * This integrates your fork into the $GOPATH (typically pointing at ~/go)
92+
# * Your sources are at $GOPATH/src/github.com/<yourAccount>/docker-machine-driver-hetzner
93+
# * That folder is a local Git repository. You can pull, commit and push from there.
94+
# * The binary will typically be at $GOPATH/bin/docker-machine-driver-hetzner
95+
# * In the source directory $GOPATH/src/github.com/<yourAccount>/docker-machine-driver-hetzner
96+
# you may use go get to re-build the binary.
97+
# * Note: when you build the driver from different repositories, e.g. from your fork
98+
# as well as github.com/jonasprogrammer/docker-machine-driver-hetzner,
99+
# the binary files generated by these builds are all called the same
100+
# and will hence override each other.
101+
102+
# Make the binary accessible to docker-machine
103+
export GOPATH=$(go env GOPATH)
104+
export GOBIN=$GOPATH/bin
105+
export PATH="$PATH:$GOBIN"
106+
107+
# Make docker-machine output help including hetzner-specific options
108+
docker-machine create --driver hetzner

driver/driver.go renamed to driver.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package driver
1+
package main
22

33
import (
44
"fmt"
@@ -128,7 +128,7 @@ func (d *Driver) SetConfigFromFlags(opts drivers.DriverOptions) error {
128128
d.SetSwarmConfigFromFlags(opts)
129129

130130
if d.AccessToken == "" {
131-
return fmt.Errorf("hetnzer erquires --%v to be set", flagApiToken)
131+
return fmt.Errorf("hetzner requires --%v to be set", flagApiToken)
132132
}
133133

134134
return nil
@@ -159,7 +159,7 @@ func (d *Driver) PreCreateCheck() error {
159159

160160
if key.Fingerprint != ssh.FingerprintLegacyMD5(pubk) &&
161161
key.Fingerprint != ssh.FingerprintSHA256(pubk) {
162-
return fmt.Errorf("remote key %d does not fit with local key %s", d.KeyID, d.originalKey)
162+
return fmt.Errorf("remote key %d does not match local key %s", d.KeyID, d.originalKey)
163163
}
164164
}
165165

main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@ package main
22

33
import (
44
"github.com/docker/machine/libmachine/drivers/plugin"
5-
"github.com/jonasprogrammer/docker-machine-driver-hetzner/driver"
65
)
76

87
func main() {
9-
plugin.RegisterDriver(driver.NewDriver())
8+
plugin.RegisterDriver(NewDriver())
109
}

0 commit comments

Comments
 (0)