Skip to content

Commit 8ea7005

Browse files
committed
fix user agent with last version
1 parent 5ebf729 commit 8ea7005

File tree

39 files changed

+17860
-17888
lines changed

39 files changed

+17860
-17888
lines changed

internal/services/object/helpers_object.go

+3-31
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"fmt"
88
"net/http"
99
"runtime"
10-
"runtime/debug"
1110
"strings"
1211
"time"
1312

@@ -38,6 +37,8 @@ const (
3837
maxObjectVersionDeletionWorkers = 8
3938

4039
ErrCodeForbidden = "Forbidden"
40+
41+
defaultVersion = "v2.49.0"
4142
)
4243

4344
type scalewayResolver struct {
@@ -53,36 +54,7 @@ type userAgentRoundTripper struct {
5354
userAgent string
5455
}
5556

56-
const (
57-
defaultVersion = "v2.49.0"
58-
path = "https://github.com/scaleway/terraform-provider-scaleway"
59-
)
60-
61-
var cachedVersion = (*string)(nil)
62-
63-
func getVersion() string {
64-
if cachedVersion == nil {
65-
debugVersion := ""
66-
b, ok := debug.ReadBuildInfo()
67-
if ok {
68-
for _, dep := range b.Deps {
69-
if dep.Path == path {
70-
debugVersion = dep.Version
71-
}
72-
}
73-
}
74-
75-
cachedVersion = &debugVersion
76-
}
77-
78-
if *cachedVersion != "" {
79-
return *cachedVersion
80-
}
81-
82-
return defaultVersion
83-
}
84-
85-
var userAgent = fmt.Sprintf("scaleway-terraform-provider/%s (%s; %s; %s)", getVersion(), runtime.Version(), runtime.GOOS, runtime.GOARCH)
57+
var userAgent = fmt.Sprintf("scaleway-terraform-provider/%s (%s; %s; %s)", defaultVersion, runtime.Version(), runtime.GOOS, runtime.GOARCH)
8658

8759
func (r *userAgentRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
8860
req.Header.Set("User-Agent", userAgent)

0 commit comments

Comments
 (0)