Skip to content

Commit 756e051

Browse files
Configure API token using LinodeClient{}.SetToken(...) rather than transport; allow configuring LINODE_CA (#188)
* Configure API token using LinodeClient{}.SetToken(...) rather than transport * Fix lint * Update e2e test image
1 parent 548e3e5 commit 756e051

File tree

5 files changed

+53
-13
lines changed

5 files changed

+53
-13
lines changed

.golangci.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
version: "2"
2+
3+
run:
4+
tests: false
5+
6+
linters:
7+
settings:
8+
dupl:
9+
threshold: 100
10+
11+
gomoddirectives:
12+
replace-allow-list:
13+
- github.com/linode/linodego
14+
15+
govet:
16+
disable:
17+
- shadow
18+
19+
revive:
20+
rules:
21+
- name: unused-parameter
22+
severity: warning
23+
disabled: true
24+
25+
staticcheck:
26+
checks: ["all", "-ST1005"]
27+
28+
exclusions:
29+
generated: lax
30+
presets:
31+
- comments
32+
- common-false-positives
33+
- legacy
34+
- std-error-handling
35+
paths:
36+
- third_party$
37+
- builtin$
38+
- examples$
39+
40+
formatters:
41+
exclusions:
42+
generated: lax
43+
paths:
44+
- third_party$
45+
- builtin$
46+
- examples$

driver.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@ import (
55
"encoding/json"
66
"fmt"
77
"net"
8-
"net/http"
98
"os"
109
"path"
1110
"strconv"
1211
"strings"
1312
"sync"
1413
"time"
1514

16-
"golang.org/x/oauth2"
17-
1815
"github.com/docker/go-plugins-helpers/volume"
1916
metadata "github.com/linode/go-metadata"
2017
"github.com/linode/linodego"
@@ -72,16 +69,13 @@ func (driver *linodeVolumeDriver) linodeAPI() (*linodego.Client, error) {
7269
}
7370

7471
func setupLinodeAPI(token string) *linodego.Client {
75-
tokenSource := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: token})
76-
oauth2Client := &http.Client{
77-
Transport: &oauth2.Transport{
78-
Source: tokenSource,
79-
},
80-
}
72+
api := linodego.NewClient(nil)
8173

82-
api := linodego.NewClient(oauth2Client)
8374
ua := fmt.Sprintf("docker-volume-linode/%s linodego/%s", VERSION, linodego.Version)
8475
api.SetUserAgent(ua)
76+
77+
api.SetToken(token)
78+
8579
return &api
8680
}
8781

fs_utils_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func GetFSType(device string) string {
4646
for _, v := range strings.Split(string(out), " ") {
4747
if strings.Contains(v, "TYPE=") {
4848
fsType = strings.Split(v, "=")[1]
49-
fsType = strings.Replace(fsType, "\"", "", -1)
49+
fsType = strings.ReplaceAll(fsType, "\"", "")
5050
}
5151
}
5252
}

integration-test/test.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
label: "{{ label }}"
3636
type: "{{ type }}"
3737
region: "{{ region }}"
38-
image: linode/ubuntu23.10
38+
image: linode/ubuntu24.04
3939
booted: true
4040
metadata:
4141
user_data: '{{ lookup("template", playbook_dir ~ "/harden.yaml.j2") }}'

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func getEnv(name string) (string, bool) {
7979
}
8080

8181
name = strings.ToUpper(name)
82-
name = strings.Replace(name, "-", "_", -1)
82+
name = strings.ReplaceAll(name, "-", "_")
8383

8484
if val, found := os.LookupEnv(name); found {
8585
return val, true

0 commit comments

Comments
 (0)