diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index b977042d..3c8ae4f6 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -15,7 +15,7 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v2 with: - version: v1.51.2 + version: v1.55.2 args: --enable gofmt,gocyclo,goimports,dupl,gosec --timeout 5m --skip-dirs=examples,test --skip-files=.*_test.go$ static-checks: runs-on: ubuntu-latest diff --git a/server/datasource/dao.go b/server/datasource/dao.go index 5cada492..a4cc01eb 100644 --- a/server/datasource/dao.go +++ b/server/datasource/dao.go @@ -22,10 +22,10 @@ import ( "context" "errors" "fmt" - "github.com/apache/servicecomb-kie/server/datasource/rbac" - "github.com/go-chassis/openlog" "github.com/apache/servicecomb-kie/pkg/model" + "github.com/apache/servicecomb-kie/server/datasource/rbac" + "github.com/go-chassis/openlog" ) var ( diff --git a/server/datasource/local/counter/revision.go b/server/datasource/local/counter/revision.go index ff4993a9..756b79f3 100644 --- a/server/datasource/local/counter/revision.go +++ b/server/datasource/local/counter/revision.go @@ -19,11 +19,11 @@ package counter import ( "context" - "github.com/apache/servicecomb-kie/server/datasource/local/file" "os" "path" "strconv" + "github.com/apache/servicecomb-kie/server/datasource/local/file" "github.com/go-chassis/openlog" ) diff --git a/server/datasource/local/file/fileprocess.go b/server/datasource/local/file/fileprocess.go index 34e779e4..30fa486e 100644 --- a/server/datasource/local/file/fileprocess.go +++ b/server/datasource/local/file/fileprocess.go @@ -1,13 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * 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 file import ( - log "github.com/go-chassis/openlog" "io/fs" "os" "path" "path/filepath" "strings" "sync" + + log "github.com/go-chassis/openlog" ) var FileRootPath = "/data/kvs" @@ -238,16 +256,7 @@ func CountInDomain(dir string) (int, error) { count := 0 for _, projectFolder := range files { if projectFolder.IsDir() { - kvs, err := os.ReadDir(path.Join(dir, projectFolder.Name())) - if err != nil { - log.Error("failed to read directory " + dir + ", " + err.Error()) - return 0, err - } - for _, kv := range kvs { - if kv.IsDir() { - count++ - } - } + count++ } } // count kv numbers diff --git a/server/datasource/local/history/history_dao.go b/server/datasource/local/history/history_dao.go index 8acde933..5766beb8 100644 --- a/server/datasource/local/history/history_dao.go +++ b/server/datasource/local/history/history_dao.go @@ -20,15 +20,14 @@ package history import ( "context" "encoding/json" - "github.com/apache/servicecomb-kie/server/datasource/local/file" "path" "strconv" - "github.com/apache/servicecomb-kie/server/datasource/auth" - "github.com/go-chassis/openlog" - "github.com/apache/servicecomb-kie/pkg/model" "github.com/apache/servicecomb-kie/server/datasource" + "github.com/apache/servicecomb-kie/server/datasource/auth" + "github.com/apache/servicecomb-kie/server/datasource/local/file" + "github.com/go-chassis/openlog" ) // Dao is the implementation diff --git a/server/datasource/local/kv/kv_cache.go b/server/datasource/local/kv/kv_cache.go index d23cbead..3eb843b0 100644 --- a/server/datasource/local/kv/kv_cache.go +++ b/server/datasource/local/kv/kv_cache.go @@ -21,16 +21,17 @@ import ( "context" "encoding/json" "fmt" + "regexp" + "strings" + "sync" + "time" + "github.com/apache/servicecomb-kie/pkg/model" "github.com/apache/servicecomb-kie/pkg/stringutil" "github.com/apache/servicecomb-kie/server/datasource" "github.com/go-chassis/openlog" goCache "github.com/patrickmn/go-cache" "go.etcd.io/etcd/api/v3/mvccpb" - "regexp" - "strings" - "sync" - "time" ) type IDSet map[string]struct{} @@ -95,7 +96,6 @@ func (kc *Cache) GetKvDoc(kv *mvccpb.KeyValue) (*model.KVDoc, error) { return kvDoc, nil } - func (kc *Cache) GetCacheKey(domain, project string, labels map[string]string) string { labelFormat := stringutil.FormatMap(labels) inputKey := strings.Join([]string{ diff --git a/server/datasource/local/kv/kv_dao.go b/server/datasource/local/kv/kv_dao.go index 0bb52278..f16ec090 100644 --- a/server/datasource/local/kv/kv_dao.go +++ b/server/datasource/local/kv/kv_dao.go @@ -20,7 +20,6 @@ package kv import ( "context" "encoding/json" - "github.com/apache/servicecomb-kie/server/datasource/local/file" "os" "path" "regexp" @@ -31,6 +30,7 @@ import ( "github.com/apache/servicecomb-kie/pkg/util" "github.com/apache/servicecomb-kie/server/datasource" "github.com/apache/servicecomb-kie/server/datasource/auth" + "github.com/apache/servicecomb-kie/server/datasource/local/file" "github.com/go-chassis/openlog" ) @@ -51,7 +51,7 @@ func (s *Dao) Create(ctx context.Context, kv *model.KVDoc, options ...datasource })) return nil, err } - + kvCache.CachePut([]*model.KVDoc{kv}) return kv, nil } diff --git a/server/datasource/local/track/polling_detail_dao.go b/server/datasource/local/track/polling_detail_dao.go index d78d0a6c..eab584bb 100644 --- a/server/datasource/local/track/polling_detail_dao.go +++ b/server/datasource/local/track/polling_detail_dao.go @@ -20,12 +20,13 @@ package track import ( "context" "encoding/json" + "os" + "path" + "github.com/apache/servicecomb-kie/pkg/model" "github.com/apache/servicecomb-kie/server/datasource" "github.com/apache/servicecomb-kie/server/datasource/local/file" "github.com/go-chassis/openlog" - "os" - "path" ) // Dao is the implementation diff --git a/server/db/db.go b/server/db/db.go index 1419ab59..7f75b32f 100644 --- a/server/db/db.go +++ b/server/db/db.go @@ -20,11 +20,11 @@ package db import ( "crypto/tls" "errors" - "github.com/apache/servicecomb-kie/server/datasource/local/file" "time" "github.com/apache/servicecomb-kie/server/config" "github.com/apache/servicecomb-kie/server/config/tlsutil" + "github.com/apache/servicecomb-kie/server/datasource/local/file" "github.com/go-chassis/cari/db" dconfig "github.com/go-chassis/cari/db/config" "github.com/go-chassis/openlog"