Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit b1cd919

Browse files
committed
+ add user agent to dns & storage sdk
1 parent 54552f6 commit b1cd919

File tree

3 files changed

+1254
-47
lines changed

3 files changed

+1254
-47
lines changed

gcore/provider.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
gc "github.com/G-Core/gcorelabscloud-go/gcore"
1717
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
1818
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
19+
"github.com/hashicorp/terraform/version"
1920
)
2021

2122
const (
@@ -256,6 +257,7 @@ func providerConfigure(_ context.Context, d *schema.ResourceData) (interface{},
256257
CDNClient: cdnService,
257258
}
258259

260+
userAgent := fmt.Sprintf("terraform/%s", version.Version)
259261
if storageAPI != "" {
260262
stHost, stPath, err := ExtractHostAndPath(storageAPI)
261263
if err != nil {
@@ -266,6 +268,7 @@ func providerConfigure(_ context.Context, d *schema.ResourceData) (interface{},
266268
stPath,
267269
storageSDK.WithBearerAuth(provider.AccessToken),
268270
storageSDK.WithPermanentTokenAuth(func() string { return permanentToken }),
271+
storageSDK.WithUserAgent(userAgent),
269272
)
270273
}
271274
if dnsAPI != "" {
@@ -277,10 +280,15 @@ func providerConfigure(_ context.Context, d *schema.ResourceData) (interface{},
277280
if permanentToken != "" {
278281
authorizer = dnssdk.PermanentAPIKeyAuth(permanentToken)
279282
}
280-
config.DNSClient = dnssdk.NewClient(authorizer, func(client *dnssdk.Client) {
281-
client.BaseURL = baseUrl
282-
client.Debug = os.Getenv("TF_LOG") == "DEBUG"
283-
})
283+
config.DNSClient = dnssdk.NewClient(
284+
authorizer,
285+
func(client *dnssdk.Client) {
286+
client.BaseURL = baseUrl
287+
client.Debug = os.Getenv("TF_LOG") == "DEBUG"
288+
},
289+
func(client *dnssdk.Client) {
290+
client.UserAgent = userAgent
291+
})
284292
}
285293

286294
return &config, diags

go.mod

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ go 1.17
44

55
require (
66
github.com/AlekSi/pointer v1.2.0
7-
github.com/G-Core/gcore-dns-sdk-go v0.2.1
8-
github.com/G-Core/gcore-storage-sdk-go v0.1.2
7+
github.com/G-Core/gcore-dns-sdk-go v0.2.3
8+
github.com/G-Core/gcore-storage-sdk-go v0.1.3
99
github.com/G-Core/gcorelabscdn-go v0.1.20
1010
github.com/G-Core/gcorelabscloud-go v0.4.51
1111
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
@@ -16,18 +16,16 @@ require (
1616
require (
1717
github.com/PuerkitoBio/purell v1.1.1 // indirect
1818
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
19-
github.com/agext/levenshtein v1.2.2 // indirect
20-
github.com/apparentlymart/go-textseg v1.0.0 // indirect
19+
github.com/agext/levenshtein v1.2.3 // indirect
2120
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
2221
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
2322
github.com/davecgh/go-spew v1.1.1 // indirect
24-
github.com/fatih/color v1.7.0 // indirect
23+
github.com/fatih/color v1.9.0 // indirect
2524
github.com/go-openapi/analysis v0.21.2 // indirect
2625
github.com/go-openapi/errors v0.20.2 // indirect
2726
github.com/go-openapi/jsonpointer v0.19.5 // indirect
2827
github.com/go-openapi/jsonreference v0.19.6 // indirect
2928
github.com/go-openapi/loads v0.21.1 // indirect
30-
github.com/go-openapi/runtime v0.23.2 // indirect
3129
github.com/go-openapi/spec v0.20.4 // indirect
3230
github.com/go-openapi/strfmt v0.21.2 // indirect
3331
github.com/go-openapi/swag v0.21.1 // indirect
@@ -36,54 +34,57 @@ require (
3634
github.com/go-playground/universal-translator v0.17.0 // indirect
3735
github.com/go-playground/validator/v10 v10.2.0 // indirect
3836
github.com/go-stack/stack v1.8.1 // indirect
39-
github.com/golang/protobuf v1.4.2 // indirect
37+
github.com/golang/protobuf v1.5.2 // indirect
4038
github.com/google/go-cmp v0.5.7 // indirect
41-
github.com/hashicorp/errwrap v1.0.0 // indirect
39+
github.com/hashicorp/errwrap v1.1.0 // indirect
4240
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
4341
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
4442
github.com/hashicorp/go-hclog v0.16.1 // indirect
4543
github.com/hashicorp/go-multierror v1.1.1 // indirect
46-
github.com/hashicorp/go-plugin v1.4.1 // indirect
44+
github.com/hashicorp/go-plugin v1.4.3 // indirect
4745
github.com/hashicorp/go-uuid v1.0.2 // indirect
4846
github.com/hashicorp/go-version v1.4.0 // indirect
4947
github.com/hashicorp/hc-install v0.3.1 // indirect
50-
github.com/hashicorp/hcl/v2 v2.3.0 // indirect
48+
github.com/hashicorp/hcl/v2 v2.11.1 // indirect
5149
github.com/hashicorp/logutils v1.0.0 // indirect
52-
github.com/hashicorp/terraform-exec v0.16.0 // indirect
5350
github.com/hashicorp/terraform-json v0.13.0 // indirect
54-
github.com/hashicorp/terraform-plugin-docs v0.7.0 // indirect
5551
github.com/hashicorp/terraform-plugin-go v0.5.0 // indirect
5652
github.com/hashicorp/terraform-plugin-log v0.2.0 // indirect
5753
github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896 // indirect
5854
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 // indirect
5955
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
6056
github.com/josharian/intern v1.0.0 // indirect
61-
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
6257
github.com/ladydascalie/currency v1.5.0 // indirect
6358
github.com/leodido/go-urn v1.2.0 // indirect
6459
github.com/mailru/easyjson v0.7.7 // indirect
65-
github.com/mattn/go-colorable v0.1.12 // indirect
6660
github.com/mattn/go-isatty v0.0.14 // indirect
6761
github.com/mitchellh/copystructure v1.2.0 // indirect
6862
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
69-
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
63+
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
7064
github.com/mitchellh/reflectwalk v1.0.2 // indirect
7165
github.com/oklog/run v1.0.0 // indirect
7266
github.com/oklog/ulid v1.3.1 // indirect
7367
github.com/opentracing/opentracing-go v1.2.0 // indirect
7468
github.com/shopspring/decimal v0.0.0-20200227202807-02e2044944cc // indirect
75-
github.com/sirupsen/logrus v1.6.0 // indirect
69+
github.com/sirupsen/logrus v1.7.0 // indirect
7670
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
7771
github.com/zclconf/go-cty v1.10.0 // indirect
78-
go.mongodb.org/mongo-driver v1.8.4 // indirect
79-
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e // indirect
80-
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
72+
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa // indirect
8173
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
8274
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect
8375
golang.org/x/text v0.3.7 // indirect
84-
google.golang.org/appengine v1.6.6 // indirect
85-
google.golang.org/genproto v0.0.0-20200711021454-869866162049 // indirect
86-
google.golang.org/grpc v1.32.0 // indirect
87-
google.golang.org/protobuf v1.25.0 // indirect
76+
google.golang.org/appengine v1.6.7 // indirect
77+
google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1 // indirect
78+
google.golang.org/grpc v1.36.1 // indirect
79+
google.golang.org/protobuf v1.27.1 // indirect
8880
gopkg.in/yaml.v2 v2.4.0 // indirect
8981
)
82+
83+
require (
84+
github.com/go-openapi/runtime v0.23.2 // indirect
85+
github.com/hashicorp/terraform v1.1.9
86+
github.com/hashicorp/terraform-exec v0.16.0 // indirect
87+
github.com/mattn/go-colorable v0.1.12 // indirect
88+
go.mongodb.org/mongo-driver v1.8.4 // indirect
89+
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
90+
)

0 commit comments

Comments
 (0)