Skip to content

Commit 478877b

Browse files
committed
Merge remote-tracking branch 'upstream/master' into add_pr_template
2 parents 254325f + 8d3ba22 commit 478877b

File tree

3 files changed

+31
-12
lines changed

3 files changed

+31
-12
lines changed

provision/azure_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func Test_Azure_Auth_Contents_Invalid(t *testing.T) {
1111
_, err := NewAzureProvisioner("SubscriptionID", "invalid contents")
1212

1313
if err == nil {
14-
t.Errorf("want: error, but got: nil")
14+
t.Fatalf("want: error, but got: nil")
1515
}
1616
}
1717

provision/linode.go

+14-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package provision
33
import (
44
"context"
55
"fmt"
6+
"net/http"
7+
"strconv"
8+
69
"github.com/linode/linodego"
710
"github.com/sethvargo/go-password/password"
811
"golang.org/x/oauth2"
9-
"net/http"
10-
"strconv"
1112
)
1213

1314
type LinodeInterface interface {
@@ -65,6 +66,10 @@ func NewLinodeProvisioner(apiKey string) (*LinodeProvisioner, error) {
6566
// Provision provisions a new Linode instance as an exit node
6667
func (p *LinodeProvisioner) Provision(host BasicHost) (*ProvisionedHost, error) {
6768

69+
if len(host.Name) > 32 {
70+
return nil, fmt.Errorf("name cannot be longer than 32 characters for Linode due to label limitations")
71+
}
72+
6873
// Stack script is how linode does the cloud-init when provisioning a VM.
6974
// Stack script is the inlets user data containing inlets auth token.
7075
// Making stack script public will allow everyone to read the stack script
@@ -87,8 +92,13 @@ func (p *LinodeProvisioner) Provision(host BasicHost) (*ProvisionedHost, error)
8792
return nil, err
8893
}
8994
instanceOptions := linodego.InstanceCreateOptions{
90-
Label: "inlets-" + host.Name, StackScriptID: stackscript.ID,
91-
Image: host.OS, Region: host.Region, Type: host.Plan, RootPass: rootPassword,
95+
Label: host.Name,
96+
StackScriptID: stackscript.ID,
97+
Image: host.OS,
98+
Region: host.Region,
99+
Type: host.Plan,
100+
RootPass: rootPassword,
101+
Tags: []string{"inlets"},
92102
}
93103
instance, err := p.client.CreateInstance(instanceOptions)
94104
if err != nil {

provision/linode_test.go

+16-7
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,15 @@ func Test_Linode_Provision(t *testing.T) {
3131
returnedStackscript := &linodego.Stackscript{ID: 10}
3232

3333
expectedInstanceOptions := linodego.InstanceCreateOptions{
34-
Label: "inlets-" + host.Name, StackScriptID: returnedStackscript.ID,
35-
Image: host.OS, Region: host.Region, Type: host.Plan, RootPass: "testpass",
34+
Label: host.Name,
35+
StackScriptID: returnedStackscript.ID,
36+
Image: host.OS,
37+
Region: host.Region,
38+
Type: host.Plan,
39+
RootPass: "testpass",
40+
Tags: []string{"inlets"},
3641
}
42+
3743
returnedInstance := &linodego.Instance{
3844
ID: 42,
3945
Status: linodego.InstanceBooting,
@@ -43,19 +49,22 @@ func Test_Linode_Provision(t *testing.T) {
4349
mockClient.EXPECT().CreateInstance(gomock.Any()).Return(returnedInstance, nil).Times(1).
4450
Do(func(instanceOptions linodego.InstanceCreateOptions) {
4551
if instanceOptions.Label != expectedInstanceOptions.Label {
46-
t.Fail()
52+
t.Fatalf("Label didn't match")
4753
}
4854
if instanceOptions.StackScriptID != expectedInstanceOptions.StackScriptID {
49-
t.Fail()
55+
t.Fatalf("StackScriptID didn't match")
5056
}
5157
if instanceOptions.Image != expectedInstanceOptions.Image {
52-
t.Fail()
58+
t.Fatalf("Image didn't match")
5359
}
5460
if instanceOptions.Region != expectedInstanceOptions.Region {
55-
t.Fail()
61+
t.Fatalf("Region didn't match")
5662
}
5763
if instanceOptions.Type != expectedInstanceOptions.Type {
58-
t.Fail()
64+
t.Fatalf("Type didn't match")
65+
}
66+
if len(instanceOptions.Tags) != len(expectedInstanceOptions.Tags) {
67+
t.Fatalf("tags don't match")
5968
}
6069
})
6170
provisionedHost, _ := provisioner.Provision(host)

0 commit comments

Comments
 (0)