From c6feeb6f0698a7b6475499f086f3df3f784ddd4b Mon Sep 17 00:00:00 2001 From: Lena Garber Date: Thu, 27 Mar 2025 15:27:49 -0400 Subject: [PATCH 1/3] Configure API token using LinodeClient{}.SetToken(...) rather than transport --- driver.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/driver.go b/driver.go index a0dc1b6..f22dd2d 100644 --- a/driver.go +++ b/driver.go @@ -5,7 +5,6 @@ import ( "encoding/json" "fmt" "net" - "net/http" "os" "path" "strconv" @@ -13,8 +12,6 @@ import ( "sync" "time" - "golang.org/x/oauth2" - "github.com/docker/go-plugins-helpers/volume" metadata "github.com/linode/go-metadata" "github.com/linode/linodego" @@ -72,16 +69,13 @@ func (driver *linodeVolumeDriver) linodeAPI() (*linodego.Client, error) { } func setupLinodeAPI(token string) *linodego.Client { - tokenSource := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: token}) - oauth2Client := &http.Client{ - Transport: &oauth2.Transport{ - Source: tokenSource, - }, - } + api := linodego.NewClient(nil) - api := linodego.NewClient(oauth2Client) ua := fmt.Sprintf("docker-volume-linode/%s linodego/%s", VERSION, linodego.Version) api.SetUserAgent(ua) + + api.SetToken(token) + return &api } From d11dea4ed8ce7499345064d0669fd20c5a28a7ff Mon Sep 17 00:00:00 2001 From: Lena Garber Date: Mon, 31 Mar 2025 10:28:59 -0400 Subject: [PATCH 2/3] Fix lint --- .golangci.yml | 46 ++++++++++++++++++++++++++++++++++++++++++++++ fs_utils_linux.go | 2 +- main.go | 2 +- 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 .golangci.yml diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..7f24b0c --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,46 @@ +version: "2" + +run: + tests: false + +linters: + settings: + dupl: + threshold: 100 + + gomoddirectives: + replace-allow-list: + - github.com/linode/linodego + + govet: + disable: + - shadow + + revive: + rules: + - name: unused-parameter + severity: warning + disabled: true + + staticcheck: + checks: ["all", "-ST1005"] + + exclusions: + generated: lax + presets: + - comments + - common-false-positives + - legacy + - std-error-handling + paths: + - third_party$ + - builtin$ + - examples$ + +formatters: + exclusions: + generated: lax + paths: + - third_party$ + - builtin$ + - examples$ diff --git a/fs_utils_linux.go b/fs_utils_linux.go index 96a5fbf..1470bef 100644 --- a/fs_utils_linux.go +++ b/fs_utils_linux.go @@ -46,7 +46,7 @@ func GetFSType(device string) string { for _, v := range strings.Split(string(out), " ") { if strings.Contains(v, "TYPE=") { fsType = strings.Split(v, "=")[1] - fsType = strings.Replace(fsType, "\"", "", -1) + fsType = strings.ReplaceAll(fsType, "\"", "") } } } diff --git a/main.go b/main.go index 4233841..9e1f351 100644 --- a/main.go +++ b/main.go @@ -79,7 +79,7 @@ func getEnv(name string) (string, bool) { } name = strings.ToUpper(name) - name = strings.Replace(name, "-", "_", -1) + name = strings.ReplaceAll(name, "-", "_") if val, found := os.LookupEnv(name); found { return val, true From a9756eed7ee133e655fcaf817a3092263eefd800 Mon Sep 17 00:00:00 2001 From: Lena Garber Date: Fri, 4 Apr 2025 12:32:26 -0400 Subject: [PATCH 3/3] Update e2e test image --- integration-test/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-test/test.yaml b/integration-test/test.yaml index abea53f..2a86126 100644 --- a/integration-test/test.yaml +++ b/integration-test/test.yaml @@ -35,7 +35,7 @@ label: "{{ label }}" type: "{{ type }}" region: "{{ region }}" - image: linode/ubuntu23.10 + image: linode/ubuntu24.04 booted: true metadata: user_data: '{{ lookup("template", playbook_dir ~ "/harden.yaml.j2") }}'