From 1fccf33eda2d18947ca0e24e369ac0a3035108db Mon Sep 17 00:00:00 2001 From: Ondrej Kokes Date: Thu, 15 Aug 2024 09:14:33 +0200 Subject: [PATCH] Do not use a custom http.Transport due to Resty incompatibility We're hitting the same issue as here: https://github.com/linode/cluster-api-provider-linode/pull/436 We use a custom CA and it doesn't get used. Given that we construct an http.Transport that is of a different concrete type than http.Transport (it just needs to be a RoundTripper), resty fails and defaults to an empty client, discarding our CA. --- cloud/linode/client/client.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/cloud/linode/client/client.go b/cloud/linode/client/client.go index abf5bee7..639bdcfe 100644 --- a/cloud/linode/client/client.go +++ b/cloud/linode/client/client.go @@ -10,7 +10,6 @@ import ( "time" "github.com/linode/linodego" - "golang.org/x/oauth2" "k8s.io/klog/v2" ) @@ -63,19 +62,13 @@ func New(token string, timeout time.Duration) (*linodego.Client, error) { userAgent := fmt.Sprintf("linode-cloud-controller-manager %s", linodego.DefaultUserAgent) apiURL := os.Getenv("LINODE_URL") - tokenSource := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: token}) - oauth2Client := &http.Client{ - Transport: &oauth2.Transport{ - Source: tokenSource, - }, - Timeout: timeout, - } - linodeClient := linodego.NewClient(oauth2Client) + linodeClient := linodego.NewClient(&http.Client{Timeout: timeout}) client, err := linodeClient.UseURL(apiURL) if err != nil { return nil, err } client.SetUserAgent(userAgent) + client.SetToken(token) klog.V(3).Infof("Linode client created with default timeout of %v", timeout) return client, nil