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

Improve codecov #1384

Merged
merged 42 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
ac135db
docs:add error code desc
chuntaojun Sep 25, 2022
f4ddd23
fix:调整license-checker的触发
chuntaojun Oct 19, 2022
7db90bd
fix:调整license-checker的触发
chuntaojun Oct 19, 2022
9f8f3eb
hotfix:修复鉴权interceptor遗漏请求来源
chuntaojun Jun 27, 2023
5062e7f
fix:codecov
chuntaojun Jul 11, 2024
1d8d6cf
fix:codecov
chuntaojun Jul 12, 2024
15ec9bc
fix:codecov
chuntaojun Jul 15, 2024
2e9a66f
fix:就近路由代码增加
chuntaojun Jul 22, 2024
c1a74e3
fix:就近路由代码增加
chuntaojun Jul 22, 2024
2d8abb0
fix:就近路由代码增加
chuntaojun Jul 22, 2024
3a59b37
fix:就近路由代码增加
chuntaojun Jul 22, 2024
dfba8e7
fix:就近路由代码增加
chuntaojun Jul 22, 2024
d1199e0
fix:就近路由代码增加
chuntaojun Jul 29, 2024
797dd6b
refactor:鉴权能力优化调整
chuntaojun Aug 12, 2024
4ed969c
refactor:鉴权能力优化调整
chuntaojun Aug 12, 2024
9980a01
refactor:鉴权能力优化调整
chuntaojun Aug 16, 2024
cb0c87e
refactor:鉴权能力优化调整
chuntaojun Aug 16, 2024
94b77ef
refactor:鉴权能力优化调整
chuntaojun Aug 18, 2024
619a658
refactor:鉴权能力优化调整
chuntaojun Aug 19, 2024
b62ba20
refactor:鉴权能力优化调整
chuntaojun Aug 20, 2024
4a9bd56
refactor:鉴权能力优化调整
chuntaojun Aug 21, 2024
32b0158
refactor:鉴权能力优化调整
chuntaojun Aug 22, 2024
e55cdce
refactor:鉴权能力优化调整
chuntaojun Aug 29, 2024
048e034
refactor:鉴权能力优化调整
chuntaojun Aug 29, 2024
64485ef
refactor:鉴权能力优化调整
chuntaojun Aug 30, 2024
dd0d133
refactor:鉴权能力优化调整
chuntaojun Aug 30, 2024
18d70e8
refactor:鉴权能力优化调整
chuntaojun Aug 30, 2024
3232dbf
refactor:鉴权能力优化调整
chuntaojun Sep 2, 2024
a4c3735
refactor:鉴权能力优化调整
chuntaojun Sep 9, 2024
cc5b616
refactor:鉴权能力优化调整
chuntaojun Sep 9, 2024
6c2f6bd
refactor:鉴权能力优化调整
chuntaojun Sep 9, 2024
2929a54
refactor:鉴权能力优化调整
chuntaojun Sep 10, 2024
8a995b3
refactor:鉴权能力优化调整
chuntaojun Sep 12, 2024
e82149b
refactor:鉴权能力优化调整
chuntaojun Sep 12, 2024
07f7d33
refactor:鉴权能力优化调整
chuntaojun Sep 12, 2024
21f823d
refactor:鉴权能力优化调整
chuntaojun Sep 12, 2024
580c6b5
refactor:鉴权能力优化调整
chuntaojun Sep 12, 2024
b88ebba
refactor:鉴权能力优化调整
chuntaojun Sep 13, 2024
c6b45ad
refactor:鉴权能力优化调整
chuntaojun Sep 13, 2024
9a2eb9b
refactor:鉴权能力优化调整
chuntaojun Sep 19, 2024
4b5deef
refactor:鉴权能力优化调整
chuntaojun Sep 20, 2024
41bffc0
refactor:鉴权能力优化调整
chuntaojun Sep 25, 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
14 changes: 13 additions & 1 deletion .github/workflows/codecov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,25 @@ jobs:
with:
fetch-depth: 2

- uses: shogo82148/actions-setup-mysql@v1
with:
mysql-version: "5.7"
auto-start: true
my-cnf: |
innodb_log_file_size=256MB
innodb_buffer_pool_size=512MB
max_allowed_packet=16MB
max_connections=50
local_infile=1
root-password: root


- name: Initialize database
env:
MYSQL_DB_USER: root
MYSQL_DB_PWD: root
MYSQL_DATABASE: polaris_server
run: |
sudo systemctl start mysql.service
mysql -e 'CREATE DATABASE ${{ env.MYSQL_DATABASE }};' -u${{ env.MYSQL_DB_USER }} -p${{ env.MYSQL_DB_PWD }}
mysql -e "ALTER USER '${{ env.MYSQL_DB_USER }}'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';" -u${{ env.MYSQL_DB_USER }} -p${{ env.MYSQL_DB_PWD }}

Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ linters-settings:
disabled: false
- name: max-public-structs
severity: warning
disabled: false
disabled: true
arguments: [35]
- name: indent-error-flow
severity: warning
Expand Down
3 changes: 3 additions & 0 deletions admin/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

