Skip to content

Commit 9e4769b

Browse files
authored
[ISSUE polarismesh#741] Fix import style (polarismesh#740)
* fix issue polarismesh#629 (polarismesh#693) * docs:优化错误信息描述 * Update zh.toml * fix:修复eureka心跳协议错误码不兼容问题 * fix:修复eureka心跳协议错误码不兼容问题 * unit:添加单元测试 * test:调整测试配置文件位置 * fix:issue polarismesh#692 * fix:issue polarismesh#692 * fix:issue polarismesh#692 * fix:issue polarismesh#692 * docs:add error code desc * fix:修复polaris-limiter 容器部署失败问题 (polarismesh#722) * fix:修复polaris-console.yaml问题 * fix:code style * style:fix import order
1 parent 90ad169 commit 9e4769b

39 files changed

+133
-41
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ __debug_bin
2323
/vendor
2424
.codecc
2525
*.log
26+
27+
style_tool/
28+
goimports-reviser

apiserver/eurekaserver/eureka_suit_test.go

+8-10
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,14 @@ import (
2525
"time"
2626

2727
"github.com/golang/mock/gomock"
28+
"gopkg.in/yaml.v2"
29+
2830
"github.com/polarismesh/polaris/auth"
2931
"github.com/polarismesh/polaris/cache"
3032
commonlog "github.com/polarismesh/polaris/common/log"
3133
"github.com/polarismesh/polaris/common/utils"
3234
"github.com/polarismesh/polaris/namespace"
3335
"github.com/polarismesh/polaris/plugin"
34-
"github.com/polarismesh/polaris/service"
35-
"github.com/polarismesh/polaris/service/batch"
36-
"github.com/polarismesh/polaris/service/healthcheck"
37-
"github.com/polarismesh/polaris/store"
38-
storemock "github.com/polarismesh/polaris/store/mock"
39-
"gopkg.in/yaml.v2"
40-
41-
"github.com/polarismesh/polaris/testdata"
42-
43-
// 注册相关默认插件
4436
_ "github.com/polarismesh/polaris/plugin/auth/defaultauth"
4537
_ "github.com/polarismesh/polaris/plugin/auth/platform"
4638
_ "github.com/polarismesh/polaris/plugin/cmdb/memory"
@@ -53,8 +45,14 @@ import (
5345
_ "github.com/polarismesh/polaris/plugin/ratelimit/lrurate"
5446
_ "github.com/polarismesh/polaris/plugin/ratelimit/token"
5547
_ "github.com/polarismesh/polaris/plugin/statis/local"
48+
"github.com/polarismesh/polaris/service"
49+
"github.com/polarismesh/polaris/service/batch"
50+
"github.com/polarismesh/polaris/service/healthcheck"
51+
"github.com/polarismesh/polaris/store"
5652
_ "github.com/polarismesh/polaris/store/boltdb"
53+
storemock "github.com/polarismesh/polaris/store/mock"
5754
_ "github.com/polarismesh/polaris/store/sqldb"
55+
"github.com/polarismesh/polaris/testdata"
5856
)
5957

6058
type Bootstrap struct {

apiserver/eurekaserver/write_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ import (
2323
"time"
2424

2525
"github.com/golang/mock/gomock"
26+
"github.com/stretchr/testify/assert"
27+
"google.golang.org/protobuf/types/known/wrapperspb"
28+
2629
api "github.com/polarismesh/polaris/common/api/v1"
2730
"github.com/polarismesh/polaris/common/model"
2831
"github.com/polarismesh/polaris/common/utils"
2932
"github.com/polarismesh/polaris/store/mock"
30-
"github.com/stretchr/testify/assert"
31-
"google.golang.org/protobuf/types/known/wrapperspb"
3233
)
3334

3435
func TestEurekaServer_renew(t *testing.T) {

apiserver/grpcserver/discover/v2/client_access_v2.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ import (
2121
"fmt"
2222
"io"
2323

24+
"go.uber.org/zap"
25+
"google.golang.org/grpc"
26+
2427
"github.com/polarismesh/polaris/apiserver/grpcserver"
2528
apiv1 "github.com/polarismesh/polaris/common/api/v1"
2629
apiv2 "github.com/polarismesh/polaris/common/api/v2"
2730
commonlog "github.com/polarismesh/polaris/common/log"
2831
"github.com/polarismesh/polaris/common/utils"
29-
"go.uber.org/zap"
30-
"google.golang.org/grpc"
3132
)
3233

3334
var (

apiserver/grpcserver/stream.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ import (
2323
"strings"
2424
"time"
2525

26-
commonlog "github.com/polarismesh/polaris/common/log"
2726
"go.uber.org/zap"
2827
"google.golang.org/grpc"
2928
"google.golang.org/grpc/metadata"
3029
"google.golang.org/grpc/peer"
30+
31+
commonlog "github.com/polarismesh/polaris/common/log"
3132
)
3233

3334
// initVirtualStream 对 VirtualStream 的一些初始化动作

apiserver/httpserver/client.go

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package httpserver
1919

2020
import (
2121
"github.com/emicklei/go-restful/v3"
22+
2223
httpcommon "github.com/polarismesh/polaris/apiserver/httpserver/http"
2324
)
2425

apiserver/httpserver/i18n/en.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,4 @@
155155
500007 = "heartbeat execute exception" #HeartbeatException
156156
500008 = "instance async regist timeout" #InstanceRegisTimeout
157157
500100 = "token verify exception" #AuthTokenVerifyException
158-
500101 = "operation role exception" #OperationRoleException
158+
500101 = "operation role exception" #OperationRoleException

apiserver/httpserver/i18n/messages.genearate.go

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apiserver/httpserver/swagger_access.go

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/emicklei/go-restful/v3"
2222
"github.com/go-openapi/spec"
2323
restfulspec "github.com/polarismesh/go-restful-openapi/v2"
24+
2425
"github.com/polarismesh/polaris/common/version"
2526
)
2627

apiserver/xdsserverv3/callback.go

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
discovery "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3"
2424
"github.com/gogo/protobuf/jsonpb"
25+
2526
commonlog "github.com/polarismesh/polaris/common/log"
2627
)
2728

auth/defaultauth/main_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import (
2626

2727
"github.com/boltdb/bolt"
2828
_ "github.com/go-sql-driver/mysql"
29+
"gopkg.in/yaml.v2"
30+
2931
"github.com/polarismesh/polaris/auth"
3032
"github.com/polarismesh/polaris/cache"
3133
_ "github.com/polarismesh/polaris/cache"
@@ -55,7 +57,6 @@ import (
5557
"github.com/polarismesh/polaris/store/sqldb"
5658
_ "github.com/polarismesh/polaris/store/sqldb"
5759
"github.com/polarismesh/polaris/testdata"
58-
"gopkg.in/yaml.v2"
5960
)
6061

6162
const (
@@ -291,7 +292,6 @@ func (d *AuthTestSuit) cleanAllUserGroup() {
291292
}
292293
}
293294

294-
295295
func (d *AuthTestSuit) cleanAllAuthStrategy() {
296296
if d.storage.Name() == sqldb.STORENAME {
297297
func() {

cache/client_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,12 @@ import (
2323
"time"
2424

2525
"github.com/golang/mock/gomock"
26+
"github.com/stretchr/testify/assert"
27+
2628
apiv1 "github.com/polarismesh/polaris/common/api/v1"
2729
"github.com/polarismesh/polaris/common/model"
2830
"github.com/polarismesh/polaris/common/utils"
2931
"github.com/polarismesh/polaris/store/mock"
30-
"github.com/stretchr/testify/assert"
3132
)
3233

3334
func newTestClientCache(t *testing.T) (*gomock.Controller, *mock.MockStore, *clientCache) {

cache/config_file_bucket.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ func newConfigFileGroupBucket() *configFileGroupBucket {
4343
}
4444

4545
type configFileGroupBucket struct {
46-
lock sync.RWMutex
46+
lock sync.RWMutex
4747
name2groups map[string]*subConfigFileGroupBucket
4848

49-
idlock sync.RWMutex
50-
id2groups map[uint64]*configGroupEntry
49+
idlock sync.RWMutex
50+
id2groups map[uint64]*configGroupEntry
5151
}
5252

5353
func (b *configFileGroupBucket) saveGroupById(id uint64, item *model.ConfigFileGroup) {

cache/routing_config.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ import (
2121
"sort"
2222
"time"
2323

24+
"go.uber.org/zap"
25+
"golang.org/x/sync/singleflight"
26+
2427
apiv1 "github.com/polarismesh/polaris/common/api/v1"
2528
apiv2 "github.com/polarismesh/polaris/common/api/v2"
2629
"github.com/polarismesh/polaris/common/log"
@@ -29,8 +32,6 @@ import (
2932
routingcommon "github.com/polarismesh/polaris/common/routing"
3033
"github.com/polarismesh/polaris/common/utils"
3134
"github.com/polarismesh/polaris/store"
32-
"go.uber.org/zap"
33-
"golang.org/x/sync/singleflight"
3435
)
3536

3637
const (

common/api/v2/response.go

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package v2
2020
import (
2121
"github.com/golang/protobuf/proto"
2222
"github.com/golang/protobuf/ptypes"
23+
2324
v1 "github.com/polarismesh/polaris/common/api/v1"
2425
)
2526

common/model/v2/routing.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ import (
2121
"time"
2222

2323
"github.com/golang/protobuf/ptypes"
24+
"google.golang.org/protobuf/types/known/anypb"
25+
2426
apiv2 "github.com/polarismesh/polaris/common/api/v2"
2527
commontime "github.com/polarismesh/polaris/common/time"
26-
"google.golang.org/protobuf/types/known/anypb"
2728
)
2829

2930
const (

common/routing/routing.go

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"sort"
2424

2525
"github.com/golang/protobuf/ptypes"
26+
2627
apiv1 "github.com/polarismesh/polaris/common/api/v1"
2728
apiv2 "github.com/polarismesh/polaris/common/api/v2"
2829
"github.com/polarismesh/polaris/common/model"

config/config_file_template_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ package config
2020
import (
2121
"testing"
2222

23+
"github.com/stretchr/testify/assert"
24+
2325
api "github.com/polarismesh/polaris/common/api/v1"
2426
"github.com/polarismesh/polaris/common/utils"
25-
"github.com/stretchr/testify/assert"
2627
)
2728

2829
// TestConfigFileTemplateCRUD the base test for config file template

config/server_authability.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ import (
2121
"context"
2222
"strconv"
2323

24+
"go.uber.org/zap"
25+
2426
"github.com/polarismesh/polaris/auth"
2527
api "github.com/polarismesh/polaris/common/api/v1"
2628
commonlog "github.com/polarismesh/polaris/common/log"
2729
"github.com/polarismesh/polaris/common/model"
2830
"github.com/polarismesh/polaris/common/utils"
29-
"go.uber.org/zap"
3031
)
3132

3233
var _ ConfigCenterServer = (*serverAuthability)(nil)

deploy/helm/templates/polaris-console-config.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ data:
1515
mode: "release"
1616
listenIP: "0.0.0.0"
1717
listenPort: {{ .Values.service.webPort }}
18-
namingURL: "/naming/v1"
18+
namingV1URL: "/naming/v1"
19+
namingV2URL: "/naming/v2"
1920
authURL: "/core/v1"
2021
requestURL: "/naming/v1"
2122
configURL: "/config/v1"

deploy/helm/templates/polaris-server-config.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,28 @@ data:
6464
- stdout
6565
errorOutputPaths:
6666
- stderr
67+
healthcheck:
68+
rotateOutputPath: log/polaris-healthcheck.log
69+
errorRotateOutputPath: log/polaris-healthcheck-error.log
70+
rotationMaxSize: 100
71+
rotationMaxBackups: 10
72+
rotationMaxAge: 7
73+
outputLevel: info
74+
outputPaths:
75+
- stdout
76+
errorOutputPaths:
77+
- stderr
78+
xdsv3:
79+
rotateOutputPath: log/polaris-xdsv3.log
80+
errorRotateOutputPath: log/polaris-xdsv3-error.log
81+
rotationMaxSize: 100
82+
rotationMaxBackups: 10
83+
rotationMaxAge: 7
84+
outputLevel: info
85+
outputPaths:
86+
- stdout
87+
errorOutputPaths:
88+
- stderr
6789
default:
6890
rotateOutputPath: log/polaris-default.log
6991
errorRotateOutputPath: log/polaris-default-error.log

deploy/standalone/docker-compose/console/polaris-console.yaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ webServer:
88
mode: "release"
99
listenIP: "0.0.0.0"
1010
listenPort: 8080
11-
namingURL: "/naming/v1"
11+
namingV1URL: "/naming/v1"
12+
namingV2URL: "/naming/v2"
1213
authURL: "/core/v1"
1314
requestURL: "/naming/v1"
1415
configURL: "/config/v1"

deploy/standalone/k8s/02-polaris-server-config.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,28 @@ data:
6060
- stdout
6161
errorOutputPaths:
6262
- stderr
63+
healthcheck:
64+
rotateOutputPath: log/polaris-healthcheck.log
65+
errorRotateOutputPath: log/polaris-healthcheck-error.log
66+
rotationMaxSize: 100
67+
rotationMaxBackups: 10
68+
rotationMaxAge: 7
69+
outputLevel: info
70+
outputPaths:
71+
- stdout
72+
errorOutputPaths:
73+
- stderr
74+
xdsv3:
75+
rotateOutputPath: log/polaris-xdsv3.log
76+
errorRotateOutputPath: log/polaris-xdsv3-error.log
77+
rotationMaxSize: 100
78+
rotationMaxBackups: 10
79+
rotationMaxAge: 7
80+
outputLevel: info
81+
outputPaths:
82+
- stdout
83+
errorOutputPaths:
84+
- stderr
6385
default:
6486
rotateOutputPath: log/polaris-default.log
6587
errorRotateOutputPath: log/polaris-default-error.log

deploy/standalone/k8s/05-polaris-limiter.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ spec:
3434
restartPolicy: Always
3535
volumes:
3636
- configMap:
37-
defaultMode: 640
37+
defaultMode: 0640
3838
name: polaris-limiter-config
3939
name: polaris-limiter-config
4040
updateStrategy:

import-format.sh

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
rm -rf style_tool
4+
rm -rf goimports-reviser
5+
6+
mkdir -p style_tool
7+
8+
cd style_tool
9+
10+
wget https://github.com/incu6us/goimports-reviser/releases/download/v3.1.1/goimports-reviser_3.1.1_linux_amd64.tar.gz
11+
tar -zxvf goimports-reviser_3.1.1_linux_amd64.tar.gz
12+
mv goimports-reviser ../
13+
14+
cd ../
15+
16+
find . -name "*.go" -type f | grep -v .pb.go|grep -v test/tools/tools.go | grep -v ./plugin.go | xargs -I {} goimports-reviser -rm-unused -format {} -project-name github.com/polarismesh/polaris
17+
18+
go fmt ./...

plugin/discoverevent/loki/event_loki_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ package loki
2020
import (
2121
"testing"
2222

23-
"github.com/polarismesh/polaris/plugin"
2423
"github.com/stretchr/testify/assert"
24+
25+
"github.com/polarismesh/polaris/plugin"
2526
)
2627

2728
func Test_discoverEventLoki_Name(t *testing.T) {

plugin/discoverevent/loki/logger.go

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/golang/snappy"
3232
"github.com/grafana/loki/pkg/logproto"
3333
json "github.com/json-iterator/go"
34+
3435
"github.com/polarismesh/polaris/common/log"
3536
"github.com/polarismesh/polaris/common/model"
3637
"github.com/polarismesh/polaris/common/utils"

plugin/history/loki/history_loki_test.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ package loki
2020
import (
2121
"testing"
2222

23+
"github.com/stretchr/testify/assert"
24+
2325
"github.com/polarismesh/polaris/common/model"
2426
"github.com/polarismesh/polaris/plugin"
25-
"github.com/stretchr/testify/assert"
2627
)
2728

2829
func TestHistoryLoki_Name(t *testing.T) {

0 commit comments

Comments
 (0)