Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion cluster-autoscaler/cloudprovider/exoscale/exoscale_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"errors"
"fmt"
"net/http"
"os"

"k8s.io/autoscaler/cluster-autoscaler/cloudprovider"
Expand All @@ -38,6 +39,18 @@ type exoscaleClient interface {
ScaleSKSNodepool(context.Context, string, *egoscale.SKSCluster, *egoscale.SKSNodepool, int64) error
}

// userAgentRoundTripper is a roundtripper which updates the user-agent header.
// This roundtripper can be deleted with egoscale v3.
type userAgentRoundTripper struct {
next http.RoundTripper
}

func (rt *userAgentRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
req.Header.Add("User-Agent", "k8s.io/cluster-auto-scaler "+egoscale.UserAgent)

return rt.next.RoundTrip(req)
}

const defaultAPIEnvironment = "api"

// Manager handles Exoscale communication and data caching of
Expand Down Expand Up @@ -75,7 +88,12 @@ func newManager(discoveryOpts cloudprovider.NodeGroupDiscoveryOptions) (*Manager
apiEnvironment = defaultAPIEnvironment
}

client, err := egoscale.NewClient(apiKey, apiSecret)
client, err := egoscale.NewClient(
apiKey, apiSecret,
egoscale.ClientOptWithHTTPClient(&http.Client{
Transport: &userAgentRoundTripper{next: http.DefaultTransport},
}),
)
if err != nil {
return nil, err
}
Expand Down