Skip to content

Commit 02077c9

Browse files
authored
feat: specify req client header with -ldflag (#1318)
* feat: specify req client header with -ldflag * changelog 1318
1 parent 0e5afc8 commit 02077c9

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

.changelog/1318.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
provider: Specify req client header with -ldflag
3+
```

.goreleaser.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ builds:
1010
flags:
1111
- -trimpath
1212
ldflags:
13-
- '-s -w -X main.version={{.Version}} -X main.commit={{.Commit}}'
13+
- '-s -w -X main.Version={{.Version}} -X main.commit={{.Commit}} -X github.com/tencentcloudstack/terraform-provider-tencentcloud/tencentcloud/connectivity.ReqClient=Terraform-{{.Version}}'
1414
goos:
1515
- freebsd
1616
- windows

tencentcloud/connectivity/transport.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,14 @@ import (
1010
"time"
1111
)
1212

13-
const ReqClient = "Terraform-v1.56.1"
13+
var ReqClient = "Terraform-latest"
14+
15+
func SetReqClient(name string) {
16+
if name == "" {
17+
return
18+
}
19+
ReqClient = name
20+
}
1421

1522
type LogRoundTripper struct {
1623
}
@@ -62,7 +69,7 @@ func (me *LogRoundTripper) log(in []byte, out []byte, err error, start time.Time
6269
buf.WriteString("######")
6370
tag := "[DEBUG]"
6471
if err != nil {
65-
tag = "[CRITAL]"
72+
tag = "[CRITICAL]"
6673
}
6774
buf.WriteString(tag)
6875
if len(in) > 0 {

0 commit comments

Comments
 (0)