WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 2af07d8

Browse files
zechen0alexellis
authored andcommitted
Add Linode provisioner
Signed-off-by: Ze Chen <[email protected]>
1 parent feb2422 commit 2af07d8

File tree

10 files changed

+535
-8
lines changed

10 files changed

+535
-8
lines changed

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Completed:
4848
* [x] Provisioner: Packet.com
4949
* [x] Provisioner: AWS EC2
5050
* [x] Provisioner: Azure
51+
* [x] Provisioner: Linode
5152
* [x] `inletsctl delete` command
5253
* [x] Add poll interval `--poll 5s` for use with Civo that applies rate-limiting
5354
* [x] Install `inlets/inlets-pro` via `inletsctl download` [#12](https://github.com/inlets/inletsctl/issues/12)
@@ -235,6 +236,24 @@ inletsctl delete --provider=azure --id inlets-clever-volhard8 \
235236
--region=eastus --access-token-file=~/Downloads/client_credentials.json
236237
```
237238

239+
### Example usage with Linode
240+
241+
Prerequisites:
242+
243+
* Prepare a Linode API Access Token. See [Create Linode API Access token](https://www.linode.com/docs/platform/api/getting-started-with-the-linode-api/#get-an-access-token)
244+
245+
246+
Create
247+
```sh
248+
inletsctl create --provider=linode --access-token=<API Access Token> --region=us-east
249+
```
250+
251+
Delete
252+
```sh
253+
inletsctl delete --provider=linode --access-token=<API Access Token> --id <instance id>
254+
```
255+
256+
238257
## Downloading inlets or inlets-pro
239258

240259
The `inletsctl download` command can be used to download the inlets or inltets-pro binaries from github

cmd/create.go

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func init() {
2727

2828
inletsCmd.AddCommand(createCmd)
2929

30-
createCmd.Flags().StringP("provider", "p", "digitalocean", "The cloud provider - digitalocean, gce, ec2, azure, packet, scaleway, or civo")
30+
createCmd.Flags().StringP("provider", "p", "digitalocean", "The cloud provider - digitalocean, gce, ec2, azure, packet, scaleway, linode or civo")
3131
createCmd.Flags().StringP("region", "r", "lon1", "The region for your cloud provider")
3232
createCmd.Flags().StringP("zone", "z", "us-central1-a", "The zone for the exit node (Google Compute Engine)")
3333

@@ -54,7 +54,7 @@ var createCmd = &cobra.Command{
5454
along with what OS version and spec will be used is explained in the README.
5555
`,
5656
Example: ` inletsctl create \
57-
--provider [digitalocean|packet|ec2|scaleway|civo|gce|azure] \
57+
--provider [digitalocean|packet|ec2|scaleway|civo|gce|azure|linode] \
5858
--access-token-file $HOME/access-token \
5959
--region lon1
6060
@@ -261,6 +261,8 @@ func getProvisioner(provider, accessToken, accessTokenFile, secretKey, organisat
261261
return provision.NewEC2Provisioner(region, accessToken, secretKey)
262262
} else if provider == "azure" {
263263
return provision.NewAzureProvisioner(subscriptionID, accessTokenFile)
264+
} else if provider == "linode" {
265+
return provision.NewLinodeProvisioner(accessToken)
264266
}
265267
return nil, fmt.Errorf("no provisioner for provider: %s", provider)
266268
}
@@ -357,6 +359,24 @@ func createHost(provider, name, region, zone, projectID, userData, inletsPort st
357359
"imageVersion": "latest",
358360
},
359361
}, nil
362+
} else if provider == "linode" {
363+
// Image:
364+
// List of images can be retrieved using: https://api.linode.com/v4/images
365+
// Example response: .."id": "linode/ubuntu16.04lts", "label": "Ubuntu 16.04 LTS"..
366+
// Type:
367+
// Type is the VM plan / size in linode.
368+
// List of type and price can be retrieved using curl https://api.linode.com/v4/linode/types
369+
return &provision.BasicHost{
370+
Name: name,
371+
OS: "linode/ubuntu16.04lts",
372+
Plan: "g6-nanode-1",
373+
Region: region,
374+
UserData: userData,
375+
Additional: map[string]string{
376+
"inlets-port": inletsPort,
377+
"pro": fmt.Sprint(pro),
378+
},
379+
}, nil
360380
}
361381

362382
return nil, fmt.Errorf("no provisioner for provider: %q", provider)

cmd/delete.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313

1414
func init() {
1515
inletsCmd.AddCommand(deleteCmd)
16-
deleteCmd.Flags().StringP("provider", "p", "digitalocean", "The cloud provider - digitalocean, gce, ec2, packet, scaleway, or civo")
16+
deleteCmd.Flags().StringP("provider", "p", "digitalocean", "The cloud provider - digitalocean, gce, ec2, azure, packet, scaleway, linode or civo")
1717
deleteCmd.Flags().StringP("region", "r", "lon1", "The region for your cloud provider")
1818
deleteCmd.Flags().StringP("zone", "z", "us-central1-a", "The zone for the exit node (Google Compute Engine)")
1919

go.mod

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ require (
1313
github.com/aws/aws-sdk-go v1.26.8
1414
github.com/digitalocean/godo v1.27.0
1515
github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 // indirect
16+
github.com/golang/mock v1.3.1
1617
github.com/google/uuid v1.1.1
18+
github.com/linode/linodego v0.19.0
1719
github.com/morikuni/aec v1.0.0
1820
github.com/packethost/packngo v0.2.0
1921
github.com/pkg/errors v0.8.1
@@ -29,5 +31,4 @@ require (
2931
google.golang.org/appengine v1.6.5 // indirect
3032
google.golang.org/genproto v0.0.0-20191115221424-83cc0476cb11 // indirect
3133
google.golang.org/grpc v1.25.1 // indirect
32-
gopkg.in/yaml.v2 v2.2.7 // indirect
3334
)

0 commit comments

Comments
 (0)