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

合并 #16

Merged
merged 62 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
d9f390c
fix: test failed on other timezone.(#3181) (#3183)
kvii Feb 2, 2024
c7fa51d
fix: zap log print out multiple `msg` (#3171)
fzdwx Feb 2, 2024
9106991
fix(protoc-gen-go-http): return nil if err == nil。 (#3188)
kvii Feb 14, 2024
50cad79
fix(transport/http): no need to call EncodeURL twice (#3218)
kvii Mar 1, 2024
f566bdc
fix: use .MapKey to get key's FieldDescriptor (#3196)
oyk666 Mar 11, 2024
131df07
build(go): Add go version v1.22.x (#3236)
flc1125 Mar 15, 2024
e11acb6
build(lint): upgrade `golangci/golangci-lint-action` (#3235)
flc1125 Mar 15, 2024
d4edd44
feat(log): Prevent log.Helper sprintf from running early #3209 (#3221)
sendya Mar 15, 2024
6286cdc
build(deps): bump golangci/golangci-lint-action from 3 to 4 (#3197)
dependabot[bot] Mar 15, 2024
63344c3
fix: remove duplicate test codes. (#3187)
kvii Mar 15, 2024
953a331
fix polaris registry bug: nodes is empty at startup (#3160)
libi Mar 15, 2024
7ee76bf
build(deps): bump actions/cache from 3 to 4 (#3158)
dependabot[bot] Mar 15, 2024
be8821e
build(deps): bump golang.org/x/net in /contrib/opensergo (#3155)
dependabot[bot] Mar 15, 2024
ffa1dca
fix: logging middleware caller issue #3133 (#3134)
kvii Mar 15, 2024
4911130
build(deps): bump github.com/prometheus/common (#3154)
dependabot[bot] Mar 15, 2024
05b23fb
build(deps): bump golang.org/x/sync in /contrib/registry/zookeeper (#…
dependabot[bot] Mar 15, 2024
3110168
feat: use writer directly in stdLogger. (#3121)
kvii Mar 16, 2024
1ab258e
fix: etcd registry lifecycle (#3180)
Disdjj Mar 16, 2024
cd9857f
nacos stop cannot cancel subscription (#3173)
chenliang Mar 20, 2024
1fdaabb
fix: When grpc ends idle mode, it needs to continue to obtain the lat…
harbourlga Mar 20, 2024
26d7d5f
feat(transport/http): add unwrap method for returning underlying resp…
kvii Mar 22, 2024
bfafeca
fix(encoding/form): optimize EncodeField and add test cases (#3234)
demoManito Mar 22, 2024
aeecf3c
fix(encoding/form): `Timestamp` use local time and fix test wrong moc…
demoManito Mar 22, 2024
41971ff
deps: upgrade kratos version to v2.7.3 (#3266)
shenqidebaozi Mar 22, 2024
f715eb0
break(metrics): refactor kratos metrics with otel metrics (#3256)
Ccheers Apr 1, 2024
7571109
fix: com patile both map[kratos] and map.kratos for a map type in the…
ASkyFullOfStar Apr 16, 2024
78b67ad
security: upgrade google.golang.org/protobuf to 1.33.0 (#3264)
wudi Apr 20, 2024
3fe570e
dep: change library name of mergo #3149 (#3297)
kvii Apr 22, 2024
c384f91
build(deps): bump golang.org/x/sync in /contrib/registry/zookeeper (#…
dependabot[bot] Apr 22, 2024
4a87ab4
build(deps): bump golang.org/x/net in /contrib/opensergo (#3277)
dependabot[bot] Apr 22, 2024
61cdc7e
build(deps): bump github.com/aliyun/aliyun-log-go-sdk (#3270)
dependabot[bot] Apr 22, 2024
b3b2a34
build(deps): bump google.golang.org/protobuf (#3238)
dependabot[bot] Apr 22, 2024
45603e3
fix(contrib/polaris): incorrect conversion between integer types (#3300)
demoManito Apr 27, 2024
a803e9d
chore(middleware/metrics): if requests and seconds are nil, return di…
Ccheers Apr 27, 2024
be624d0
fix(contrib/opensergo): incorrect conversion between integer types (#…
demoManito Apr 30, 2024
94929eb
build(deps): bump Yikun/hub-mirror-action from 1.3 to 1.4 (#3307)
dependabot[bot] May 4, 2024
d0d5761
build(deps): bump golang.org/x/net in /contrib/polaris (#3296)
dependabot[bot] May 4, 2024
fbac5fa
fix(contrib/registry/nacos): Abnormal blocking of the Subscribe and N…
guoquanwei May 16, 2024
7d3be6b
build(deps): bump github.com/aliyun/aliyun-log-go-sdk (#3332)
dependabot[bot] Jun 1, 2024
c0a7935
faat(encoding/form): allow change the default form encoder and decode…
demoManito Jun 1, 2024
ba5a651
build(deps): bump golangci/golangci-lint-action from 4 to 5 (#3305)
dependabot[bot] Jun 6, 2024
4aa4f7c
The issue that the response header is not assigned a value is fixed (…
shima-park Jun 11, 2024
86e8be9
build(deps): bump golangci/golangci-lint-action from 5 to 6 (#3340)
dependabot[bot] Jun 11, 2024
eb07954
build(deps): bump actions/setup-go from 5.0.0 to 5.0.1 (#3315)
dependabot[bot] Jun 11, 2024
46362d1
feat: parsing config input and convert to match the type (#3306)
akoserwal Jun 15, 2024
3198e0b
adds Set-Cookie method to the HTTP transport. (#3353)
tonybase Jun 27, 2024
7da1bd5
build(deps): bump golang.org/x/net in /contrib/config/etcd (#3293)
dependabot[bot] Jul 19, 2024
73c9b5a
build(deps): bump golang.org/x/net in /contrib/registry/servicecomb (…
dependabot[bot] Jul 19, 2024
7eb39d0
build(deps): bump golang.org/x/net from 0.19.0 to 0.23.0 (#3295)
dependabot[bot] Jul 19, 2024
5bb067a
chroe: chore update (#3367)
yonwoo9 Jul 22, 2024
9260862
deps: upgrade kratos version to v2.8.0 (#3378)
shenqidebaozi Jul 22, 2024
c550cda
fix: filter redundant endpoints invalid (#3373)
LHyphen Jul 25, 2024
bd7a91a
build(deps): bump actions/setup-go from 5.0.1 to 5.0.2 (#3362)
dependabot[bot] Jul 25, 2024
c1fc152
build(deps): bump golang.org/x/net in /contrib/registry/polaris (#3294)
dependabot[bot] Jul 25, 2024
4a11cb9
build(deps): bump golang.org/x/net in /contrib/log/aliyun (#3292)
dependabot[bot] Jul 25, 2024
4044326
build(deps): bump golang.org/x/net in /contrib/registry/kubernetes (#…
dependabot[bot] Jul 25, 2024
24a3f5a
build(deps): bump golang.org/x/net in /contrib/config/kubernetes (#3291)
dependabot[bot] Jul 25, 2024
0cc7ed7
build(deps): bump golang.org/x/net in /contrib/registry/etcd (#3289)
dependabot[bot] Jul 25, 2024
3b2ff19
build(deps): bump golang.org/x/net in /contrib/errortracker/sentry (#…
dependabot[bot] Jul 25, 2024
6e752cc
build(deps): bump google.golang.org/protobuf in /cmd/protoc-gen-go-ht…
dependabot[bot] Jul 25, 2024
d6fca5e
build(deps): bump github/codeql-action from 2 to 3 (#3119)
dependabot[bot] Jul 25, 2024
084c8b4
fix: fixed typo (#3395)
jarium Aug 15, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ jobs:
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: go

- name: CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
2 changes: 1 addition & 1 deletion .github/workflows/gitee-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Checkout source code
uses: actions/checkout@v4
- name: Mirror Github to Gitee
uses: Yikun/hub-mirror-action@v1.3
uses: Yikun/hub-mirror-action@v1.4
with:
src: github/go-kratos
dst: gitee/go-kratos
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
build:
strategy:
matrix:
go: [1.19,1.20.x,1.21.x]
go: [ 1.20.x, 1.21.x, 1.22.x ]
name: build & test
runs-on: ubuntu-latest
services:
Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/[email protected].0
uses: actions/[email protected].2
with:
go-version: ${{ matrix.go }}

Expand All @@ -54,7 +54,7 @@ jobs:
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH

- name: Module cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v6
with:
version: v1.54.2
working-directory: ${{ matrix.workdir }}
Expand Down
2 changes: 1 addition & 1 deletion api/metadata/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func parseMetadata(meta interface{}) (*dpb.FileDescriptorProto, error) {
if enc, ok := meta.([]byte); ok {
return decodeFileDesc(enc)
}
return nil, fmt.Errorf("proto not sumpport metadata: %v", meta)
return nil, fmt.Errorf("proto does not support metadata: %v", meta)
}

// decodeFileDesc does decompression and unmarshalling on the given
Expand Down
1 change: 0 additions & 1 deletion cmd/kratos/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0 h1:kunALQeHf1/185U1i0GOB/fy1IPRDDpuoOOqRReG57U=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down
2 changes: 1 addition & 1 deletion cmd/kratos/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main

// release is the current kratos tool version.
const release = "v2.7.2"
const release = "v2.8.0"
2 changes: 1 addition & 1 deletion cmd/protoc-gen-go-errors/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ go 1.19

require (
golang.org/x/text v0.3.8
google.golang.org/protobuf v1.28.0
google.golang.org/protobuf v1.33.0
)
8 changes: 2 additions & 6 deletions cmd/protoc-gen-go-errors/go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
golang.org/x/text v0.3.8 h1:nAL+RVCQ9uMn3vJZbV+MRnydTJFPf8qqY42YiA6MrqY=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
2 changes: 1 addition & 1 deletion cmd/protoc-gen-go-errors/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main

// release is the current protoc-gen-go-errors version.
const release = "v2.7.2"
const release = "v2.8.0"
2 changes: 1 addition & 1 deletion cmd/protoc-gen-go-http/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ go 1.19

require (
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd
google.golang.org/protobuf v1.28.0
google.golang.org/protobuf v1.33.0
)
3 changes: 2 additions & 1 deletion cmd/protoc-gen-go-http/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,9 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Expand Down
2 changes: 1 addition & 1 deletion cmd/protoc-gen-go-http/httpTemplate.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,6 @@ func (c *{{$svrType}}HTTPClientImpl) {{.Name}}(ctx context.Context, in *{{.Reque
if err != nil {
return nil, err
}
return &out, err
return &out, nil
}
{{end}}
2 changes: 1 addition & 1 deletion cmd/protoc-gen-go-http/version.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main

// release is the current protoc-gen-go-http version.
const release = "v2.7.2"
const release = "v2.8.0"
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sync"
"time"

"github.com/imdario/mergo"
"dario.cat/mergo"

// init encoding
_ "github.com/go-kratos/kratos/v2/encoding/json"
Expand Down
2 changes: 1 addition & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"errors"
"testing"

"github.com/imdario/mergo"
"dario.cat/mergo"
)

const (
Expand Down
87 changes: 73 additions & 14 deletions config/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package config
import (
"fmt"
"regexp"
"strconv"
"strings"

"github.com/go-kratos/kratos/v2/encoding"
Expand Down Expand Up @@ -45,6 +46,14 @@ func WithDecoder(d Decoder) Option {
}
}

// WithResolveActualTypes with config resolver.
// bool input will enable conversion of config to data types
func WithResolveActualTypes(enableConvertToType bool) Option {
return func(o *options) {
o.resolver = newActualTypesResolver(enableConvertToType)
}
}

// WithResolver with config resolver.
func WithResolver(r Resolver) Option {
return func(o *options) {
Expand Down Expand Up @@ -82,26 +91,27 @@ func defaultDecoder(src *KeyValue, target map[string]interface{}) error {
return fmt.Errorf("unsupported key: %s format: %s", src.Key, src.Format)
}

func newActualTypesResolver(enableConvertToType bool) func(map[string]interface{}) error {
return func(input map[string]interface{}) error {
mapper := mapper(input)
return resolver(input, mapper, enableConvertToType)
}
}

// defaultResolver resolve placeholder in map value,
// placeholder format in ${key:default}.
func defaultResolver(input map[string]interface{}) error {
mapper := func(name string) string {
args := strings.SplitN(strings.TrimSpace(name), ":", 2) //nolint:gomnd
if v, has := readValue(input, args[0]); has {
s, _ := v.String()
return s
} else if len(args) > 1 { // default value
return args[1]
}
return ""
}
mapper := mapper(input)
return resolver(input, mapper, false)
}

func resolver(input map[string]interface{}, mapper func(name string) string, toType bool) error {
var resolve func(map[string]interface{}) error
resolve = func(sub map[string]interface{}) error {
for k, v := range sub {
switch vt := v.(type) {
case string:
sub[k] = expand(vt, mapper)
sub[k] = expand(vt, mapper, toType)
case map[string]interface{}:
if err := resolve(vt); err != nil {
return err
Expand All @@ -110,7 +120,7 @@ func defaultResolver(input map[string]interface{}) error {
for i, iface := range vt {
switch it := iface.(type) {
case string:
vt[i] = expand(it, mapper)
vt[i] = expand(it, mapper, toType)
case map[string]interface{}:
if err := resolve(it); err != nil {
return err
Expand All @@ -125,12 +135,61 @@ func defaultResolver(input map[string]interface{}) error {
return resolve(input)
}

func expand(s string, mapping func(string) string) string {
func mapper(input map[string]interface{}) func(name string) string {
mapper := func(name string) string {
args := strings.SplitN(strings.TrimSpace(name), ":", 2) //nolint:gomnd
if v, has := readValue(input, args[0]); has {
s, _ := v.String()
return s
} else if len(args) > 1 { // default value
return args[1]
}
return ""
}
return mapper
}

func convertToType(input string) interface{} {
// Check if the input is a string with quotes
if strings.HasPrefix(input, "\"") && strings.HasSuffix(input, "\"") {
// Trim the quotes and return the string value
return strings.Trim(input, "\"")
}

// Try converting to bool
if input == "true" || input == "false" {
b, _ := strconv.ParseBool(input)
return b
}

// Try converting to float64
if strings.Contains(input, ".") {
if f, err := strconv.ParseFloat(input, 64); err == nil {
return f
}
}

// Try converting to int64
if i, err := strconv.ParseInt(input, 10, 64); err == nil {
return i
}

// Default to string if no other conversion succeeds
return input
}

func expand(s string, mapping func(string) string, toType bool) interface{} {
r := regexp.MustCompile(`\${(.*?)}`)
re := r.FindAllStringSubmatch(s, -1)
var ct interface{}
for _, i := range re {
if len(i) == 2 { //nolint:gomnd
s = strings.ReplaceAll(s, i[0], mapping(i[1]))
m := mapping(i[1])
if toType {
ct = convertToType(m)
return ct
}
s = strings.ReplaceAll(s, i[0], m)
}
}
return s
Expand Down
Loading
Loading