"github.com/polarismesh/polaris/common/model"
"github.com/polarismesh/polaris/common/model/admin"
authcommon "github.com/polarismesh/polaris/common/model/auth"
)

// AdminOperateServer Maintain related operation
Expand Down Expand Up @@ -55,4 +56,6 @@ type AdminOperateServer interface {
GetCMDBInfo(ctx context.Context) ([]model.LocationView, error)
// InitMainUser
InitMainUser(ctx context.Context, user apisecurity.User) error
// GetServerFunctions Get server functions
GetServerFunctions(ctx context.Context) map[string][]authcommon.ServerFunctionName
}
3 changes: 2 additions & 1 deletion admin/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import (

// Config maintain configuration
type Config struct {
Jobs []job.JobConfig `yaml:"jobs"`
Jobs []job.JobConfig `yaml:"jobs"`
Interceptors []string `yaml:"-"`
}

func DefaultConfig() *Config {
Expand Down
66 changes: 43 additions & 23 deletions admin/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,32 @@ package admin
import (
"context"
"errors"
"fmt"

"github.com/polarismesh/polaris/admin/job"
"github.com/polarismesh/polaris/auth"
"github.com/polarismesh/polaris/cache"
"github.com/polarismesh/polaris/service"
"github.com/polarismesh/polaris/service/healthcheck"
"github.com/polarismesh/polaris/store"
)

var (
server AdminOperateServer
maintainServer = &Server{}
finishInit bool
server AdminOperateServer
maintainServer = &Server{}
finishInit bool
serverProxyFactories = map[string]ServerProxyFactory{}
)

type ServerProxyFactory func(ctx context.Context, pre AdminOperateServer) (AdminOperateServer, error)

func RegisterServerProxy(name string, factor ServerProxyFactory) error {
if _, ok := serverProxyFactories[name]; ok {
return fmt.Errorf("duplicate ServerProxyFactory, name(%s)", name)
}
serverProxyFactories[name] = factor
return nil
}

// Initialize 初始化
func Initialize(ctx context.Context, cfg *Config, namingService service.DiscoverServer,
healthCheckServer *healthcheck.Server, cacheMgn *cache.CacheManager, storage store.Store) error {
Expand All @@ -43,40 +54,49 @@ func Initialize(ctx context.Context, cfg *Config, namingService service.Discover
return nil
}

err := initialize(ctx, cfg, namingService, healthCheckServer, cacheMgn, storage)
proxySvr, actualSvr, err := InitServer(ctx, cfg, namingService, healthCheckServer, cacheMgn, storage)
if err != nil {
return err
}

server = proxySvr
maintainServer = actualSvr
finishInit = true
return nil
}

func initialize(_ context.Context, cfg *Config, namingService service.DiscoverServer,
healthCheckServer *healthcheck.Server, cacheMgn *cache.CacheManager, storage store.Store) error {
func InitServer(ctx context.Context, cfg *Config, namingService service.DiscoverServer,
healthCheckServer *healthcheck.Server, cacheMgn *cache.CacheManager, storage store.Store) (AdminOperateServer, *Server, error) {

userMgn, err := auth.GetUserServer()
if err != nil {
return err
}
actualSvr := new(Server)

strategyMgn, err := auth.GetStrategyServer()
if err != nil {
return err
}

maintainServer.namingServer = namingService
maintainServer.healthCheckServer = healthCheckServer
maintainServer.cacheMgn = cacheMgn
maintainServer.storage = storage
actualSvr.namingServer = namingService
actualSvr.healthCheckServer = healthCheckServer
actualSvr.cacheMgn = cacheMgn
actualSvr.storage = storage

maintainJobs := job.NewMaintainJobs(namingService, cacheMgn, storage)
if err := maintainJobs.StartMaintianJobs(cfg.Jobs); err != nil {
return err
return nil, nil, err
}

server = newServerAuthAbility(maintainServer, userMgn, strategyMgn)
return nil
var proxySvr AdminOperateServer
proxySvr = actualSvr
order := GetChainOrder()
for i := range order {
factory, exist := serverProxyFactories[order[i]]
if !exist {
return nil, nil, fmt.Errorf("name(%s) not exist in serverProxyFactories", order[i])
}

afterSvr, err := factory(ctx, proxySvr)
if err != nil {
return nil, nil, err
}
proxySvr = afterSvr
}

return proxySvr, actualSvr, nil
}

// GetServer 获取已经初始化好的Server
Expand Down
24 changes: 24 additions & 0 deletions admin/interceptor/auth/log.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Tencent is pleased to support the open source community by making Polaris available.
*
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved.
*
* Licensed under the BSD 3-Clause License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://opensource.org/licenses/BSD-3-Clause
*
* Unless required by applicable law or agreed to in writing, software distributed
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*/

package auth

import (
commonlog "github.com/polarismesh/polaris/common/log"
)

var log = commonlog.GetScopeOrDefaultByName(commonlog.AuthLoggerName)
Loading
Loading