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

feat: update namespace for code style #730

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 4 additions & 5 deletions namespace/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ import (

var (
server NamespaceOperateServer
namespaceServer *Server = new(Server)
once = sync.Once{}
finishInit = false
namespaceServer = &Server{}
once sync.Once
finishInit bool
)

type Config struct {
Expand All @@ -56,8 +56,7 @@ func Initialize(ctx context.Context, nsOpt *Config, storage store.Store, cacheMg
return nil
}

func initialize(ctx context.Context, nsOpt *Config, storage store.Store, cacheMgn *cache.CacheManager) error {

func initialize(_ context.Context, nsOpt *Config, storage store.Store, cacheMgn *cache.CacheManager) error {
namespaceServer.caches = cacheMgn
namespaceServer.storage = storage
namespaceServer.cfg = *nsOpt
Expand Down
6 changes: 4 additions & 2 deletions namespace/namespace_authability.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ import (
"github.com/polarismesh/polaris/common/utils"
)

var _ NamespaceOperateServer = (*serverAuthAbility)(nil)

// CreateNamespaceIfAbsent Create a single name space
func (svr *serverAuthAbility) CreateNamespaceIfAbsent(ctx context.Context, req *api.Namespace) error {
return svr.targetServer.CreateNamespaceIfAbsent(ctx, req)
}
Expand All @@ -42,8 +45,7 @@ func (svr *serverAuthAbility) CreateNamespace(ctx context.Context, req *api.Name
ctx = context.WithValue(ctx, utils.ContextAuthContextKey, authCtx)

// 填充 ownerId 信息数据
ownerId := utils.ParseOwnerID(ctx)
if len(ownerId) > 0 {
if ownerId := utils.ParseOwnerID(ctx); len(ownerId) > 0 {
req.Owners = utils.NewStringValue(ownerId)
}

Expand Down
2 changes: 2 additions & 0 deletions namespace/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import (
"github.com/polarismesh/polaris/store"
)

var _ NamespaceOperateServer = (*Server)(nil)

type Server struct {
storage store.Store

Expand Down
2 changes: 1 addition & 1 deletion namespace/server_authability.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (

// serverAuthAbility 带有鉴权能力的 discoverServer
//
// 该层会对请求参数做一些调整,根据具体的请求发起人,设置为数据对应的 owner,不可为为别人进行创建资源
// 该层会对请求参数做一些调整,根据具体的请求发起人,设置为数据对应的 owner,不可为为别人进行创建资源
type serverAuthAbility struct {
targetServer *Server
authSvr auth.AuthServer
Expand Down
6 changes: 2 additions & 4 deletions namespace/test_export.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,9 @@ import (
"github.com/polarismesh/polaris/store"
)

func TestInitialize(ctx context.Context, nsOpt *Config, storage store.Store, cacheMgn *cache.CacheManager,
func TestInitialize(_ context.Context, nsOpt *Config, storage store.Store, cacheMgn *cache.CacheManager,
authSvr auth.AuthServer) (NamespaceOperateServer, error) {

namespaceServer := new(Server)

namespaceServer := &Server{}
namespaceServer.caches = cacheMgn
namespaceServer.storage = storage
namespaceServer.cfg = *nsOpt
Expand Down