Skip to content
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

chore: specific user agent #1129

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions mgc/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

func main() {
defer panicRecover()
mgcSdk.SetUserAgent("MgcCLI")

err := cmd.Execute()
if err != nil {
Expand Down
8 changes: 7 additions & 1 deletion mgc/sdk/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ type contextKey string

var ctxWrappedKey contextKey = "magalu.cloud/sdk/SdkWrapped"

var currentUserAgent string = "MgcSDK"

func SetUserAgent(userAgent string) {
currentUserAgent = userAgent
}

func NewSdk() *Sdk {
return &Sdk{}
}
Expand Down Expand Up @@ -156,7 +162,7 @@ func (o *Sdk) Group() core.Grouper {
}

func newHttpTransport() http.RoundTripper {
userAgent := "MgcSDK/" + Version
userAgent := currentUserAgent + "/" + Version

// To avoid creating a transport with zero values, we leverage
// DefaultTransport (exemple: `Proxy: ProxyFromEnvironment`)
Expand Down
2 changes: 1 addition & 1 deletion mgc/sdk/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.21.1
v0.22.0
2 changes: 1 addition & 1 deletion mgc/sdk/version_development.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ var Version = func() string {
return fmt.Sprintf("%s-%s-%s%s", version, vcs, rev, status)
}
}
return version + "dev"
return version + " dev"
}()
1 change: 1 addition & 0 deletions mgc/terraform-provider-mgc/internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ func (p *MgcProvider) DataSources(ctx context.Context) []func() datasource.DataS

func New(version string, commit string, date string) func() provider.Provider {
sdk := mgcSdk.NewSdk()
mgcSdk.SetUserAgent("MgcTF")

return func() provider.Provider {
return &MgcProvider{
Expand Down
Loading