Skip to content

Commit

Permalink
Revert "Improve codecov (#1384)"
Browse files Browse the repository at this point in the history
This reverts commit 060a9e5.
  • Loading branch information
chuntaojun authored Sep 25, 2024
1 parent 060a9e5 commit 5530016
Show file tree
Hide file tree
Showing 192 changed files with 10,432 additions and 7,595 deletions.
14 changes: 1 addition & 13 deletions .github/workflows/codecov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,13 @@ 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
4 changes: 2 additions & 2 deletions .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: true
disabled: false
arguments: [35]
- name: indent-error-flow
severity: warning
Expand Down Expand Up @@ -281,7 +281,7 @@ linters-settings:
govet:
# Report about shadowed variables.
# Default: false
shadow: false
check-shadowing: true
# Settings per analyzer.
settings:
# Analyzer name, run `go tool vet help` to see all analyzers.
Expand Down
3 changes: 0 additions & 3 deletions admin/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ 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 @@ -56,6 +55,4 @@ 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) []authcommon.ServerFunctionGroup
}
3 changes: 1 addition & 2 deletions admin/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ import (

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

func DefaultConfig() *Config {
Expand Down
66 changes: 23 additions & 43 deletions admin/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,21 @@ 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
serverProxyFactories = map[string]ServerProxyFactory{}
server AdminOperateServer
maintainServer = &Server{}
finishInit bool
)

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 @@ -54,49 +43,40 @@ func Initialize(ctx context.Context, cfg *Config, namingService service.Discover
return nil
}

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

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

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

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

actualSvr.namingServer = namingService
actualSvr.healthCheckServer = healthCheckServer
actualSvr.cacheMgn = cacheMgn
actualSvr.storage = storage
strategyMgn, err := auth.GetStrategyServer()
if err != nil {
return err
}

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

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

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 err
}

return proxySvr, actualSvr, nil
server = newServerAuthAbility(maintainServer, userMgn, strategyMgn)
return nil
}

// GetServer 获取已经初始化好的Server
Expand Down
24 changes: 0 additions & 24 deletions admin/interceptor/auth/log.go

This file was deleted.

Loading

0 comments on commit 5530016

Please sign in to comment.