-
Notifications
You must be signed in to change notification settings - Fork 130
fix(object): change user-agent #2919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
0bf2f5c
a852f4c
e222b05
8d2bc0b
d03de87
f6d98b9
2eb01d3
de790eb
f2a49bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -37,6 +37,8 @@ const ( | |||||
maxObjectVersionDeletionWorkers = 8 | ||||||
|
||||||
ErrCodeForbidden = "Forbidden" | ||||||
|
||||||
defaultVersion = "v2.49.0" | ||||||
) | ||||||
|
||||||
type scalewayResolver struct { | ||||||
|
@@ -47,8 +49,25 @@ func (r *scalewayResolver) ResolveEndpoint(ctx context.Context, params s3.Endpoi | |||||
return s3.NewDefaultEndpointResolverV2().ResolveEndpoint(ctx, params) | ||||||
} | ||||||
|
||||||
type userAgentRoundTripper struct { | ||||||
defaultRoundTripper http.RoundTripper | ||||||
userAgent string | ||||||
} | ||||||
|
||||||
var userAgent = fmt.Sprintf("scaleway-terraform-provider/%s (%s; %s; %s)", defaultVersion, runtime.Version(), runtime.GOOS, runtime.GOARCH) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could also add the version of terraform as well.
|
||||||
|
||||||
func (r *userAgentRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { | ||||||
req.Header.Set("User-Agent", userAgent) | ||||||
|
||||||
return r.defaultRoundTripper.RoundTrip(req) | ||||||
} | ||||||
|
||||||
func newS3Client(ctx context.Context, region, accessKey, secretKey string, httpClient *http.Client) (*s3.Client, error) { | ||||||
endpoint := "https://s3." + region + ".scw.cloud" | ||||||
httpClient.Transport = &userAgentRoundTripper{ | ||||||
defaultRoundTripper: httpClient.Transport, | ||||||
userAgent: userAgent, | ||||||
} | ||||||
|
||||||
cfg, err := config.LoadDefaultConfig(ctx, | ||||||
config.WithRegion(region), | ||||||
|
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how will this string get maintained through time?