Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/go_modules/contrib/config/etcd/go…
Browse files Browse the repository at this point in the history
…ogle.golang.org/grpc-1.59.0
  • Loading branch information
hawkingrei committed Nov 27, 2023
2 parents 9b285fc + 5d3827f commit 2a7732e
Show file tree
Hide file tree
Showing 29 changed files with 291 additions and 115 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:

steps:
- name: Checkout repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gitee-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Mirror Github to Gitee
uses: Yikun/hub-mirror-action@v1.3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- 8091:8091
- 8093:8093
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4.1.0
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- id: set-matrix
run: ./hack/resolve-modules.sh
Expand All @@ -27,7 +27,7 @@ jobs:
strategy:
matrix: ${{ fromJson(needs.resolve-modules.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Lint
uses: golangci/golangci-lint-action@v3
with:
Expand Down
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ linters:
- whitespace
- wastedassign
- unconvert
- misspell

# don't enable:
# - asciicheck
Expand Down Expand Up @@ -66,3 +67,5 @@ linters-settings:
min-complexity: 50
goimports:
local-prefixes: github.com/go-kratos # Put imports beginning with prefix after 3rd-party packages
misspell: # Finds commonly misspelled English words in comments
locale: US
2 changes: 1 addition & 1 deletion cmd/kratos/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/testify v1.7.0 // indirect
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f // indirect
golang.org/x/sys v0.1.0 // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
gopkg.in/yaml.v3 v3.0.0 // indirect
)
2 changes: 2 additions & 0 deletions cmd/kratos/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBc
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=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
Expand Down
19 changes: 8 additions & 11 deletions contrib/config/apollo/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,15 @@ func (c *customChangeListener) onChange(namespace string, changes map[string]*st
kv := make([]*config.KeyValue, 0, 2)
if strings.Contains(namespace, ".") && !strings.HasSuffix(namespace, "."+properties) &&
(format(namespace) == yaml || format(namespace) == yml || format(namespace) == json) {
value, err := c.apollo.client.GetConfigCache(namespace).Get("content")
if err != nil {
log.Warnw("apollo get config failed", "err", err)
return nil
if value, ok := changes["content"]; ok {
kv = append(kv, &config.KeyValue{
Key: namespace,
Value: []byte(value.NewValue.(string)),
Format: format(namespace),
})

return kv
}
kv = append(kv, &config.KeyValue{
Key: namespace,
Value: []byte(value.(string)),
Format: format(namespace),
})

return kv
}

next := make(map[string]interface{})
Expand Down
79 changes: 79 additions & 0 deletions contrib/config/apollo/watcher_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package apollo

import (
"testing"

"github.com/apolloconfig/agollo/v4/storage"

"github.com/go-kratos/kratos/v2/config"
"github.com/go-kratos/kratos/v2/encoding"
)

func Test_onChange(t *testing.T) {
s := map[string]struct {
Name string `yaml:"name"`
}{
"app": {
Name: "new",
},
}
codec := encoding.GetCodec(yaml)
val, _ := codec.Marshal(s)
c := customChangeListener{}
tests := []struct {
name string
namespace string
changes map[string]*storage.ConfigChange
kvs []*config.KeyValue
}{
{
"test yaml onChange",
"app.yaml",
map[string]*storage.ConfigChange{
"name": {
OldValue: "old",
NewValue: "new",
ChangeType: storage.MODIFIED,
},
},
[]*config.KeyValue{
{
Key: "app.yaml",
Value: val,
Format: yaml,
},
},
},
{
"test json onChange",
"app.json",
map[string]*storage.ConfigChange{
"content": {
OldValue: `{"name":"old"}`,
NewValue: `{"name":"new"}`,
ChangeType: storage.MODIFIED,
},
},
[]*config.KeyValue{
{
Key: "app.json",
Value: []byte(`{"name":"new"}`),
Format: json,
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
kvs := c.onChange(tt.namespace, tt.changes)
if len(kvs) != len(tt.kvs) {
t.Errorf("len(kvs) = %v, want %v", len(kvs), len(tt.kvs))
}
for i := range kvs {
if kvs[i].Format != tt.kvs[i].Format || kvs[i].Key != tt.kvs[i].Key || string(kvs[i].Value) != string(tt.kvs[i].Value) {
t.Errorf("got %v, want %v", kvs[i], tt.kvs[i])
}
}
})
}
}
2 changes: 1 addition & 1 deletion contrib/encoding/msgpack/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.19

require (
github.com/go-kratos/kratos/v2 v2.7.1
github.com/vmihailenco/msgpack/v5 v5.3.5
github.com/vmihailenco/msgpack/v5 v5.4.1
)

require github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
Expand Down
10 changes: 2 additions & 8 deletions contrib/encoding/msgpack/go.sum
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU=
github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc=
github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8=
github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok=
github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g=
github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
2 changes: 1 addition & 1 deletion contrib/log/aliyun/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/go-kratos/kratos/contrib/log/aliyun/v2
go 1.19

require (
github.com/aliyun/aliyun-log-go-sdk v0.1.44
github.com/aliyun/aliyun-log-go-sdk v0.1.66
github.com/go-kratos/kratos/v2 v2.7.1
google.golang.org/protobuf v1.31.0
)
Expand Down
Loading

0 comments on commit 2a7732e

Please sign in to comment.