From 556eabe3e13a7a84aea4681ff5be4f805d190a52 Mon Sep 17 00:00:00 2001 From: adevjoe Date: Sun, 18 Feb 2024 17:59:03 +0800 Subject: [PATCH] feat: add stream ci for lint (merge request !1614) Squash merge branch 'feat/stream' into 'master' feat: add stream ci for lint --- .ci/lint.yml | 43 ++ .code.yml | 41 +- .golangci.yml | 68 +- bcs-common/.golangci.yml | 61 +- bcs-common/common/encryptv2/.golangci.yml | 54 +- bcs-common/common/encryptv2/cryptor.go | 9 +- bcs-common/common/encryptv2/types.go | 9 +- bcs-common/pkg/audit/.golangci.yml | 54 +- bcs-common/pkg/auth/.golangci.yml | 54 +- bcs-common/pkg/bcsapi/test/.golangci.yml | 54 +- bcs-common/pkg/bcsapiv4/.golangci.yml | 57 +- bcs-common/pkg/i18n/.golangci.yml | 54 +- bcs-common/pkg/otel/.golangci.yml | 54 +- .../bcs-apiserver-proxy}/.golangci.yml | 58 +- .../.golangci.yml | 58 +- .../.golangci.yml | 58 +- .../bcs-clusternet-controller/.golangci.yml | 121 ++++ .../bcs-component/bcs-egress/.golangci.yml | 121 ++++ .../bcs-general-pod-autoscaler/.golangci.yml | 121 ++++ .../bcs-k8s-custom-scheduler/.golangci.yml | 121 ++++ .../bcs-logbeat-sidecar/.golangci.yml | 121 ++++ .../bcs-multi-ns-proxy/.golangci.yml | 121 ++++ .../bcs-netservice-controller/.golangci.yml | 121 ++++ .../cni/.golangci.yml | 121 ++++ .../internal/httpsvr/handler.go | 7 + .../bcs-unified-apiserver/.golangci.yml | 121 ++++ .../bcs-webhook-server/.golangci.yml | 121 ++++ bcs-runtime/bcs-k8s/bcs-network/.golangci.yml | 131 ++++ .../exporter/node_exporter.go | 1 + bcs-runtime/bcs-k8s/kubernetes/.golangci.yml | 121 ++++ .../bcs-k8s/kubernetes/common/.golangci.yml | 121 ++++ bcs-runtime/bcs-k8s/kubernetes/common/go.mod | 44 ++ bcs-runtime/bcs-k8s/kubernetes/go.mod | 62 ++ .../bcs-gitops-manager/.golangci.yml | 121 ++++ .../bcs-gitops-manager/handler/cluster.go | 1 - .../bcs-gitops-manager/handler/handler.go | 1 + .../pkg/proxy/argocd/analysis.go | 1 - .../pkg/proxy/argocd/argocd.go | 1 + .../pkg/proxy/argocd/middleware/handler.go | 6 +- .../pkg/store/app_history.go | 1 - .../bcs-gitops-manager/pkg/store/store.go | 1 + .../.golangci.yml | 121 ++++ .../bcs-gitops-vaultplugin-server/go.mod | 584 +++++++++--------- .../bcs-monitor-controller/.golangci.yml | 121 ++++ bcs-scenarios/bcs-monitor-controller/go.mod | 9 - .../pkg/httpsvr/httpserver.go | 1 + .../pkg/repo/git_repo.go | 10 +- .../bcs-terraform-controller/.golangci.yml | 121 ++++ bcs-scenarios/bcs-terraform-controller/go.mod | 3 +- .../pkg/server/server.go | 4 +- bcs-services/bcs-argocd-manager/.golangci.yml | 117 ---- .../bcs-bkcmdb-synchronizer/.golangci.yml | 121 ++++ bcs-services/bcs-bkcmdb-synchronizer/go.mod | 17 +- .../internal/pkg/handler/handler.go | 16 + .../internal/pkg/syncer/syncer.go | 4 + bcs-services/bcs-bscp/.golangci.yml | 59 +- .../bcs-bscp/cmd/api-server/service/kv.go | 2 + .../cmd/vault-server/service/gateway.go | 1 - .../cmd/vault-server/service/service.go | 1 + .../cmd/vault-server/vault-sidecar/init.go | 1 + .../cmd/vault-server/vault/.golangci.yml | 54 +- .../bcs-bscp/pkg/audit/routematch/matcher.go | 1 + .../bcs-bscp/pkg/components/bkpaas/auth.go | 1 - .../bcs-bscp/pkg/components/bkpaas/bkpaas.go | 1 + .../bcs-bscp/pkg/dal/repository/bkrepo.go | 1 - .../bcs-bscp/pkg/dal/repository/repository.go | 1 + .../pkg/protocol/auth-server/convert.go | 6 +- .../bcs-bscp/pkg/runtime/archive/tgz.go | 1 + .../bcs-bscp/pkg/runtime/archive/zip.go | 1 + .../pkg/runtime/selector/label_test.go | 1 + bcs-services/bcs-bscp/pkg/tools/algorithm.go | 1 - bcs-services/bcs-bscp/pkg/tools/tools.go | 1 + bcs-services/bcs-bscp/pkg/types/cache.go | 8 +- .../bcs-cli/bcs-cluster-manager/.golangci.yml | 54 +- .../bcs-cli/bcs-data-manager/.golangci.yml | 54 +- .../bcs-cli/bcs-project-manager/.golangci.yml | 54 +- .../bcs-cli/bcs-user-manager/.golangci.yml | 55 +- .../bcs-cli/bcs-user-manager/pkg/user.go | 4 +- .../bcs-cluster-manager/.golangci.yml | 61 +- .../internal/options/options.go | 2 +- .../internal/remote/encrypt/client.go | 2 +- .../internal/store/store.go | 2 +- .../internal/store/util/credentials.go | 2 +- .../.golangci.yml | 58 +- bcs-services/bcs-cluster-reporter/cmd/root.go | 5 +- .../internal/api/bcs/clustermanager.go | 1 + .../internal/metric_manager/metric_test.go | 2 +- .../plugin/clustercheck/clustercheck.go | 31 +- .../plugin/logrecorder/logrecorder.go | 2 +- .../plugin/masterpodcheck/masterpodcheck.go | 23 +- bcs-services/bcs-data-manager/.golangci.yml | 55 +- .../pkg/store/mongo/cloudnativeworkload.go | 1 - .../bcs-data-manager/pkg/store/mongo/mongo.go | 1 + .../bcs-gateway-discovery/.golangci.yml | 54 +- bcs-services/bcs-helm-manager/.golangci.yml | 54 +- bcs-services/bcs-helm-manager/go.mod | 10 +- .../bcs-helm-manager/internal/app/app.go | 2 +- .../internal/store/repository/repository.go | 2 +- .../bcs-helm-manager/internal/store/store.go | 4 +- bcs-services/bcs-k8s-watch/.golangci.yml | 54 +- bcs-services/bcs-k8s-watch/app/k8s/watcher.go | 1 + bcs-services/bcs-kube-agent/.golangci.yml | 54 +- bcs-services/bcs-mesh-manager/.golangci.yml | 117 ---- bcs-services/bcs-monitor/.golangci.yml | 54 +- .../bcs-netservice/bcs-ipam/.golangci.yml | 117 ---- .../bcs-nodegroup-manager/.golangci.yml | 54 +- .../bcs-project-manager/.golangci.yml | 54 +- bcs-services/bcs-storage/.golangci.yml | 54 +- bcs-services/bcs-user-manager/.golangci.yml | 54 +- .../user-manager/storages/sqlstore/token.go | 2 +- .../app/user-manager/user-manager.go | 2 +- .../bcs-user-manager/config/config.go | 2 +- bcs-services/bcs-user-manager/go.mod | 25 +- bcs-services/bcs-webconsole/.golangci.yml | 54 +- bcs-services/cluster-resources/.golangci.yml | 54 +- bcs-services/pkg/.golangci.yml | 54 +- bcs-services/pkg/bcs-auth-v4/.golangci.yml | 54 +- bcs-ui/.golangci.yml | 54 +- go.mod | 17 +- install/cryptool/.golangci.yml | 121 ++++ install/cryptool/main.go | 10 +- .../gen-lint/.golangci.yml.tpl | 22 +- scripts/gen-lint/golangci-lint.sh | 8 + scripts/gen-lint/main.go | 161 ++++- scripts/gen-lint/modules_black_list | 17 + 125 files changed, 4180 insertions(+), 1692 deletions(-) create mode 100644 .ci/lint.yml rename {bcs-services/bcs-api => bcs-runtime/bcs-k8s/bcs-component/bcs-apiserver-proxy}/.golangci.yml (67%) rename {bcs-services/bcs-netservice => bcs-runtime/bcs-k8s/bcs-component/bcs-cluster-autoscaler/bcs-cluster-autoscaler-1.16}/.golangci.yml (66%) rename {bcs-services/bcs-log-manager => bcs-runtime/bcs-k8s/bcs-component/bcs-cluster-autoscaler/bcs-cluster-autoscaler-1.22}/.golangci.yml (66%) create mode 100644 bcs-runtime/bcs-k8s/bcs-component/bcs-clusternet-controller/.golangci.yml create mode 100644 bcs-runtime/bcs-k8s/bcs-component/bcs-egress/.golangci.yml create mode 100644 bcs-runtime/bcs-k8s/bcs-component/bcs-general-pod-autoscaler/.golangci.yml create mode 100644 bcs-runtime/bcs-k8s/bcs-component/bcs-k8s-custom-scheduler/.golangci.yml create mode 100644 bcs-runtime/bcs-k8s/bcs-component/bcs-logbeat-sidecar/.golangci.yml create mode 100644 bcs-runtime/bcs-k8s/bcs-component/bcs-multi-ns-proxy/.golangci.yml create mode 100644 bcs-runtime/bcs-k8s/bcs-component/bcs-netservice-controller/.golangci.yml create mode 100644 bcs-runtime/bcs-k8s/bcs-component/bcs-netservice-controller/cni/.golangci.yml create mode 100644 bcs-runtime/bcs-k8s/bcs-component/bcs-unified-apiserver/.golangci.yml create mode 100644 bcs-runtime/bcs-k8s/bcs-component/bcs-webhook-server/.golangci.yml create mode 100644 bcs-runtime/bcs-k8s/bcs-network/.golangci.yml create mode 100644 bcs-runtime/bcs-k8s/kubernetes/.golangci.yml create mode 100644 bcs-runtime/bcs-k8s/kubernetes/common/.golangci.yml create mode 100644 bcs-scenarios/bcs-gitops-manager/.golangci.yml create mode 100644 bcs-scenarios/bcs-gitops-vaultplugin-server/.golangci.yml create mode 100644 bcs-scenarios/bcs-monitor-controller/.golangci.yml create mode 100644 bcs-scenarios/bcs-terraform-controller/.golangci.yml delete mode 100644 bcs-services/bcs-argocd-manager/.golangci.yml create mode 100644 bcs-services/bcs-bkcmdb-synchronizer/.golangci.yml rename bcs-services/{bcs-client => bcs-cluster-reporter}/.golangci.yml (69%) delete mode 100644 bcs-services/bcs-mesh-manager/.golangci.yml delete mode 100644 bcs-services/bcs-netservice/bcs-ipam/.golangci.yml create mode 100644 install/cryptool/.golangci.yml rename bcs-services/bcs-alert-manager/.golangci.yml => scripts/gen-lint/.golangci.yml.tpl (84%) create mode 100755 scripts/gen-lint/golangci-lint.sh create mode 100644 scripts/gen-lint/modules_black_list diff --git a/.ci/lint.yml b/.ci/lint.yml new file mode 100644 index 0000000000..595c515aea --- /dev/null +++ b/.ci/lint.yml @@ -0,0 +1,43 @@ +version: v2.0 + +on: + push: [ master ] + mr: [ master, v1.* ] + +stages: +- name: lint + jobs: + prepare: + steps: + - checkout: self + name: 拉取代码 + - run: | + dir_json="$(find . -type f -name '.golangci.yml' -exec dirname {} \; | sed 's|^\./||' | sort -u | jq -c -R -s 'split("\n") | map(select(. != "")) | {dirs: .}')" + echo "::set-output name=parameters::$dir_json" + id: set-matrix + name: 矩阵参数生成 + - run: | + bcs_image=${{ settings.bcs_docker_image.password }} + echo "::set-output name=parameters::$bcs_image" + id: set-image + name: 镜像参数设置 + build: + depend-on: + - prepare + strategy: + matrix: ${{ fromJSON(jobs.prepare.steps.set-matrix.outputs.parameters) }} + max-parallel: 20 + name: ${{ matrix.dirs }} 代码检查 + runs-on: + pool-name: docker + container: + image: ${{ jobs.prepare.steps.set-image.outputs.parameters }} + steps: + - checkout: self + name: 拉取代码 + - run: | + wget -O- -nv https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.54.2 + mv ./bin/golangci-lint /usr/bin/golangci-lint + cd ${{ matrix.dirs }} + go mod tidy + CGO_ENABLED=0 golangci-lint run \ No newline at end of file diff --git a/.code.yml b/.code.yml index a58be2294d..3e03d8403d 100644 --- a/.code.yml +++ b/.code.yml @@ -7,8 +7,23 @@ source: #用于匹配文件; 匹配方式为正则表达式。 filepath_regex: # Deprecated module - - /bcs-services/bcs-argocd-manager/ - - /bcs-services/bcs-log-manager/ + - /bcs-services/bcs-mesh-manager/.* + - /bcs-services/bcs-api/.* + - /bcs-services/bcs-alert-manager/.* + - /bcs-services/bcs-log-manager/.* + - /bcs-services/bcs-netservice/.* + - /bcs-services/bcs-netservice/bcs-ipam/.* + - /bcs-services/bcs-argocd-manager/.* + - /bcs-services/bcs-client/.* + - /bcs-runtime/bcs-k8s/kubebkbcs/.* + - /bcs-runtime/bcs-k8s/kubedeprecated/.* + - /bcs-runtime/bcs-k8s/bcs-component/bcs-k8s-driver/.* + - /bcs-services/bcs-upgrader/.* + - /bcs-services/bcs-service-prometheus/.* + - /bcs-network/.* + - /bcs-runtime/bcs-mesos/.* + - /bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent/.* + - /bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device/.* # Comment ratio - /bcs-services/bcs-bscp/cmd/data-service/service/config_item.go @@ -17,7 +32,6 @@ source: - /bcs-services/bcs-bscp/test/mock/repo/service/node.go - /bcs-services/bcs-cli/bcs-user-manager/cmd/create.go - /bcs-services/bcs-cluster-manager/internal/cloudprovider/qcloud/tasks/createNodeGroup.go - - /bcs-services/bcs-mesh-manager/config/options.go - /bcs-services/bcs-upgrader/upgrades/u1.21.202203082112/migrate.go - /bcs-services/bcs-upgrader/upgrades/u1.21.202203082112/types.go - /bcs-services/bcs-cluster-manager/internal/cloudprovider/qcloud/tasks/createNodeGroup.go @@ -28,8 +42,6 @@ source: - /bcs-common/go.mod - /bcs-runtime/bcs-k8s/bcs-component/bcs-cluster-autoscaler/bcs-cluster-autoscaler-1.16/go.mod - /bcs-runtime/bcs-k8s/bcs-component/bcs-cluster-autoscaler/bcs-cluster-autoscaler-1.22/go.mod - - /bcs-services/bcs-alert-manager/go.mod - - /bcs-services/bcs-client/go.mod - /bcs-services/bcs-data-manager/go.mod - /bcs-services/bcs-gateway-discovery/plugins/t/bcs-auth.t - /bcs-services/bcs-k8s-watch/go.mod @@ -41,6 +53,10 @@ source: - /bcs-scenarios/kourse - /bcs-common/pkg/bcsapi/storage/tkex/gamedeployment/v1alpha1/gamedeployment.go - /bcs-common/pkg/bcsapiv4/storage/tkex/gamedeployment/v1alpha1/gamedeployment.go + - /bcs-common/pkg/bcsapi/storage/tkex/gamestatefulset/v1alpha1/gamestatefulset.go + - /bcs-common/pkg/bcsapiv4/storage/tkex/gamestatefulset/v1alpha1/gamestatefulset.go + - /bcs-common/pkg/bcsapi/storage/tkex/generalpodautoscaler/v1alpha1/generalpodautoscaler.go + - /bcs-common/pkg/bcsapiv4/storage/tkex/generalpodautoscaler/v1alpha1/generalpodautoscaler.go - /bcs-common/pkg/esb/apigateway/bkdata/types.go - /bcs-runtime/bcs-k8s/bcs-component/bcs-cluster-autoscaler/core/scale_up.go - /bcs-runtime/bcs-k8s/bcs-component/bcs-cluster-autoscaler/simulator/drain.go @@ -64,21 +80,7 @@ source: - /bcs-runtime/bcs-k8s/bcs-network/internal/.* - /bcs-runtime/bcs-k8s/bcs-network/pkg/.* - /bcs-runtime/bcs-k8s/bcs-network/qcloud-eip/.* - - /bcs-runtime/bcs-k8s/kubebkbcs/.* - - /bcs-runtime/bcs-k8s/kubedeprecated/.* - /bcs-runtime/bcs-k8s/kubernetes/.* - - /bcs-runtime/bcs-mesos/bcs-clb-controller/.* - - /bcs-runtime/bcs-mesos/bcs-container-executor/.* - - /bcs-runtime/bcs-mesos/bcs-dns/.* - - /bcs-runtime/bcs-mesos/bcs-hpacontroller/.* - - /bcs-runtime/bcs-mesos/bcs-loadbalance/.* - - /bcs-runtime/bcs-mesos/bcs-mesos-driver/.* - - /bcs-runtime/bcs-mesos/bcs-mesos-watch/.* - - /bcs-runtime/bcs-mesos/bcs-scheduler/.* - - /bcs-runtime/bcs-mesos/bmsf-mesh/pkg/.* - - /bcs-runtime/bcs-mesos/kubebkbcsv2/.* - - /bcs-runtime/bcs-mesos/mesosv2/.* - - /bcs-runtime/bcs-mesos/pkg/.* - /bcs-services/bcs-bscp/pkg/version/version.go - /bcs-services/bcs-clb-controller/apis/.* - /bcs-services/bcs-clb-controller/client/.* @@ -86,7 +88,6 @@ source: - /bcs-services/bcs-cluster-manager/internal/cloudprovider/component/.* - /bcs-services/bcs-cluster-manager/internal/cloudprovider/qcloud/api/common_.* - /bcs-services/bcs-data-manager/pkg/mock/.* - - /bcs-services/bcs-mesh-manager/api/.* # 提供产品代码库中工具或框架自动生成的且在代码库中的代码,没有可为空。以便后续代码统计环节进行排除等特殊处理。 auto_generate_source: diff --git a/.golangci.yml b/.golangci.yml index c9678d5926..bd1d222a98 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,26 +1,36 @@ run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - # - gci + - gci - goconst - gocritic - gocyclo @@ -34,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -46,39 +54,39 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true - # goimports: - # local-prefixes: github.com/Tencent/bk-bcs - # gci: - # sections: - # - standard - # - default - # - prefix(github.com/Tencent/bk-bcs) + goimports: + local-prefixes: github.com/Tencent/bk-bcs + gci: + sections: + - standard + - default + - prefix(github.com/Tencent/bk-bcs) gocritic: settings: ifElseChain: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -110,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-common/.golangci.yml b/bcs-common/.golangci.yml index 3442610731..04c3a4cb4c 100644 --- a/bcs-common/.golangci.yml +++ b/bcs-common/.golangci.yml @@ -1,26 +1,41 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ + - pkg/bcsapi/storage/tkex/gamedeployment/v1alpha1/gamedeployment.go + - pkg/bcsapiv4/storage/tkex/gamedeployment/v1alpha1/gamedeployment.go + - pkg/bcsapi/storage/tkex/gamestatefulset/v1alpha1/gamestatefulset.go + - pkg/bcsapiv4/storage/tkex/gamestatefulset/v1alpha1/gamestatefulset.go + - pkg/bcsapi/storage/tkex/generalpodautoscaler/v1alpha1/generalpodautoscaler.go + - pkg/bcsapiv4/storage/tkex/generalpodautoscaler/v1alpha1/generalpodautoscaler.go + - pkg/esb/apigateway/bkdata/types.go issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +51,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +61,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +82,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +125,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-common/common/encryptv2/.golangci.yml b/bcs-common/common/encryptv2/.golangci.yml index 3aa974efdd..2b2b25198a 100644 --- a/bcs-common/common/encryptv2/.golangci.yml +++ b/bcs-common/common/encryptv2/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +54,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +75,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-common/common/encryptv2/cryptor.go b/bcs-common/common/encryptv2/cryptor.go index ee2d7ba7d4..fbcba08adc 100644 --- a/bcs-common/common/encryptv2/cryptor.go +++ b/bcs-common/common/encryptv2/cryptor.go @@ -1,10 +1,11 @@ +// nolint /* * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. * Licensed under the MIT License (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * http://opensource.org/licenses/MIT - * Unless required by applicable law or agreed to in writing, software distributed under, + * 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. @@ -18,7 +19,7 @@ import ( "errors" "fmt" - bkcrypto "github.com/TencentBlueKing/crypto-golang-sdk" + bkcrypto "github.com/TencentBlueKing/crypto-golang-sdk" // nolint ) // Cryptor 密码器 @@ -110,7 +111,7 @@ func newBkCrypto(conf *Config) (bkcrypto.Crypto, error) { type aesGcmCrypto struct { kv string nonce string - randomIv string + randomIv string // nolint } // NewAesGcmCrypto bcs crypto from aesFcm, kv 16,24,32 && nonce 12-16 @@ -183,7 +184,7 @@ func (c *aesGcmCrypto) Decrypt(ciphertext []byte) ([]byte, error) { type sm4Crypto struct { kv string iv string - randomIv string + randomIv string // nolint } // NewSm4Crypto bcs crypto from sm4, kv 16 && iv 16 diff --git a/bcs-common/common/encryptv2/types.go b/bcs-common/common/encryptv2/types.go index 593e228b9b..ccdb5d1baf 100644 --- a/bcs-common/common/encryptv2/types.go +++ b/bcs-common/common/encryptv2/types.go @@ -4,7 +4,7 @@ * Licensed under the MIT License (the "License"); you may not use this file except * in compliance with the License. You may obtain a copy of the License at * http://opensource.org/licenses/MIT - * Unless required by applicable law or agreed to in writing, software distributed under, + * 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. @@ -62,7 +62,7 @@ var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") func RandomId(n int) string { b := make([]rune, n) for i := range b { - b[i] = letters[rand.Intn(len(letters))] + b[i] = letters[rand.Intn(len(letters))] // nolint } return string(b) } @@ -71,8 +71,11 @@ func RandomId(n int) string { type Algorithm string const ( - Sm4 Algorithm = "SM4" + // Sm4 SM4 cryptography algorithm + Sm4 Algorithm = "SM4" + // AesGcm AES-GCM cryptography algorithm AesGcm Algorithm = "AES-GCM" + // Normal normal algorithm Normal Algorithm = "normal" ) diff --git a/bcs-common/pkg/audit/.golangci.yml b/bcs-common/pkg/audit/.golangci.yml index 11769142dd..aae12fa2cd 100644 --- a/bcs-common/pkg/audit/.golangci.yml +++ b/bcs-common/pkg/audit/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +54,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +75,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-common/pkg/auth/.golangci.yml b/bcs-common/pkg/auth/.golangci.yml index 84a38c539d..5b63d87ad3 100644 --- a/bcs-common/pkg/auth/.golangci.yml +++ b/bcs-common/pkg/auth/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +54,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +75,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-common/pkg/bcsapi/test/.golangci.yml b/bcs-common/pkg/bcsapi/test/.golangci.yml index 0f3ae9a988..384b9b7e49 100644 --- a/bcs-common/pkg/bcsapi/test/.golangci.yml +++ b/bcs-common/pkg/bcsapi/test/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +54,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +75,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-common/pkg/bcsapiv4/.golangci.yml b/bcs-common/pkg/bcsapiv4/.golangci.yml index 3bb58d600d..8f5d83b52e 100644 --- a/bcs-common/pkg/bcsapiv4/.golangci.yml +++ b/bcs-common/pkg/bcsapiv4/.golangci.yml @@ -1,26 +1,37 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ + - storage/tkex/gamedeployment/v1alpha1/gamedeployment.go + - storage/tkex/gamestatefulset/v1alpha1/gamestatefulset.go + - storage/tkex/generalpodautoscaler/v1alpha1/generalpodautoscaler.go issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +47,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +57,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +78,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +121,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-common/pkg/i18n/.golangci.yml b/bcs-common/pkg/i18n/.golangci.yml index 16e21b4f15..e43ed3f835 100644 --- a/bcs-common/pkg/i18n/.golangci.yml +++ b/bcs-common/pkg/i18n/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +54,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +75,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-common/pkg/otel/.golangci.yml b/bcs-common/pkg/otel/.golangci.yml index 7e69db9dba..c38148b587 100644 --- a/bcs-common/pkg/otel/.golangci.yml +++ b/bcs-common/pkg/otel/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +54,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +75,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-services/bcs-api/.golangci.yml b/bcs-runtime/bcs-k8s/bcs-component/bcs-apiserver-proxy/.golangci.yml similarity index 67% rename from bcs-services/bcs-api/.golangci.yml rename to bcs-runtime/bcs-k8s/bcs-component/bcs-apiserver-proxy/.golangci.yml index 38a411217c..051c269609 100644 --- a/bcs-services/bcs-api/.golangci.yml +++ b/bcs-runtime/bcs-k8s/bcs-component/bcs-apiserver-proxy/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,39 +54,39 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: - local-prefixes: github.com/Tencent/bk-bcs/bcs-services/bcs-api + local-prefixes: github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-apiserver-proxy gci: sections: - standard - default - - prefix(github.com/Tencent/bk-bcs/bcs-services/bcs-api) + - prefix(github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-apiserver-proxy) gocritic: settings: ifElseChain: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-services/bcs-netservice/.golangci.yml b/bcs-runtime/bcs-k8s/bcs-component/bcs-cluster-autoscaler/bcs-cluster-autoscaler-1.16/.golangci.yml similarity index 66% rename from bcs-services/bcs-netservice/.golangci.yml rename to bcs-runtime/bcs-k8s/bcs-component/bcs-cluster-autoscaler/bcs-cluster-autoscaler-1.16/.golangci.yml index c2aae31adb..ffcad105cc 100644 --- a/bcs-services/bcs-netservice/.golangci.yml +++ b/bcs-runtime/bcs-k8s/bcs-component/bcs-cluster-autoscaler/bcs-cluster-autoscaler-1.16/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,39 +54,39 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: - local-prefixes: github.com/Tencent/bk-bcs/bcs-services/bcs-netservice + local-prefixes: github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-cluster-autoscaler gci: sections: - standard - default - - prefix(github.com/Tencent/bk-bcs/bcs-services/bcs-netservice) + - prefix(github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-cluster-autoscaler) gocritic: settings: ifElseChain: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-services/bcs-log-manager/.golangci.yml b/bcs-runtime/bcs-k8s/bcs-component/bcs-cluster-autoscaler/bcs-cluster-autoscaler-1.22/.golangci.yml similarity index 66% rename from bcs-services/bcs-log-manager/.golangci.yml rename to bcs-runtime/bcs-k8s/bcs-component/bcs-cluster-autoscaler/bcs-cluster-autoscaler-1.22/.golangci.yml index 8ad69fee08..ffcad105cc 100644 --- a/bcs-services/bcs-log-manager/.golangci.yml +++ b/bcs-runtime/bcs-k8s/bcs-component/bcs-cluster-autoscaler/bcs-cluster-autoscaler-1.22/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,39 +54,39 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: - local-prefixes: github.com/Tencent/bk-bcs/bcs-services/bcs-log-manager + local-prefixes: github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-cluster-autoscaler gci: sections: - standard - default - - prefix(github.com/Tencent/bk-bcs/bcs-services/bcs-log-manager) + - prefix(github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-cluster-autoscaler) gocritic: settings: ifElseChain: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-runtime/bcs-k8s/bcs-component/bcs-clusternet-controller/.golangci.yml b/bcs-runtime/bcs-k8s/bcs-component/bcs-clusternet-controller/.golangci.yml new file mode 100644 index 0000000000..4bc6858093 --- /dev/null +++ b/bcs-runtime/bcs-k8s/bcs-component/bcs-clusternet-controller/.golangci.yml @@ -0,0 +1,121 @@ +run: + timeout: 10m + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-use-default: false +linters: + disable-all: true + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused + - funlen + - gci + - goconst + - gocritic + - gocyclo + - gofmt + - goheader + - goimports + - gosec + - lll + - misspell + - nakedret + - revive + - unconvert + - unparam +linters-settings: + errcheck: + exclude-functions: + - (*os.File).Close + - (io.Closer).Close + - (net/http.ResponseWriter).Write + - github.com/go-chi/render.Render + - io.Copy + - os.RemoveAll + lll: + line-length: 120 + funlen: + lines: 90 + statements: -1 + gocyclo: + min-complexity: 30 + govet: + check-shadowing: true + goimports: + local-prefixes: github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-clusternet-controller + gci: + sections: + - standard + - default + - prefix(github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-clusternet-controller) + gocritic: + settings: + ifElseChain: + minThreshold: 3 + gosec: + includes: + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 + goheader: + values: + regexp: + YEAR: 20\d\d + template: |- + * Tencent is pleased to support the open source community by making Blueking Container Service available. + * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * 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. + misspell: + locale: US + revive: + confidence: 0 + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: early-return + - name: error-naming + - name: error-return + - name: error-strings + - name: errorf + - name: exported + - name: increment-decrement + - name: indent-error-flow + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: var-declaration diff --git a/bcs-runtime/bcs-k8s/bcs-component/bcs-egress/.golangci.yml b/bcs-runtime/bcs-k8s/bcs-component/bcs-egress/.golangci.yml new file mode 100644 index 0000000000..8e1e0f2867 --- /dev/null +++ b/bcs-runtime/bcs-k8s/bcs-component/bcs-egress/.golangci.yml @@ -0,0 +1,121 @@ +run: + timeout: 10m + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-use-default: false +linters: + disable-all: true + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused + - funlen + - gci + - goconst + - gocritic + - gocyclo + - gofmt + - goheader + - goimports + - gosec + - lll + - misspell + - nakedret + - revive + - unconvert + - unparam +linters-settings: + errcheck: + exclude-functions: + - (*os.File).Close + - (io.Closer).Close + - (net/http.ResponseWriter).Write + - github.com/go-chi/render.Render + - io.Copy + - os.RemoveAll + lll: + line-length: 120 + funlen: + lines: 90 + statements: -1 + gocyclo: + min-complexity: 30 + govet: + check-shadowing: true + goimports: + local-prefixes: bcs-egress + gci: + sections: + - standard + - default + - prefix(bcs-egress) + gocritic: + settings: + ifElseChain: + minThreshold: 3 + gosec: + includes: + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 + goheader: + values: + regexp: + YEAR: 20\d\d + template: |- + * Tencent is pleased to support the open source community by making Blueking Container Service available. + * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * 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. + misspell: + locale: US + revive: + confidence: 0 + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: early-return + - name: error-naming + - name: error-return + - name: error-strings + - name: errorf + - name: exported + - name: increment-decrement + - name: indent-error-flow + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: var-declaration diff --git a/bcs-runtime/bcs-k8s/bcs-component/bcs-general-pod-autoscaler/.golangci.yml b/bcs-runtime/bcs-k8s/bcs-component/bcs-general-pod-autoscaler/.golangci.yml new file mode 100644 index 0000000000..5ec16ce700 --- /dev/null +++ b/bcs-runtime/bcs-k8s/bcs-component/bcs-general-pod-autoscaler/.golangci.yml @@ -0,0 +1,121 @@ +run: + timeout: 10m + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-use-default: false +linters: + disable-all: true + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused + - funlen + - gci + - goconst + - gocritic + - gocyclo + - gofmt + - goheader + - goimports + - gosec + - lll + - misspell + - nakedret + - revive + - unconvert + - unparam +linters-settings: + errcheck: + exclude-functions: + - (*os.File).Close + - (io.Closer).Close + - (net/http.ResponseWriter).Write + - github.com/go-chi/render.Render + - io.Copy + - os.RemoveAll + lll: + line-length: 120 + funlen: + lines: 90 + statements: -1 + gocyclo: + min-complexity: 30 + govet: + check-shadowing: true + goimports: + local-prefixes: github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-general-pod-autoscaler + gci: + sections: + - standard + - default + - prefix(github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-general-pod-autoscaler) + gocritic: + settings: + ifElseChain: + minThreshold: 3 + gosec: + includes: + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 + goheader: + values: + regexp: + YEAR: 20\d\d + template: |- + * Tencent is pleased to support the open source community by making Blueking Container Service available. + * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * 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. + misspell: + locale: US + revive: + confidence: 0 + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: early-return + - name: error-naming + - name: error-return + - name: error-strings + - name: errorf + - name: exported + - name: increment-decrement + - name: indent-error-flow + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: var-declaration diff --git a/bcs-runtime/bcs-k8s/bcs-component/bcs-k8s-custom-scheduler/.golangci.yml b/bcs-runtime/bcs-k8s/bcs-component/bcs-k8s-custom-scheduler/.golangci.yml new file mode 100644 index 0000000000..58226e3aab --- /dev/null +++ b/bcs-runtime/bcs-k8s/bcs-component/bcs-k8s-custom-scheduler/.golangci.yml @@ -0,0 +1,121 @@ +run: + timeout: 10m + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-use-default: false +linters: + disable-all: true + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused + - funlen + - gci + - goconst + - gocritic + - gocyclo + - gofmt + - goheader + - goimports + - gosec + - lll + - misspell + - nakedret + - revive + - unconvert + - unparam +linters-settings: + errcheck: + exclude-functions: + - (*os.File).Close + - (io.Closer).Close + - (net/http.ResponseWriter).Write + - github.com/go-chi/render.Render + - io.Copy + - os.RemoveAll + lll: + line-length: 120 + funlen: + lines: 90 + statements: -1 + gocyclo: + min-complexity: 30 + govet: + check-shadowing: true + goimports: + local-prefixes: github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-k8s-custom-scheduler + gci: + sections: + - standard + - default + - prefix(github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-k8s-custom-scheduler) + gocritic: + settings: + ifElseChain: + minThreshold: 3 + gosec: + includes: + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 + goheader: + values: + regexp: + YEAR: 20\d\d + template: |- + * Tencent is pleased to support the open source community by making Blueking Container Service available. + * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * 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. + misspell: + locale: US + revive: + confidence: 0 + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: early-return + - name: error-naming + - name: error-return + - name: error-strings + - name: errorf + - name: exported + - name: increment-decrement + - name: indent-error-flow + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: var-declaration diff --git a/bcs-runtime/bcs-k8s/bcs-component/bcs-logbeat-sidecar/.golangci.yml b/bcs-runtime/bcs-k8s/bcs-component/bcs-logbeat-sidecar/.golangci.yml new file mode 100644 index 0000000000..d4f085b0ed --- /dev/null +++ b/bcs-runtime/bcs-k8s/bcs-component/bcs-logbeat-sidecar/.golangci.yml @@ -0,0 +1,121 @@ +run: + timeout: 10m + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-use-default: false +linters: + disable-all: true + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused + - funlen + - gci + - goconst + - gocritic + - gocyclo + - gofmt + - goheader + - goimports + - gosec + - lll + - misspell + - nakedret + - revive + - unconvert + - unparam +linters-settings: + errcheck: + exclude-functions: + - (*os.File).Close + - (io.Closer).Close + - (net/http.ResponseWriter).Write + - github.com/go-chi/render.Render + - io.Copy + - os.RemoveAll + lll: + line-length: 120 + funlen: + lines: 90 + statements: -1 + gocyclo: + min-complexity: 30 + govet: + check-shadowing: true + goimports: + local-prefixes: github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-logbeat-sidecar + gci: + sections: + - standard + - default + - prefix(github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-logbeat-sidecar) + gocritic: + settings: + ifElseChain: + minThreshold: 3 + gosec: + includes: + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 + goheader: + values: + regexp: + YEAR: 20\d\d + template: |- + * Tencent is pleased to support the open source community by making Blueking Container Service available. + * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * 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. + misspell: + locale: US + revive: + confidence: 0 + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: early-return + - name: error-naming + - name: error-return + - name: error-strings + - name: errorf + - name: exported + - name: increment-decrement + - name: indent-error-flow + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: var-declaration diff --git a/bcs-runtime/bcs-k8s/bcs-component/bcs-multi-ns-proxy/.golangci.yml b/bcs-runtime/bcs-k8s/bcs-component/bcs-multi-ns-proxy/.golangci.yml new file mode 100644 index 0000000000..38ae85cb7c --- /dev/null +++ b/bcs-runtime/bcs-k8s/bcs-component/bcs-multi-ns-proxy/.golangci.yml @@ -0,0 +1,121 @@ +run: + timeout: 10m + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-use-default: false +linters: + disable-all: true + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused + - funlen + - gci + - goconst + - gocritic + - gocyclo + - gofmt + - goheader + - goimports + - gosec + - lll + - misspell + - nakedret + - revive + - unconvert + - unparam +linters-settings: + errcheck: + exclude-functions: + - (*os.File).Close + - (io.Closer).Close + - (net/http.ResponseWriter).Write + - github.com/go-chi/render.Render + - io.Copy + - os.RemoveAll + lll: + line-length: 120 + funlen: + lines: 90 + statements: -1 + gocyclo: + min-complexity: 30 + govet: + check-shadowing: true + goimports: + local-prefixes: github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-multi-ns-proxy + gci: + sections: + - standard + - default + - prefix(github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-multi-ns-proxy) + gocritic: + settings: + ifElseChain: + minThreshold: 3 + gosec: + includes: + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 + goheader: + values: + regexp: + YEAR: 20\d\d + template: |- + * Tencent is pleased to support the open source community by making Blueking Container Service available. + * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * 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. + misspell: + locale: US + revive: + confidence: 0 + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: early-return + - name: error-naming + - name: error-return + - name: error-strings + - name: errorf + - name: exported + - name: increment-decrement + - name: indent-error-flow + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: var-declaration diff --git a/bcs-runtime/bcs-k8s/bcs-component/bcs-netservice-controller/.golangci.yml b/bcs-runtime/bcs-k8s/bcs-component/bcs-netservice-controller/.golangci.yml new file mode 100644 index 0000000000..461007251e --- /dev/null +++ b/bcs-runtime/bcs-k8s/bcs-component/bcs-netservice-controller/.golangci.yml @@ -0,0 +1,121 @@ +run: + timeout: 10m + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-use-default: false +linters: + disable-all: true + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused + - funlen + - gci + - goconst + - gocritic + - gocyclo + - gofmt + - goheader + - goimports + - gosec + - lll + - misspell + - nakedret + - revive + - unconvert + - unparam +linters-settings: + errcheck: + exclude-functions: + - (*os.File).Close + - (io.Closer).Close + - (net/http.ResponseWriter).Write + - github.com/go-chi/render.Render + - io.Copy + - os.RemoveAll + lll: + line-length: 120 + funlen: + lines: 90 + statements: -1 + gocyclo: + min-complexity: 30 + govet: + check-shadowing: true + goimports: + local-prefixes: github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-netservice-controller + gci: + sections: + - standard + - default + - prefix(github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-netservice-controller) + gocritic: + settings: + ifElseChain: + minThreshold: 3 + gosec: + includes: + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 + goheader: + values: + regexp: + YEAR: 20\d\d + template: |- + * Tencent is pleased to support the open source community by making Blueking Container Service available. + * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * 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. + misspell: + locale: US + revive: + confidence: 0 + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: early-return + - name: error-naming + - name: error-return + - name: error-strings + - name: errorf + - name: exported + - name: increment-decrement + - name: indent-error-flow + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: var-declaration diff --git a/bcs-runtime/bcs-k8s/bcs-component/bcs-netservice-controller/cni/.golangci.yml b/bcs-runtime/bcs-k8s/bcs-component/bcs-netservice-controller/cni/.golangci.yml new file mode 100644 index 0000000000..4990d60cf0 --- /dev/null +++ b/bcs-runtime/bcs-k8s/bcs-component/bcs-netservice-controller/cni/.golangci.yml @@ -0,0 +1,121 @@ +run: + timeout: 10m + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-use-default: false +linters: + disable-all: true + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused + - funlen + - gci + - goconst + - gocritic + - gocyclo + - gofmt + - goheader + - goimports + - gosec + - lll + - misspell + - nakedret + - revive + - unconvert + - unparam +linters-settings: + errcheck: + exclude-functions: + - (*os.File).Close + - (io.Closer).Close + - (net/http.ResponseWriter).Write + - github.com/go-chi/render.Render + - io.Copy + - os.RemoveAll + lll: + line-length: 120 + funlen: + lines: 90 + statements: -1 + gocyclo: + min-complexity: 30 + govet: + check-shadowing: true + goimports: + local-prefixes: github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-netservice-controller/cni + gci: + sections: + - standard + - default + - prefix(github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-netservice-controller/cni) + gocritic: + settings: + ifElseChain: + minThreshold: 3 + gosec: + includes: + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 + goheader: + values: + regexp: + YEAR: 20\d\d + template: |- + * Tencent is pleased to support the open source community by making Blueking Container Service available. + * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * 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. + misspell: + locale: US + revive: + confidence: 0 + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: early-return + - name: error-naming + - name: error-return + - name: error-strings + - name: errorf + - name: exported + - name: increment-decrement + - name: indent-error-flow + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: var-declaration diff --git a/bcs-runtime/bcs-k8s/bcs-component/bcs-netservice-controller/internal/httpsvr/handler.go b/bcs-runtime/bcs-k8s/bcs-component/bcs-netservice-controller/internal/httpsvr/handler.go index 1c3da3a485..47811f375d 100644 --- a/bcs-runtime/bcs-k8s/bcs-component/bcs-netservice-controller/internal/httpsvr/handler.go +++ b/bcs-runtime/bcs-k8s/bcs-component/bcs-netservice-controller/internal/httpsvr/handler.go @@ -234,6 +234,7 @@ func (c *HttpServerClient) allocateNewIPForClaim( blog.Errorf(message) return nil, nil, fmt.Errorf(message) } + // update ip status targetIP := availableIP[0] if err := c.updateIPStatus(targetIP, netIPReq, utils.GetNamespacedNameKey(netIPReq.PodNamespace, ipClaim.GetName()), "", true); err != nil { @@ -241,6 +242,7 @@ func (c *HttpServerClient) allocateNewIPForClaim( blog.Errorf(message) return nil, nil, fmt.Errorf(message) } + // bound ip claim if err := c.boundClaimIP(ipClaim, targetIP); err != nil { message := fmt.Sprintf("bound BCSNetIP %s to BCSNetIPClaim %s/%s failed, err %s", targetIP.GetName(), ipClaim.GetNamespace(), ipClaim.GetName(), err.Error()) @@ -249,6 +251,7 @@ func (c *HttpServerClient) allocateNewIPForClaim( } message := fmt.Sprintf("allocate fixed IP [%s] for Host %s success", targetIP.Name, netIPReq.Host) blog.Infof(message) + // get pool by ip bcspool, err := c.getPoolByIP(targetIP) if err != nil { message := fmt.Sprintf("get pool failed, err %s", err.Error()) @@ -276,6 +279,7 @@ func (c *HttpServerClient) allocateIPByClaim( blog.Errorf(message) return nil, nil, fmt.Errorf(message) } + // update ip status if err := c.updateIPStatus( bcsNetIP, netIPReq, utils.GetNamespacedNameKey(ipClaim.GetNamespace(), ipClaim.GetName()), ipClaim.Spec.ExpiredDuration, true); err != nil { @@ -329,6 +333,7 @@ func (c *HttpServerClient) getAvailableIPs(netPoolList *v1.BCSNetPoolList, netIP } } } + // if host not found in pools, return error if !found { message := fmt.Sprintf("host %s does not exist in pools", netIPReq.Host) blog.Errorf(message) @@ -393,6 +398,7 @@ func (c *HttpServerClient) DeleteIP(request *restful.Request, response *restful. return } + // list all BCSNetIP netIPList := &v1.BCSNetIPList{} if err := c.K8SClient.List(context.Background(), netIPList); err != nil { message := fmt.Sprintf("get BCSNetIP list failed, %s", err.Error()) @@ -444,6 +450,7 @@ func (c *HttpServerClient) DeleteIP(request *restful.Request, response *restful. } } + // update BCSNetIP status if err := c.K8SClient.Status().Update(context.Background(), netIP); err != nil { message := fmt.Sprintf("update IP [%s] status failed", netIP.Name) blog.Errorf(message) diff --git a/bcs-runtime/bcs-k8s/bcs-component/bcs-unified-apiserver/.golangci.yml b/bcs-runtime/bcs-k8s/bcs-component/bcs-unified-apiserver/.golangci.yml new file mode 100644 index 0000000000..804d5366e5 --- /dev/null +++ b/bcs-runtime/bcs-k8s/bcs-component/bcs-unified-apiserver/.golangci.yml @@ -0,0 +1,121 @@ +run: + timeout: 10m + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-use-default: false +linters: + disable-all: true + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused + - funlen + - gci + - goconst + - gocritic + - gocyclo + - gofmt + - goheader + - goimports + - gosec + - lll + - misspell + - nakedret + - revive + - unconvert + - unparam +linters-settings: + errcheck: + exclude-functions: + - (*os.File).Close + - (io.Closer).Close + - (net/http.ResponseWriter).Write + - github.com/go-chi/render.Render + - io.Copy + - os.RemoveAll + lll: + line-length: 120 + funlen: + lines: 90 + statements: -1 + gocyclo: + min-complexity: 30 + govet: + check-shadowing: true + goimports: + local-prefixes: github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-unified-apiserver + gci: + sections: + - standard + - default + - prefix(github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-unified-apiserver) + gocritic: + settings: + ifElseChain: + minThreshold: 3 + gosec: + includes: + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 + goheader: + values: + regexp: + YEAR: 20\d\d + template: |- + * Tencent is pleased to support the open source community by making Blueking Container Service available. + * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * 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. + misspell: + locale: US + revive: + confidence: 0 + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: early-return + - name: error-naming + - name: error-return + - name: error-strings + - name: errorf + - name: exported + - name: increment-decrement + - name: indent-error-flow + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: var-declaration diff --git a/bcs-runtime/bcs-k8s/bcs-component/bcs-webhook-server/.golangci.yml b/bcs-runtime/bcs-k8s/bcs-component/bcs-webhook-server/.golangci.yml new file mode 100644 index 0000000000..06e6e02b71 --- /dev/null +++ b/bcs-runtime/bcs-k8s/bcs-component/bcs-webhook-server/.golangci.yml @@ -0,0 +1,121 @@ +run: + timeout: 10m + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-use-default: false +linters: + disable-all: true + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused + - funlen + - gci + - goconst + - gocritic + - gocyclo + - gofmt + - goheader + - goimports + - gosec + - lll + - misspell + - nakedret + - revive + - unconvert + - unparam +linters-settings: + errcheck: + exclude-functions: + - (*os.File).Close + - (io.Closer).Close + - (net/http.ResponseWriter).Write + - github.com/go-chi/render.Render + - io.Copy + - os.RemoveAll + lll: + line-length: 120 + funlen: + lines: 90 + statements: -1 + gocyclo: + min-complexity: 30 + govet: + check-shadowing: true + goimports: + local-prefixes: github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-webhook-server + gci: + sections: + - standard + - default + - prefix(github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-webhook-server) + gocritic: + settings: + ifElseChain: + minThreshold: 3 + gosec: + includes: + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 + goheader: + values: + regexp: + YEAR: 20\d\d + template: |- + * Tencent is pleased to support the open source community by making Blueking Container Service available. + * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * 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. + misspell: + locale: US + revive: + confidence: 0 + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: early-return + - name: error-naming + - name: error-return + - name: error-strings + - name: errorf + - name: exported + - name: increment-decrement + - name: indent-error-flow + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: var-declaration diff --git a/bcs-runtime/bcs-k8s/bcs-network/.golangci.yml b/bcs-runtime/bcs-k8s/bcs-network/.golangci.yml new file mode 100644 index 0000000000..4bb6da0d85 --- /dev/null +++ b/bcs-runtime/bcs-k8s/bcs-network/.golangci.yml @@ -0,0 +1,131 @@ +run: + timeout: 10m + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + - api/* + - bcs-cloud-netagent/* + - bcs-cloud-netcontroller/* + - bcs-cloudnetwork/* + - bcs-ipmasq-cidrsync/* + - bcs-ipres-webhook/* + - bcs-networkpolicy/* + - internal/* + - pkg/* + - qcloud-eip/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-use-default: false +linters: + disable-all: true + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused + - funlen + - gci + - goconst + - gocritic + - gocyclo + - gofmt + - goheader + - goimports + - gosec + - lll + - misspell + - nakedret + - revive + - unconvert + - unparam +linters-settings: + errcheck: + exclude-functions: + - (*os.File).Close + - (io.Closer).Close + - (net/http.ResponseWriter).Write + - github.com/go-chi/render.Render + - io.Copy + - os.RemoveAll + lll: + line-length: 120 + funlen: + lines: 90 + statements: -1 + gocyclo: + min-complexity: 30 + govet: + check-shadowing: true + goimports: + local-prefixes: github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-network + gci: + sections: + - standard + - default + - prefix(github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-network) + gocritic: + settings: + ifElseChain: + minThreshold: 3 + gosec: + includes: + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 + goheader: + values: + regexp: + YEAR: 20\d\d + template: |- + * Tencent is pleased to support the open source community by making Blueking Container Service available. + * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * 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. + misspell: + locale: US + revive: + confidence: 0 + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: early-return + - name: error-naming + - name: error-return + - name: error-strings + - name: errorf + - name: exported + - name: increment-decrement + - name: indent-error-flow + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: var-declaration diff --git a/bcs-runtime/bcs-k8s/bcs-network/bcs-node-external-worker/exporter/node_exporter.go b/bcs-runtime/bcs-k8s/bcs-network/bcs-node-external-worker/exporter/node_exporter.go index a8f7c4ee8b..ca5218d0dd 100644 --- a/bcs-runtime/bcs-k8s/bcs-network/bcs-node-external-worker/exporter/node_exporter.go +++ b/bcs-runtime/bcs-k8s/bcs-network/bcs-node-external-worker/exporter/node_exporter.go @@ -45,6 +45,7 @@ type NodeExporter struct { externalIP string } +// Watch watch external ip func (n *NodeExporter) Watch() { ticker := time.NewTicker(time.Second * 5) defer ticker.Stop() diff --git a/bcs-runtime/bcs-k8s/kubernetes/.golangci.yml b/bcs-runtime/bcs-k8s/kubernetes/.golangci.yml new file mode 100644 index 0000000000..4c2d70c48a --- /dev/null +++ b/bcs-runtime/bcs-k8s/kubernetes/.golangci.yml @@ -0,0 +1,121 @@ +run: + timeout: 10m + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-use-default: false +linters: + disable-all: true + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused + - funlen + - gci + - goconst + - gocritic + - gocyclo + - gofmt + - goheader + - goimports + - gosec + - lll + - misspell + - nakedret + - revive + - unconvert + - unparam +linters-settings: + errcheck: + exclude-functions: + - (*os.File).Close + - (io.Closer).Close + - (net/http.ResponseWriter).Write + - github.com/go-chi/render.Render + - io.Copy + - os.RemoveAll + lll: + line-length: 120 + funlen: + lines: 90 + statements: -1 + gocyclo: + min-complexity: 30 + govet: + check-shadowing: true + goimports: + local-prefixes: github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/kubernetes + gci: + sections: + - standard + - default + - prefix(github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/kubernetes) + gocritic: + settings: + ifElseChain: + minThreshold: 3 + gosec: + includes: + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 + goheader: + values: + regexp: + YEAR: 20\d\d + template: |- + * Tencent is pleased to support the open source community by making Blueking Container Service available. + * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * 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. + misspell: + locale: US + revive: + confidence: 0 + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: early-return + - name: error-naming + - name: error-return + - name: error-strings + - name: errorf + - name: exported + - name: increment-decrement + - name: indent-error-flow + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: var-declaration diff --git a/bcs-runtime/bcs-k8s/kubernetes/common/.golangci.yml b/bcs-runtime/bcs-k8s/kubernetes/common/.golangci.yml new file mode 100644 index 0000000000..6b7c01d1ae --- /dev/null +++ b/bcs-runtime/bcs-k8s/kubernetes/common/.golangci.yml @@ -0,0 +1,121 @@ +run: + timeout: 10m + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-use-default: false +linters: + disable-all: true + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused + - funlen + - gci + - goconst + - gocritic + - gocyclo + - gofmt + - goheader + - goimports + - gosec + - lll + - misspell + - nakedret + - revive + - unconvert + - unparam +linters-settings: + errcheck: + exclude-functions: + - (*os.File).Close + - (io.Closer).Close + - (net/http.ResponseWriter).Write + - github.com/go-chi/render.Render + - io.Copy + - os.RemoveAll + lll: + line-length: 120 + funlen: + lines: 90 + statements: -1 + gocyclo: + min-complexity: 30 + govet: + check-shadowing: true + goimports: + local-prefixes: github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/kubernetes/common + gci: + sections: + - standard + - default + - prefix(github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/kubernetes/common) + gocritic: + settings: + ifElseChain: + minThreshold: 3 + gosec: + includes: + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 + goheader: + values: + regexp: + YEAR: 20\d\d + template: |- + * Tencent is pleased to support the open source community by making Blueking Container Service available. + * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * 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. + misspell: + locale: US + revive: + confidence: 0 + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: early-return + - name: error-naming + - name: error-return + - name: error-strings + - name: errorf + - name: exported + - name: increment-decrement + - name: indent-error-flow + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: var-declaration diff --git a/bcs-runtime/bcs-k8s/kubernetes/common/go.mod b/bcs-runtime/bcs-k8s/kubernetes/common/go.mod index 171652ccc2..c816514c59 100644 --- a/bcs-runtime/bcs-k8s/kubernetes/common/go.mod +++ b/bcs-runtime/bcs-k8s/kubernetes/common/go.mod @@ -48,3 +48,47 @@ require ( k8s.io/klog v1.0.0 k8s.io/klog/v2 v2.4.0 ) + +require ( + github.com/beorn7/perks v1.0.1 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/evanphx/json-patch v4.9.0+incompatible // indirect + github.com/go-logr/logr v0.2.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect + github.com/golang/protobuf v1.4.3 // indirect + github.com/google/go-cmp v0.5.4 // indirect + github.com/google/gofuzz v1.2.0 // indirect + github.com/googleapis/gnostic v0.5.3 // indirect + github.com/hashicorp/golang-lru v0.5.4 // indirect + github.com/json-iterator/go v1.1.10 // indirect + github.com/kr/text v0.2.0 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.1 // indirect + github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect + github.com/onsi/ginkgo v1.14.2 // indirect + github.com/onsi/gomega v1.10.4 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/prometheus/client_model v0.2.0 // indirect + github.com/prometheus/common v0.15.0 // indirect + github.com/prometheus/procfs v0.2.0 // indirect + golang.org/x/crypto v0.0.0-20201117144127-c1f2f97bffc9 // indirect + golang.org/x/net v0.0.0-20201224014010-6772e930b67b // indirect + golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58 // indirect + golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e // indirect + golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect + golang.org/x/text v0.3.5 // indirect + golang.org/x/time v0.0.0-20201208040808-7e3f01d25324 // indirect + google.golang.org/appengine v1.6.6 // indirect + google.golang.org/protobuf v1.25.0 // indirect + gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect + gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect + k8s.io/kube-openapi v0.0.0-20201113171705-d219536bb9fd // indirect + k8s.io/kubernetes v1.20.0 // indirect + k8s.io/utils v0.0.0-20201110183641-67b214c5f920 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.0.2 // indirect + sigs.k8s.io/yaml v1.2.0 // indirect +) diff --git a/bcs-runtime/bcs-k8s/kubernetes/go.mod b/bcs-runtime/bcs-k8s/kubernetes/go.mod index 18950b187f..b369029493 100644 --- a/bcs-runtime/bcs-k8s/kubernetes/go.mod +++ b/bcs-runtime/bcs-k8s/kubernetes/go.mod @@ -11,3 +11,65 @@ require ( k8s.io/code-generator v0.18.5 sigs.k8s.io/controller-runtime v0.6.0 ) + +require ( + github.com/PuerkitoBio/purell v1.1.1 // indirect + github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect + github.com/beorn7/perks v1.0.0 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/emicklei/go-restful v2.9.5+incompatible // indirect + github.com/evanphx/json-patch v4.5.0+incompatible // indirect + github.com/fsnotify/fsnotify v1.4.9 // indirect + github.com/go-logr/zapr v0.1.0 // indirect + github.com/go-openapi/jsonpointer v0.19.3 // indirect + github.com/go-openapi/jsonreference v0.19.3 // indirect + github.com/go-openapi/spec v0.19.3 // indirect + github.com/go-openapi/swag v0.19.5 // indirect + github.com/gogo/protobuf v1.3.1 // indirect + github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect + github.com/golang/protobuf v1.4.2 // indirect + github.com/google/go-cmp v0.4.0 // indirect + github.com/google/gofuzz v1.1.0 // indirect + github.com/google/uuid v1.1.1 // indirect + github.com/googleapis/gnostic v0.3.1 // indirect + github.com/hashicorp/golang-lru v0.5.1 // indirect + github.com/imdario/mergo v0.3.6 // indirect + github.com/json-iterator/go v1.1.8 // indirect + github.com/mailru/easyjson v0.7.0 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.1 // indirect + github.com/nxadm/tail v1.4.4 // indirect + github.com/pkg/errors v0.8.1 // indirect + github.com/prometheus/client_golang v1.0.0 // indirect + github.com/prometheus/client_model v0.2.0 // indirect + github.com/prometheus/common v0.4.1 // indirect + github.com/prometheus/procfs v0.0.2 // indirect + github.com/spf13/pflag v1.0.5 // indirect + go.uber.org/atomic v1.4.0 // indirect + go.uber.org/multierr v1.1.0 // indirect + go.uber.org/zap v1.10.0 // indirect + golang.org/x/crypto v0.0.0-20200220183623-bac4c82f6975 // indirect + golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7 // indirect + golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45 // indirect + golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 // indirect + golang.org/x/text v0.3.2 // indirect + golang.org/x/time v0.0.0-20190308202827-9d24e82272b4 // indirect + golang.org/x/tools v0.0.0-20190920225731-5eefd052ad72 // indirect + golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 // indirect + gomodules.xyz/jsonpatch/v2 v2.0.1 // indirect + google.golang.org/appengine v1.5.0 // indirect + google.golang.org/protobuf v1.23.0 // indirect + gopkg.in/fsnotify.v1 v1.4.7 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect + gopkg.in/yaml.v2 v2.3.0 // indirect + k8s.io/api v0.18.5 // indirect + k8s.io/apiextensions-apiserver v0.18.2 // indirect + k8s.io/gengo v0.0.0-20200114144118-36b2048a9120 // indirect + k8s.io/klog v1.0.0 // indirect + k8s.io/kube-openapi v0.0.0-20200410145947-61e04a5be9a6 // indirect + k8s.io/utils v0.0.0-20200324210504-a9aa75ae1b89 // indirect + sigs.k8s.io/structured-merge-diff/v3 v3.0.0 // indirect + sigs.k8s.io/yaml v1.2.0 // indirect +) diff --git a/bcs-scenarios/bcs-gitops-manager/.golangci.yml b/bcs-scenarios/bcs-gitops-manager/.golangci.yml new file mode 100644 index 0000000000..cb87018e71 --- /dev/null +++ b/bcs-scenarios/bcs-gitops-manager/.golangci.yml @@ -0,0 +1,121 @@ +run: + timeout: 10m + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-use-default: false +linters: + disable-all: true + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused + - funlen + - gci + - goconst + - gocritic + - gocyclo + - gofmt + - goheader + - goimports + - gosec + - lll + - misspell + - nakedret + - revive + - unconvert + - unparam +linters-settings: + errcheck: + exclude-functions: + - (*os.File).Close + - (io.Closer).Close + - (net/http.ResponseWriter).Write + - github.com/go-chi/render.Render + - io.Copy + - os.RemoveAll + lll: + line-length: 120 + funlen: + lines: 90 + statements: -1 + gocyclo: + min-complexity: 30 + govet: + check-shadowing: true + goimports: + local-prefixes: github.com/Tencent/bk-bcs/bcs-scenarios/bcs-gitops-manager + gci: + sections: + - standard + - default + - prefix(github.com/Tencent/bk-bcs/bcs-scenarios/bcs-gitops-manager) + gocritic: + settings: + ifElseChain: + minThreshold: 3 + gosec: + includes: + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 + goheader: + values: + regexp: + YEAR: 20\d\d + template: |- + * Tencent is pleased to support the open source community by making Blueking Container Service available. + * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * 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. + misspell: + locale: US + revive: + confidence: 0 + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: early-return + - name: error-naming + - name: error-return + - name: error-strings + - name: errorf + - name: exported + - name: increment-decrement + - name: indent-error-flow + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: var-declaration diff --git a/bcs-scenarios/bcs-gitops-manager/handler/cluster.go b/bcs-scenarios/bcs-gitops-manager/handler/cluster.go index 3fb28f982c..94b060c2d1 100644 --- a/bcs-scenarios/bcs-gitops-manager/handler/cluster.go +++ b/bcs-scenarios/bcs-gitops-manager/handler/cluster.go @@ -10,7 +10,6 @@ * limitations under the License. */ -// Package handler xxx package handler import ( diff --git a/bcs-scenarios/bcs-gitops-manager/handler/handler.go b/bcs-scenarios/bcs-gitops-manager/handler/handler.go index 67f410a113..f8334d677c 100644 --- a/bcs-scenarios/bcs-gitops-manager/handler/handler.go +++ b/bcs-scenarios/bcs-gitops-manager/handler/handler.go @@ -10,6 +10,7 @@ * limitations under the License. */ +// Package handler xxx package handler import ( diff --git a/bcs-scenarios/bcs-gitops-manager/pkg/proxy/argocd/analysis.go b/bcs-scenarios/bcs-gitops-manager/pkg/proxy/argocd/analysis.go index 78d48157af..01583a4db9 100644 --- a/bcs-scenarios/bcs-gitops-manager/pkg/proxy/argocd/analysis.go +++ b/bcs-scenarios/bcs-gitops-manager/pkg/proxy/argocd/analysis.go @@ -11,7 +11,6 @@ * */ -// Package argocd xxx package argocd import ( diff --git a/bcs-scenarios/bcs-gitops-manager/pkg/proxy/argocd/argocd.go b/bcs-scenarios/bcs-gitops-manager/pkg/proxy/argocd/argocd.go index 741aa15c40..6bae9e6e35 100644 --- a/bcs-scenarios/bcs-gitops-manager/pkg/proxy/argocd/argocd.go +++ b/bcs-scenarios/bcs-gitops-manager/pkg/proxy/argocd/argocd.go @@ -10,6 +10,7 @@ * limitations under the License. */ +// Package argocd xxx package argocd import ( diff --git a/bcs-scenarios/bcs-gitops-manager/pkg/proxy/argocd/middleware/handler.go b/bcs-scenarios/bcs-gitops-manager/pkg/proxy/argocd/middleware/handler.go index fcc76473b3..160698898d 100644 --- a/bcs-scenarios/bcs-gitops-manager/pkg/proxy/argocd/middleware/handler.go +++ b/bcs-scenarios/bcs-gitops-manager/pkg/proxy/argocd/middleware/handler.go @@ -431,7 +431,8 @@ func (h *handler) CheckCreateApplication(ctx context.Context, app *v1alpha1.Appl for i := range app.Spec.Sources { appSource := app.Spec.Sources[i] repoUrl := appSource.RepoURL - repoBelong, err := h.checkRepositoryBelongProject(ctx, repoUrl, projectName) + var repoBelong bool + repoBelong, err = h.checkRepositoryBelongProject(ctx, repoUrl, projectName) if err != nil { return http.StatusBadRequest, errors.Wrapf(err, "check multi-source repository '%s' permission failed", repoUrl) @@ -445,7 +446,8 @@ func (h *handler) CheckCreateApplication(ctx context.Context, app *v1alpha1.Appl } else { if app.Spec.Source != nil { repoUrl := app.Spec.Source.RepoURL - repoBelong, err := h.checkRepositoryBelongProject(ctx, repoUrl, projectName) + var repoBelong bool + repoBelong, err = h.checkRepositoryBelongProject(ctx, repoUrl, projectName) if err != nil { return http.StatusBadRequest, errors.Wrapf(err, "check repository permission failed") } diff --git a/bcs-scenarios/bcs-gitops-manager/pkg/store/app_history.go b/bcs-scenarios/bcs-gitops-manager/pkg/store/app_history.go index 01891f35de..15331ce452 100644 --- a/bcs-scenarios/bcs-gitops-manager/pkg/store/app_history.go +++ b/bcs-scenarios/bcs-gitops-manager/pkg/store/app_history.go @@ -11,7 +11,6 @@ * */ -// Package store xxx package store import ( diff --git a/bcs-scenarios/bcs-gitops-manager/pkg/store/store.go b/bcs-scenarios/bcs-gitops-manager/pkg/store/store.go index 79ace44644..79edc26a45 100644 --- a/bcs-scenarios/bcs-gitops-manager/pkg/store/store.go +++ b/bcs-scenarios/bcs-gitops-manager/pkg/store/store.go @@ -10,6 +10,7 @@ * limitations under the License. */ +// Package store xxx package store import ( diff --git a/bcs-scenarios/bcs-gitops-vaultplugin-server/.golangci.yml b/bcs-scenarios/bcs-gitops-vaultplugin-server/.golangci.yml new file mode 100644 index 0000000000..38c444cf31 --- /dev/null +++ b/bcs-scenarios/bcs-gitops-vaultplugin-server/.golangci.yml @@ -0,0 +1,121 @@ +run: + timeout: 10m + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-use-default: false +linters: + disable-all: true + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused + - funlen + - gci + - goconst + - gocritic + - gocyclo + - gofmt + - goheader + - goimports + - gosec + - lll + - misspell + - nakedret + - revive + - unconvert + - unparam +linters-settings: + errcheck: + exclude-functions: + - (*os.File).Close + - (io.Closer).Close + - (net/http.ResponseWriter).Write + - github.com/go-chi/render.Render + - io.Copy + - os.RemoveAll + lll: + line-length: 120 + funlen: + lines: 90 + statements: -1 + gocyclo: + min-complexity: 30 + govet: + check-shadowing: true + goimports: + local-prefixes: github.com/Tencent/bk-bcs/bcs-scenarios/bcs-gitops-vaultplugin-server + gci: + sections: + - standard + - default + - prefix(github.com/Tencent/bk-bcs/bcs-scenarios/bcs-gitops-vaultplugin-server) + gocritic: + settings: + ifElseChain: + minThreshold: 3 + gosec: + includes: + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 + goheader: + values: + regexp: + YEAR: 20\d\d + template: |- + * Tencent is pleased to support the open source community by making Blueking Container Service available. + * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * 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. + misspell: + locale: US + revive: + confidence: 0 + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: early-return + - name: error-naming + - name: error-return + - name: error-strings + - name: errorf + - name: exported + - name: increment-decrement + - name: indent-error-flow + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: var-declaration diff --git a/bcs-scenarios/bcs-gitops-vaultplugin-server/go.mod b/bcs-scenarios/bcs-gitops-vaultplugin-server/go.mod index 97a893c16f..92ca54a303 100644 --- a/bcs-scenarios/bcs-gitops-vaultplugin-server/go.mod +++ b/bcs-scenarios/bcs-gitops-vaultplugin-server/go.mod @@ -3,302 +3,302 @@ module github.com/Tencent/bk-bcs/bcs-scenarios/bcs-gitops-vaultplugin-server go 1.19 replace ( - github.com/argoproj/gitops-engine => github.com/argoproj/gitops-engine v0.7.1-0.20230906152414-b0fffe419a0f - github.com/chai2010/gettext-go => github.com/chai2010/gettext-go v0.1.0 + github.com/argoproj/gitops-engine => github.com/argoproj/gitops-engine v0.7.1-0.20230906152414-b0fffe419a0f + github.com/chai2010/gettext-go => github.com/chai2010/gettext-go v0.1.0 - k8s.io/api => k8s.io/api v0.24.2 - k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.24.2 - k8s.io/apimachinery => k8s.io/apimachinery v0.24.2 - k8s.io/apiserver => k8s.io/apiserver v0.24.2 - k8s.io/cli-runtime => k8s.io/cli-runtime v0.24.2 - k8s.io/client-go => k8s.io/client-go v0.24.2 - k8s.io/cloud-provider => k8s.io/cloud-provider v0.24.2 - k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.24.2 - k8s.io/code-generator => k8s.io/code-generator v0.24.2 - k8s.io/component-base => k8s.io/component-base v0.24.2 - k8s.io/component-helpers => k8s.io/component-helpers v0.24.2 - k8s.io/controller-manager => k8s.io/controller-manager v0.24.2 - k8s.io/cri-api => k8s.io/cri-api v0.24.2 - k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.24.2 - k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.24.2 - k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.24.2 - k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20220627174259-011e075b9cb8 - k8s.io/kube-proxy => k8s.io/kube-proxy v0.24.2 - k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.24.2 - k8s.io/kubectl => k8s.io/kubectl v0.24.2 - k8s.io/kubelet => k8s.io/kubelet v0.24.2 - k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.24.2 - k8s.io/metrics => k8s.io/metrics v0.24.2 - k8s.io/mount-utils => k8s.io/mount-utils v0.24.2 - k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.24.2 - k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.24.2 - sigs.k8s.io/kustomize/api => sigs.k8s.io/kustomize/api v0.11.4 - sigs.k8s.io/kustomize/kyaml => sigs.k8s.io/kustomize/kyaml v0.13.6 + k8s.io/api => k8s.io/api v0.24.2 + k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.24.2 + k8s.io/apimachinery => k8s.io/apimachinery v0.24.2 + k8s.io/apiserver => k8s.io/apiserver v0.24.2 + k8s.io/cli-runtime => k8s.io/cli-runtime v0.24.2 + k8s.io/client-go => k8s.io/client-go v0.24.2 + k8s.io/cloud-provider => k8s.io/cloud-provider v0.24.2 + k8s.io/cluster-bootstrap => k8s.io/cluster-bootstrap v0.24.2 + k8s.io/code-generator => k8s.io/code-generator v0.24.2 + k8s.io/component-base => k8s.io/component-base v0.24.2 + k8s.io/component-helpers => k8s.io/component-helpers v0.24.2 + k8s.io/controller-manager => k8s.io/controller-manager v0.24.2 + k8s.io/cri-api => k8s.io/cri-api v0.24.2 + k8s.io/csi-translation-lib => k8s.io/csi-translation-lib v0.24.2 + k8s.io/kube-aggregator => k8s.io/kube-aggregator v0.24.2 + k8s.io/kube-controller-manager => k8s.io/kube-controller-manager v0.24.2 + k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20220627174259-011e075b9cb8 + k8s.io/kube-proxy => k8s.io/kube-proxy v0.24.2 + k8s.io/kube-scheduler => k8s.io/kube-scheduler v0.24.2 + k8s.io/kubectl => k8s.io/kubectl v0.24.2 + k8s.io/kubelet => k8s.io/kubelet v0.24.2 + k8s.io/legacy-cloud-providers => k8s.io/legacy-cloud-providers v0.24.2 + k8s.io/metrics => k8s.io/metrics v0.24.2 + k8s.io/mount-utils => k8s.io/mount-utils v0.24.2 + k8s.io/pod-security-admission => k8s.io/pod-security-admission v0.24.2 + k8s.io/sample-apiserver => k8s.io/sample-apiserver v0.24.2 + sigs.k8s.io/kustomize/api => sigs.k8s.io/kustomize/api v0.11.4 + sigs.k8s.io/kustomize/kyaml => sigs.k8s.io/kustomize/kyaml v0.13.6 ) require ( - github.com/Tencent/bk-bcs/bcs-common v0.0.0-20231124101643-0d25188774c2 - github.com/Tencent/bk-bcs/bcs-common/pkg/otel v0.0.0-20231124101643-0d25188774c2 - github.com/Tencent/bk-bcs/bcs-scenarios/bcs-gitops-manager v0.0.0-20231124101643-0d25188774c2 - github.com/agiledragon/gomonkey/v2 v2.11.0 - github.com/argoproj-labs/argocd-vault-plugin v1.17.0 - github.com/argoproj/argo-cd/v2 v2.9.2 - github.com/avast/retry-go v3.0.0+incompatible - github.com/google/uuid v1.4.0 - github.com/gorilla/mux v1.8.1 - github.com/hashicorp/vault/api v1.10.0 - github.com/pkg/errors v0.9.1 - github.com/prometheus/client_golang v1.17.0 - github.com/spf13/viper v1.17.0 - github.com/stretchr/testify v1.8.4 - k8s.io/api v0.28.3 - k8s.io/apimachinery v0.28.3 - k8s.io/client-go v0.28.3 + github.com/Tencent/bk-bcs/bcs-common v0.0.0-20231124101643-0d25188774c2 + github.com/Tencent/bk-bcs/bcs-common/pkg/otel v0.0.0-20231124101643-0d25188774c2 + github.com/Tencent/bk-bcs/bcs-scenarios/bcs-gitops-manager v0.0.0-20231124101643-0d25188774c2 + github.com/agiledragon/gomonkey/v2 v2.11.0 + github.com/argoproj-labs/argocd-vault-plugin v1.17.0 + github.com/argoproj/argo-cd/v2 v2.9.2 + github.com/avast/retry-go v3.0.0+incompatible + github.com/google/uuid v1.4.0 + github.com/gorilla/mux v1.8.1 + github.com/hashicorp/vault/api v1.10.0 + github.com/pkg/errors v0.9.1 + github.com/prometheus/client_golang v1.17.0 + github.com/spf13/viper v1.17.0 + github.com/stretchr/testify v1.8.4 + k8s.io/api v0.28.3 + k8s.io/apimachinery v0.28.3 + k8s.io/client-go v0.28.3 ) require ( - cloud.google.com/go/compute v1.23.2 // indirect - cloud.google.com/go/compute/metadata v0.2.3 // indirect - cloud.google.com/go/iam v1.1.4 // indirect - cloud.google.com/go/secretmanager v1.11.3 // indirect - dario.cat/mergo v1.0.0 // indirect - filippo.io/age v1.0.0 // indirect - github.com/1Password/connect-sdk-go v1.5.3 // indirect - github.com/Azure/azure-sdk-for-go v68.0.0+incompatible // indirect - github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect - github.com/Azure/go-autorest v14.2.0+incompatible // indirect - github.com/Azure/go-autorest/autorest v0.11.29 // indirect - github.com/Azure/go-autorest/autorest/adal v0.9.23 // indirect - github.com/Azure/go-autorest/autorest/azure/auth v0.5.12 // indirect - github.com/Azure/go-autorest/autorest/azure/cli v0.4.6 // indirect - github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect - github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect - github.com/Azure/go-autorest/autorest/validation v0.3.1 // indirect - github.com/Azure/go-autorest/logger v0.2.1 // indirect - github.com/Azure/go-autorest/tracing v0.6.0 // indirect - github.com/DelineaXPM/tss-sdk-go/v2 v2.0.0 // indirect - github.com/IBM/go-sdk-core/v5 v5.14.1 // indirect - github.com/IBM/secrets-manager-go-sdk v1.2.0 // indirect - github.com/MakeNowJust/heredoc v1.0.0 // indirect - github.com/Masterminds/semver/v3 v3.2.1 // indirect - github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 // indirect - github.com/acomagu/bufpipe v1.0.4 // indirect - github.com/argoproj/gitops-engine v0.7.3 // indirect - github.com/argoproj/pkg v0.13.7-0.20230626144333-d56162821bd1 // indirect - github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect - github.com/aws/aws-sdk-go v1.44.331 // indirect - github.com/aws/aws-sdk-go-v2 v1.21.2 // indirect - github.com/aws/aws-sdk-go-v2/config v1.18.45 // indirect - github.com/aws/aws-sdk-go-v2/credentials v1.13.43 // indirect - github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.13 // indirect - github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.43 // indirect - github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.37 // indirect - github.com/aws/aws-sdk-go-v2/internal/ini v1.3.45 // indirect - github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.37 // indirect - github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.21.5 // indirect - github.com/aws/aws-sdk-go-v2/service/sso v1.15.2 // indirect - github.com/aws/aws-sdk-go-v2/service/ssooidc v1.17.3 // indirect - github.com/aws/aws-sdk-go-v2/service/sts v1.23.2 // indirect - github.com/aws/smithy-go v1.15.0 // indirect - github.com/beorn7/perks v1.0.1 // indirect - github.com/bitly/go-simplejson v0.5.0 // indirect - github.com/blang/semver v3.5.1+incompatible // indirect - github.com/blang/semver/v4 v4.0.0 // indirect - github.com/bmatcuk/doublestar/v4 v4.6.0 // indirect - github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect - github.com/bombsimon/logrusr/v2 v2.0.1 // indirect - github.com/bradleyfalzon/ghinstallation/v2 v2.6.0 // indirect - github.com/cenkalti/backoff/v3 v3.2.2 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect - github.com/chai2010/gettext-go v1.0.2 // indirect - github.com/cloudflare/circl v1.3.3 // indirect - github.com/coreos/go-oidc/v3 v3.6.0 // indirect - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect - github.com/dimchansky/utfbom v1.1.1 // indirect - github.com/docker/distribution v2.8.2+incompatible // indirect - github.com/emicklei/go-restful/v3 v3.11.0 // indirect - github.com/emirpasic/gods v1.18.1 // indirect - github.com/evanphx/json-patch v5.6.0+incompatible // indirect - github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect - github.com/fatih/camelcase v1.0.0 // indirect - github.com/fatih/color v1.15.0 // indirect - github.com/felixge/httpsnoop v1.0.4 // indirect - github.com/fsnotify/fsnotify v1.6.0 // indirect - github.com/fvbommel/sortorder v1.1.0 // indirect - github.com/gabriel-vasile/mimetype v1.4.2 // indirect - github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 // indirect - github.com/go-errors/errors v1.4.2 // indirect - github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect - github.com/go-git/go-billy/v5 v5.4.1 // indirect - github.com/go-git/go-git/v5 v5.8.1 // indirect - github.com/go-jose/go-jose/v3 v3.0.0 // indirect - github.com/go-logr/logr v1.3.0 // indirect - github.com/go-logr/stdr v1.2.2 // indirect - github.com/go-openapi/errors v0.20.3 // indirect - github.com/go-openapi/jsonpointer v0.20.0 // indirect - github.com/go-openapi/jsonreference v0.20.2 // indirect - github.com/go-openapi/strfmt v0.21.7 // indirect - github.com/go-openapi/swag v0.22.4 // indirect - github.com/go-playground/locales v0.14.1 // indirect - github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.14.0 // indirect - github.com/go-redis/cache/v9 v9.0.0 // indirect - github.com/gobwas/glob v0.2.3 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect - github.com/golang/protobuf v1.5.3 // indirect - github.com/google/btree v1.1.2 // indirect - github.com/google/gnostic v0.6.9 // indirect - github.com/google/go-cmp v0.6.0 // indirect - github.com/google/go-github/v53 v53.2.0 // indirect - github.com/google/go-querystring v1.1.0 // indirect - github.com/google/gofuzz v1.2.0 // indirect - github.com/google/s2a-go v0.1.7 // indirect - github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect - github.com/googleapis/enterprise-certificate-proxy v0.3.1 // indirect - github.com/googleapis/gax-go/v2 v2.12.0 // indirect - github.com/goware/prefixer v0.0.0-20160118172347-395022866408 // indirect - github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect - github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect - github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect - github.com/hashicorp/errwrap v1.1.0 // indirect - github.com/hashicorp/go-cleanhttp v0.5.2 // indirect - github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-retryablehttp v0.7.4 // indirect - github.com/hashicorp/go-rootcerts v1.0.2 // indirect - github.com/hashicorp/go-secure-stdlib/parseutil v0.1.7 // indirect - github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect - github.com/hashicorp/go-sockaddr v1.0.4 // indirect - github.com/hashicorp/hcl v1.0.1-vault-5 // indirect - github.com/howeyc/gopass v0.0.0-20210920133722-c8aef6fb66ef // indirect - github.com/imdario/mergo v0.3.16 // indirect - github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/itchyny/gojq v0.12.13 // indirect - github.com/itchyny/timefmt-go v0.1.5 // indirect - github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect - github.com/jmespath/go-jmespath v0.4.0 // indirect - github.com/jonboulle/clockwork v0.2.2 // indirect - github.com/josharian/intern v1.0.0 // indirect - github.com/json-iterator/go v1.1.12 // indirect - github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect - github.com/keeper-security/secrets-manager-go/core v1.6.2 // indirect - github.com/kevinburke/ssh_config v1.2.0 // indirect - github.com/klauspost/compress v1.17.0 // indirect - github.com/leodido/go-urn v1.2.4 // indirect - github.com/lib/pq v1.10.9 // indirect - github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect - github.com/magiconair/properties v1.8.7 // indirect - github.com/mailru/easyjson v0.7.7 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect - github.com/mitchellh/go-homedir v1.1.0 // indirect - github.com/mitchellh/go-wordwrap v1.0.1 // indirect - github.com/mitchellh/mapstructure v1.5.0 // indirect - github.com/moby/spdystream v0.2.0 // indirect - github.com/moby/term v0.5.0 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect - github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/oklog/ulid v1.3.1 // indirect - github.com/opencontainers/go-digest v1.0.0 // indirect - github.com/opencontainers/image-spec v1.1.0-rc4 // indirect - github.com/opencontainers/selinux v1.10.0 // indirect - github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect - github.com/patrickmn/go-cache v2.1.0+incompatible // indirect - github.com/pelletier/go-toml/v2 v2.1.0 // indirect - github.com/peterbourgon/diskv v2.0.1+incompatible // indirect - github.com/pjbgf/sha1cd v0.3.0 // indirect - github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.69.1 // indirect - github.com/prometheus-operator/prometheus-operator/pkg/client v0.69.1 // indirect - github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect - github.com/prometheus/common v0.44.0 // indirect - github.com/prometheus/procfs v0.11.1 // indirect - github.com/r3labs/diff v1.1.0 // indirect - github.com/redis/go-redis/v9 v9.0.5 // indirect - github.com/robfig/cron/v3 v3.0.1 // indirect - github.com/russross/blackfriday v1.6.0 // indirect - github.com/ryanuber/go-glob v1.0.0 // indirect - github.com/sagikazarmark/locafero v0.3.0 // indirect - github.com/sagikazarmark/slog-shim v0.1.0 // indirect - github.com/sergi/go-diff v1.2.0 // indirect - github.com/sirupsen/logrus v1.9.3 // indirect - github.com/skeema/knownhosts v1.2.0 // indirect - github.com/sourcegraph/conc v0.3.0 // indirect - github.com/spf13/afero v1.10.0 // indirect - github.com/spf13/cast v1.5.1 // indirect - github.com/spf13/cobra v1.7.0 // indirect - github.com/spf13/pflag v1.0.5 // indirect - github.com/subosito/gotenv v1.6.0 // indirect - github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect - github.com/uber/jaeger-lib v2.4.1+incompatible // indirect - github.com/ugorji/go/codec v1.2.11 // indirect - github.com/vmihailenco/go-tinylfu v0.2.2 // indirect - github.com/vmihailenco/msgpack/v5 v5.3.4 // indirect - github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect - github.com/xanzy/ssh-agent v0.3.3 // indirect - github.com/xlab/treeprint v1.2.0 // indirect - github.com/yandex-cloud/go-genproto v0.0.0-20231009081144-b948e2f03d1e // indirect - github.com/yandex-cloud/go-sdk v0.0.0-20231009081448-02cddfe74c51 // indirect - go.mongodb.org/mongo-driver v1.12.1 // indirect - go.mozilla.org/gopgagent v0.0.0-20170926210634-4d7ea76ff71a // indirect - go.mozilla.org/sops/v3 v3.7.3 // indirect - go.opencensus.io v0.24.0 // indirect - go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.42.0 // indirect - go.opentelemetry.io/otel v1.20.0 // indirect - go.opentelemetry.io/otel/metric v1.20.0 // indirect - go.opentelemetry.io/otel/trace v1.20.0 // indirect - go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect - go.uber.org/atomic v1.11.0 // indirect - go.uber.org/multierr v1.11.0 // indirect - golang.org/x/crypto v0.14.0 // indirect - golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect - golang.org/x/mod v0.12.0 // indirect - golang.org/x/net v0.17.0 // indirect - golang.org/x/oauth2 v0.13.0 // indirect - golang.org/x/sync v0.3.0 // indirect - golang.org/x/sys v0.13.0 // indirect - golang.org/x/term v0.13.0 // indirect - golang.org/x/text v0.14.0 // indirect - golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.13.0 // indirect - google.golang.org/api v0.143.0 // indirect - google.golang.org/appengine v1.6.8 // indirect - google.golang.org/genproto v0.0.0-20231030173426-d783a09b4405 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // indirect - google.golang.org/grpc v1.59.0 // indirect - google.golang.org/protobuf v1.31.0 // indirect - gopkg.in/inf.v0 v0.9.1 // indirect - gopkg.in/ini.v1 v1.67.0 // indirect - gopkg.in/urfave/cli.v1 v1.20.0 // indirect - gopkg.in/warnings.v0 v0.1.2 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/apiextensions-apiserver v0.28.3 // indirect - k8s.io/apiserver v0.28.3 // indirect - k8s.io/cli-runtime v0.28.3 // indirect - k8s.io/cloud-provider v0.24.2 // indirect - k8s.io/component-base v0.28.3 // indirect - k8s.io/component-helpers v0.28.0 // indirect - k8s.io/cri-api v0.0.0 // indirect - k8s.io/klog/v2 v2.100.1 // indirect - k8s.io/kube-aggregator v0.24.2 // indirect - k8s.io/kube-openapi v0.0.0-20230905202853-d090da108d2f // indirect - k8s.io/kubectl v0.28.0 // indirect - k8s.io/kubernetes v1.24.2 // indirect - k8s.io/mount-utils v0.24.2 // indirect - k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect - oras.land/oras-go/v2 v2.3.0 // indirect - sigs.k8s.io/controller-runtime v0.16.3 // indirect - sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3 // indirect - sigs.k8s.io/kustomize/kyaml v0.14.2 // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect - sigs.k8s.io/yaml v1.3.0 // indirect -) \ No newline at end of file + cloud.google.com/go/compute v1.23.2 // indirect + cloud.google.com/go/compute/metadata v0.2.3 // indirect + cloud.google.com/go/iam v1.1.4 // indirect + cloud.google.com/go/secretmanager v1.11.3 // indirect + dario.cat/mergo v1.0.0 // indirect + filippo.io/age v1.0.0 // indirect + github.com/1Password/connect-sdk-go v1.5.3 // indirect + github.com/Azure/azure-sdk-for-go v68.0.0+incompatible // indirect + github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect + github.com/Azure/go-autorest v14.2.0+incompatible // indirect + github.com/Azure/go-autorest/autorest v0.11.29 // indirect + github.com/Azure/go-autorest/autorest/adal v0.9.23 // indirect + github.com/Azure/go-autorest/autorest/azure/auth v0.5.12 // indirect + github.com/Azure/go-autorest/autorest/azure/cli v0.4.6 // indirect + github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect + github.com/Azure/go-autorest/autorest/to v0.4.0 // indirect + github.com/Azure/go-autorest/autorest/validation v0.3.1 // indirect + github.com/Azure/go-autorest/logger v0.2.1 // indirect + github.com/Azure/go-autorest/tracing v0.6.0 // indirect + github.com/DelineaXPM/tss-sdk-go/v2 v2.0.0 // indirect + github.com/IBM/go-sdk-core/v5 v5.14.1 // indirect + github.com/IBM/secrets-manager-go-sdk v1.2.0 // indirect + github.com/MakeNowJust/heredoc v1.0.0 // indirect + github.com/Masterminds/semver/v3 v3.2.1 // indirect + github.com/Microsoft/go-winio v0.6.1 // indirect + github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 // indirect + github.com/acomagu/bufpipe v1.0.4 // indirect + github.com/argoproj/gitops-engine v0.7.3 // indirect + github.com/argoproj/pkg v0.13.7-0.20230626144333-d56162821bd1 // indirect + github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect + github.com/aws/aws-sdk-go v1.44.331 // indirect + github.com/aws/aws-sdk-go-v2 v1.21.2 // indirect + github.com/aws/aws-sdk-go-v2/config v1.18.45 // indirect + github.com/aws/aws-sdk-go-v2/credentials v1.13.43 // indirect + github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.13 // indirect + github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.43 // indirect + github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.37 // indirect + github.com/aws/aws-sdk-go-v2/internal/ini v1.3.45 // indirect + github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.37 // indirect + github.com/aws/aws-sdk-go-v2/service/secretsmanager v1.21.5 // indirect + github.com/aws/aws-sdk-go-v2/service/sso v1.15.2 // indirect + github.com/aws/aws-sdk-go-v2/service/ssooidc v1.17.3 // indirect + github.com/aws/aws-sdk-go-v2/service/sts v1.23.2 // indirect + github.com/aws/smithy-go v1.15.0 // indirect + github.com/beorn7/perks v1.0.1 // indirect + github.com/bitly/go-simplejson v0.5.0 // indirect + github.com/blang/semver v3.5.1+incompatible // indirect + github.com/blang/semver/v4 v4.0.0 // indirect + github.com/bmatcuk/doublestar/v4 v4.6.0 // indirect + github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect + github.com/bombsimon/logrusr/v2 v2.0.1 // indirect + github.com/bradleyfalzon/ghinstallation/v2 v2.6.0 // indirect + github.com/cenkalti/backoff/v3 v3.2.2 // indirect + github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/chai2010/gettext-go v1.0.2 // indirect + github.com/cloudflare/circl v1.3.3 // indirect + github.com/coreos/go-oidc/v3 v3.6.0 // indirect + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect + github.com/dimchansky/utfbom v1.1.1 // indirect + github.com/docker/distribution v2.8.2+incompatible // indirect + github.com/emicklei/go-restful/v3 v3.11.0 // indirect + github.com/emirpasic/gods v1.18.1 // indirect + github.com/evanphx/json-patch v5.6.0+incompatible // indirect + github.com/exponent-io/jsonpath v0.0.0-20151013193312-d6023ce2651d // indirect + github.com/fatih/camelcase v1.0.0 // indirect + github.com/fatih/color v1.15.0 // indirect + github.com/felixge/httpsnoop v1.0.4 // indirect + github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/fvbommel/sortorder v1.1.0 // indirect + github.com/gabriel-vasile/mimetype v1.4.2 // indirect + github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32 // indirect + github.com/go-errors/errors v1.4.2 // indirect + github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect + github.com/go-git/go-billy/v5 v5.4.1 // indirect + github.com/go-git/go-git/v5 v5.8.1 // indirect + github.com/go-jose/go-jose/v3 v3.0.0 // indirect + github.com/go-logr/logr v1.3.0 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-openapi/errors v0.20.3 // indirect + github.com/go-openapi/jsonpointer v0.20.0 // indirect + github.com/go-openapi/jsonreference v0.20.2 // indirect + github.com/go-openapi/strfmt v0.21.7 // indirect + github.com/go-openapi/swag v0.22.4 // indirect + github.com/go-playground/locales v0.14.1 // indirect + github.com/go-playground/universal-translator v0.18.1 // indirect + github.com/go-playground/validator/v10 v10.14.0 // indirect + github.com/go-redis/cache/v9 v9.0.0 // indirect + github.com/gobwas/glob v0.2.3 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang-jwt/jwt/v4 v4.5.0 // indirect + github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect + github.com/golang/protobuf v1.5.3 // indirect + github.com/google/btree v1.1.2 // indirect + github.com/google/gnostic v0.6.9 // indirect + github.com/google/go-cmp v0.6.0 // indirect + github.com/google/go-github/v53 v53.2.0 // indirect + github.com/google/go-querystring v1.1.0 // indirect + github.com/google/gofuzz v1.2.0 // indirect + github.com/google/s2a-go v0.1.7 // indirect + github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect + github.com/googleapis/enterprise-certificate-proxy v0.3.1 // indirect + github.com/googleapis/gax-go/v2 v2.12.0 // indirect + github.com/goware/prefixer v0.0.0-20160118172347-395022866408 // indirect + github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect + github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 // indirect + github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect + github.com/hashicorp/errwrap v1.1.0 // indirect + github.com/hashicorp/go-cleanhttp v0.5.2 // indirect + github.com/hashicorp/go-multierror v1.1.1 // indirect + github.com/hashicorp/go-retryablehttp v0.7.4 // indirect + github.com/hashicorp/go-rootcerts v1.0.2 // indirect + github.com/hashicorp/go-secure-stdlib/parseutil v0.1.7 // indirect + github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect + github.com/hashicorp/go-sockaddr v1.0.4 // indirect + github.com/hashicorp/hcl v1.0.1-vault-5 // indirect + github.com/howeyc/gopass v0.0.0-20210920133722-c8aef6fb66ef // indirect + github.com/imdario/mergo v0.3.16 // indirect + github.com/inconshreveable/mousetrap v1.1.0 // indirect + github.com/itchyny/gojq v0.12.13 // indirect + github.com/itchyny/timefmt-go v0.1.5 // indirect + github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect + github.com/jmespath/go-jmespath v0.4.0 // indirect + github.com/jonboulle/clockwork v0.2.2 // indirect + github.com/josharian/intern v1.0.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect + github.com/keeper-security/secrets-manager-go/core v1.6.2 // indirect + github.com/kevinburke/ssh_config v1.2.0 // indirect + github.com/klauspost/compress v1.17.0 // indirect + github.com/leodido/go-urn v1.2.4 // indirect + github.com/lib/pq v1.10.9 // indirect + github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect + github.com/magiconair/properties v1.8.7 // indirect + github.com/mailru/easyjson v0.7.7 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.19 // indirect + github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect + github.com/mitchellh/go-homedir v1.1.0 // indirect + github.com/mitchellh/go-wordwrap v1.0.1 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/moby/spdystream v0.2.0 // indirect + github.com/moby/term v0.5.0 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/oklog/ulid v1.3.1 // indirect + github.com/opencontainers/go-digest v1.0.0 // indirect + github.com/opencontainers/image-spec v1.1.0-rc4 // indirect + github.com/opencontainers/selinux v1.10.0 // indirect + github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect + github.com/patrickmn/go-cache v2.1.0+incompatible // indirect + github.com/pelletier/go-toml/v2 v2.1.0 // indirect + github.com/peterbourgon/diskv v2.0.1+incompatible // indirect + github.com/pjbgf/sha1cd v0.3.0 // indirect + github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect + github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring v0.69.1 // indirect + github.com/prometheus-operator/prometheus-operator/pkg/client v0.69.1 // indirect + github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect + github.com/prometheus/common v0.44.0 // indirect + github.com/prometheus/procfs v0.11.1 // indirect + github.com/r3labs/diff v1.1.0 // indirect + github.com/redis/go-redis/v9 v9.0.5 // indirect + github.com/robfig/cron/v3 v3.0.1 // indirect + github.com/russross/blackfriday v1.6.0 // indirect + github.com/ryanuber/go-glob v1.0.0 // indirect + github.com/sagikazarmark/locafero v0.3.0 // indirect + github.com/sagikazarmark/slog-shim v0.1.0 // indirect + github.com/sergi/go-diff v1.2.0 // indirect + github.com/sirupsen/logrus v1.9.3 // indirect + github.com/skeema/knownhosts v1.2.0 // indirect + github.com/sourcegraph/conc v0.3.0 // indirect + github.com/spf13/afero v1.10.0 // indirect + github.com/spf13/cast v1.5.1 // indirect + github.com/spf13/cobra v1.7.0 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/subosito/gotenv v1.6.0 // indirect + github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect + github.com/uber/jaeger-lib v2.4.1+incompatible // indirect + github.com/ugorji/go/codec v1.2.11 // indirect + github.com/vmihailenco/go-tinylfu v0.2.2 // indirect + github.com/vmihailenco/msgpack/v5 v5.3.4 // indirect + github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect + github.com/xanzy/ssh-agent v0.3.3 // indirect + github.com/xlab/treeprint v1.2.0 // indirect + github.com/yandex-cloud/go-genproto v0.0.0-20231009081144-b948e2f03d1e // indirect + github.com/yandex-cloud/go-sdk v0.0.0-20231009081448-02cddfe74c51 // indirect + go.mongodb.org/mongo-driver v1.12.1 // indirect + go.mozilla.org/gopgagent v0.0.0-20170926210634-4d7ea76ff71a // indirect + go.mozilla.org/sops/v3 v3.7.3 // indirect + go.opencensus.io v0.24.0 // indirect + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.42.0 // indirect + go.opentelemetry.io/otel v1.20.0 // indirect + go.opentelemetry.io/otel/metric v1.20.0 // indirect + go.opentelemetry.io/otel/trace v1.20.0 // indirect + go.starlark.net v0.0.0-20230525235612-a134d8f9ddca // indirect + go.uber.org/atomic v1.11.0 // indirect + go.uber.org/multierr v1.11.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect + golang.org/x/mod v0.12.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/oauth2 v0.13.0 // indirect + golang.org/x/sync v0.3.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/term v0.13.0 // indirect + golang.org/x/text v0.14.0 // indirect + golang.org/x/time v0.3.0 // indirect + golang.org/x/tools v0.13.0 // indirect + google.golang.org/api v0.143.0 // indirect + google.golang.org/appengine v1.6.8 // indirect + google.golang.org/genproto v0.0.0-20231030173426-d783a09b4405 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20231030173426-d783a09b4405 // indirect + google.golang.org/grpc v1.59.0 // indirect + google.golang.org/protobuf v1.31.0 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/ini.v1 v1.67.0 // indirect + gopkg.in/urfave/cli.v1 v1.20.0 // indirect + gopkg.in/warnings.v0 v0.1.2 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + k8s.io/apiextensions-apiserver v0.28.3 // indirect + k8s.io/apiserver v0.28.3 // indirect + k8s.io/cli-runtime v0.28.3 // indirect + k8s.io/cloud-provider v0.24.2 // indirect + k8s.io/component-base v0.28.3 // indirect + k8s.io/component-helpers v0.28.0 // indirect + k8s.io/cri-api v0.0.0 // indirect + k8s.io/klog/v2 v2.100.1 // indirect + k8s.io/kube-aggregator v0.24.2 // indirect + k8s.io/kube-openapi v0.0.0-20230905202853-d090da108d2f // indirect + k8s.io/kubectl v0.28.0 // indirect + k8s.io/kubernetes v1.24.2 // indirect + k8s.io/mount-utils v0.24.2 // indirect + k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect + oras.land/oras-go/v2 v2.3.0 // indirect + sigs.k8s.io/controller-runtime v0.16.3 // indirect + sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect + sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3 // indirect + sigs.k8s.io/kustomize/kyaml v0.14.2 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.3.0 // indirect + sigs.k8s.io/yaml v1.3.0 // indirect +) diff --git a/bcs-scenarios/bcs-monitor-controller/.golangci.yml b/bcs-scenarios/bcs-monitor-controller/.golangci.yml new file mode 100644 index 0000000000..ff6a28ca19 --- /dev/null +++ b/bcs-scenarios/bcs-monitor-controller/.golangci.yml @@ -0,0 +1,121 @@ +run: + timeout: 10m + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-use-default: false +linters: + disable-all: true + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused + - funlen + - gci + - goconst + - gocritic + - gocyclo + - gofmt + - goheader + - goimports + - gosec + - lll + - misspell + - nakedret + - revive + - unconvert + - unparam +linters-settings: + errcheck: + exclude-functions: + - (*os.File).Close + - (io.Closer).Close + - (net/http.ResponseWriter).Write + - github.com/go-chi/render.Render + - io.Copy + - os.RemoveAll + lll: + line-length: 120 + funlen: + lines: 90 + statements: -1 + gocyclo: + min-complexity: 30 + govet: + check-shadowing: true + goimports: + local-prefixes: github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-monitor-controller + gci: + sections: + - standard + - default + - prefix(github.com/Tencent/bk-bcs/bcs-runtime/bcs-k8s/bcs-component/bcs-monitor-controller) + gocritic: + settings: + ifElseChain: + minThreshold: 3 + gosec: + includes: + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 + goheader: + values: + regexp: + YEAR: 20\d\d + template: |- + * Tencent is pleased to support the open source community by making Blueking Container Service available. + * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * 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. + misspell: + locale: US + revive: + confidence: 0 + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: early-return + - name: error-naming + - name: error-return + - name: error-strings + - name: errorf + - name: exported + - name: increment-decrement + - name: indent-error-flow + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: var-declaration diff --git a/bcs-scenarios/bcs-monitor-controller/go.mod b/bcs-scenarios/bcs-monitor-controller/go.mod index a8fb06fd70..625d18095d 100644 --- a/bcs-scenarios/bcs-monitor-controller/go.mod +++ b/bcs-scenarios/bcs-monitor-controller/go.mod @@ -39,7 +39,6 @@ require ( github.com/argoproj/argo-cd/v2 v2.9.0 github.com/emicklei/go-restful v2.15.0+incompatible github.com/go-git/go-git/v5 v5.8.1 - github.com/mholt/archiver/v3 v3.5.1 github.com/onsi/ginkgo v1.16.5 github.com/onsi/gomega v1.25.0 github.com/pkg/errors v0.9.1 @@ -66,7 +65,6 @@ require ( github.com/Microsoft/go-winio v0.6.1 // indirect github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 // indirect github.com/acomagu/bufpipe v1.0.4 // indirect - github.com/andybalholm/brotli v1.0.5 // indirect github.com/argoproj/gitops-engine v0.7.1-0.20230906152414-b0fffe419a0f // indirect github.com/argoproj/pkg v0.13.7-0.20230626144333-d56162821bd1 // indirect github.com/beorn7/perks v1.0.1 // indirect @@ -81,7 +79,6 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/docker/distribution v2.8.2+incompatible // indirect - github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect github.com/emicklei/go-restful-openapi v1.4.1 // indirect github.com/emicklei/go-restful/v3 v3.8.0 // indirect github.com/emirpasic/gods v1.18.1 // indirect @@ -105,7 +102,6 @@ require ( github.com/golang-jwt/jwt/v4 v4.5.0 // indirect github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect github.com/golang/protobuf v1.5.3 // indirect - github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.1.2 // indirect github.com/google/gnostic v0.6.9 // indirect github.com/google/go-cmp v0.5.9 // indirect @@ -125,7 +121,6 @@ require ( github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/klauspost/compress v1.16.5 // indirect - github.com/klauspost/pgzip v1.2.6 // indirect github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect @@ -136,13 +131,11 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/nwaples/rardecode v1.1.3 // indirect github.com/nxadm/tail v1.4.8 // indirect github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0-rc4 // indirect github.com/patrickmn/go-cache v2.1.0+incompatible // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect - github.com/pierrec/lz4/v4 v4.1.17 // indirect github.com/pjbgf/sha1cd v0.3.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.3.0 // indirect @@ -158,12 +151,10 @@ require ( github.com/spf13/pflag v1.0.5 // indirect github.com/stretchr/testify v1.8.4 // indirect github.com/ugorji/go/codec v1.2.3 // indirect - github.com/ulikunitz/xz v0.5.11 // indirect github.com/vmihailenco/go-tinylfu v0.2.2 // indirect github.com/vmihailenco/msgpack/v5 v5.3.4 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect github.com/xanzy/ssh-agent v0.3.3 // indirect - github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect github.com/xlab/treeprint v1.1.0 // indirect go.starlark.net v0.0.0-20220328144851-d1966c6b9fcd // indirect go.uber.org/atomic v1.7.0 // indirect diff --git a/bcs-scenarios/bcs-monitor-controller/pkg/httpsvr/httpserver.go b/bcs-scenarios/bcs-monitor-controller/pkg/httpsvr/httpserver.go index 806199ee71..16c7beeb26 100644 --- a/bcs-scenarios/bcs-monitor-controller/pkg/httpsvr/httpserver.go +++ b/bcs-scenarios/bcs-monitor-controller/pkg/httpsvr/httpserver.go @@ -69,6 +69,7 @@ func (h *HttpServerClient) ListAppMonitors(request *restful.Request, response *r Status string `json:"status"` Message string `json:"message"` } + // Resp response type Resp struct { InstallScenario []InstalledScenarioInfo `json:"install_scenario"` } diff --git a/bcs-scenarios/bcs-monitor-controller/pkg/repo/git_repo.go b/bcs-scenarios/bcs-monitor-controller/pkg/repo/git_repo.go index 2df4cb74dc..806d96e07c 100644 --- a/bcs-scenarios/bcs-monitor-controller/pkg/repo/git_repo.go +++ b/bcs-scenarios/bcs-monitor-controller/pkg/repo/git_repo.go @@ -48,12 +48,12 @@ type gitRepo struct { auth *http.BasicAuth } -// todo 适配ssh -// todo 测试同repo 不同targetRevision -func newGitRepo(URL, username, password, targetRevision, bathPath string) (*gitRepo, error) { - repoKey := genRepoKey(URL, targetRevision) +// doto 适配ssh +// doto 测试同repo 不同targetRevision +func newGitRepo(url, username, password, targetRevision, bathPath string) (*gitRepo, error) { + repoKey := genRepoKey(url, targetRevision) repo := &gitRepo{ - URL: URL, + URL: url, Directory: filepath.Join(bathPath, base64.URLEncoding.EncodeToString([]byte(repoKey))), Username: username, Password: password, diff --git a/bcs-scenarios/bcs-terraform-controller/.golangci.yml b/bcs-scenarios/bcs-terraform-controller/.golangci.yml new file mode 100644 index 0000000000..18c4b2ab03 --- /dev/null +++ b/bcs-scenarios/bcs-terraform-controller/.golangci.yml @@ -0,0 +1,121 @@ +run: + timeout: 10m + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-use-default: false +linters: + disable-all: true + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused + - funlen + - gci + - goconst + - gocritic + - gocyclo + - gofmt + - goheader + - goimports + - gosec + - lll + - misspell + - nakedret + - revive + - unconvert + - unparam +linters-settings: + errcheck: + exclude-functions: + - (*os.File).Close + - (io.Closer).Close + - (net/http.ResponseWriter).Write + - github.com/go-chi/render.Render + - io.Copy + - os.RemoveAll + lll: + line-length: 120 + funlen: + lines: 90 + statements: -1 + gocyclo: + min-complexity: 30 + govet: + check-shadowing: true + goimports: + local-prefixes: github.com/Tencent/bk-bcs/bcs-scenarios/bcs-terraform-controller + gci: + sections: + - standard + - default + - prefix(github.com/Tencent/bk-bcs/bcs-scenarios/bcs-terraform-controller) + gocritic: + settings: + ifElseChain: + minThreshold: 3 + gosec: + includes: + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 + goheader: + values: + regexp: + YEAR: 20\d\d + template: |- + * Tencent is pleased to support the open source community by making Blueking Container Service available. + * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * 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. + misspell: + locale: US + revive: + confidence: 0 + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: early-return + - name: error-naming + - name: error-return + - name: error-strings + - name: errorf + - name: exported + - name: increment-decrement + - name: indent-error-flow + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: var-declaration diff --git a/bcs-scenarios/bcs-terraform-controller/go.mod b/bcs-scenarios/bcs-terraform-controller/go.mod index 93df1a08ad..1d397d7d8d 100644 --- a/bcs-scenarios/bcs-terraform-controller/go.mod +++ b/bcs-scenarios/bcs-terraform-controller/go.mod @@ -44,10 +44,12 @@ require ( github.com/gin-gonic/gin v1.9.0 github.com/go-git/go-git/v5 v5.9.0 github.com/google/uuid v1.3.1 + github.com/hashicorp/hcl/v2 v2.19.1 github.com/hashicorp/terraform-exec v0.19.0 github.com/onsi/ginkgo v1.16.5 github.com/onsi/gomega v1.27.10 github.com/pkg/errors v0.9.1 + github.com/spf13/afero v1.9.2 k8s.io/api v0.27.2 k8s.io/apimachinery v0.27.2 k8s.io/client-go v0.27.2 @@ -142,7 +144,6 @@ require ( github.com/hashicorp/go-sockaddr v1.0.2 // indirect github.com/hashicorp/go-version v1.6.0 // indirect github.com/hashicorp/hcl v1.0.1-vault-3 // indirect - github.com/hashicorp/hcl/v2 v2.19.1 // indirect github.com/hashicorp/terraform-json v0.17.1 // indirect github.com/hashicorp/vault/api v1.9.2 // indirect github.com/imdario/mergo v0.3.16 // indirect diff --git a/bcs-scenarios/bcs-terraform-controller/pkg/server/server.go b/bcs-scenarios/bcs-terraform-controller/pkg/server/server.go index 88aa3cb0f9..e1054a4a96 100644 --- a/bcs-scenarios/bcs-terraform-controller/pkg/server/server.go +++ b/bcs-scenarios/bcs-terraform-controller/pkg/server/server.go @@ -11,12 +11,14 @@ * */ +// Package server implements a http server for bcs-terraform-controller package server import ( - "github.com/gin-gonic/gin" "net" "net/http" + + "github.com/gin-gonic/gin" "sigs.k8s.io/controller-runtime/pkg/client" "github.com/Tencent/bk-bcs/bcs-common/common/blog" diff --git a/bcs-services/bcs-argocd-manager/.golangci.yml b/bcs-services/bcs-argocd-manager/.golangci.yml deleted file mode 100644 index 1717788fc4..0000000000 --- a/bcs-services/bcs-argocd-manager/.golangci.yml +++ /dev/null @@ -1,117 +0,0 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - -run: - timeout: 10m - -issues: - # 显示所有 issue - max-issues-per-linter: 0 - max-same-issues: 0 - exclude-use-default: false - -linters: - disable-all: true - enable: - # enable by default - - errcheck - - gosimple - - govet - - ineffassign - - staticcheck - - unused - - # custom - - funlen - - gci - - goconst - - gocritic - - gocyclo - - gofmt - - goheader - - goimports - - gosec - - lll - - misspell - - nakedret - - revive - - unconvert - - unparam - -linters-settings: - # 只开启特定的规则 - errcheck: - exclude-functions: - - (*os.File).Close - - (io.Closer).Close - - (net/http.ResponseWriter).Write - - github.com/go-chi/render.Render - - io.Copy - - os.RemoveAll - lll: - line-length: 120 # widely used and popular community recommended length - funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 - gocyclo: - min-complexity: 30 # 函数圈复杂度 - govet: - check-shadowing: true - goimports: - local-prefixes: github.com/Tencent/bk-bcs/bcs-services/bcs-argocd-manager - gci: - sections: - - standard - - default - - prefix(github.com/Tencent/bk-bcs/bcs-services/bcs-argocd-manager) - gocritic: - settings: - ifElseChain: - minThreshold: 3 - gosec: - includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi - goheader: - values: - regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 - template: |- - * Tencent is pleased to support the open source community by making Blueking Container Service available. - * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. - * Licensed under the MIT License (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * http://opensource.org/licenses/MIT - * 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. - misspell: - locale: US - revive: - confidence: 0 - rules: - - name: blank-imports - - name: context-as-argument - - name: context-keys-type - - name: dot-imports - - name: early-return - - name: error-naming - - name: error-return - - name: error-strings - - name: errorf - - name: exported - - name: increment-decrement - - name: indent-error-flow - - name: package-comments - - name: range - - name: receiver-naming - - name: time-naming - # - name: unexported-return - - name: var-declaration - # - name: var-naming diff --git a/bcs-services/bcs-bkcmdb-synchronizer/.golangci.yml b/bcs-services/bcs-bkcmdb-synchronizer/.golangci.yml new file mode 100644 index 0000000000..2b3638d5a6 --- /dev/null +++ b/bcs-services/bcs-bkcmdb-synchronizer/.golangci.yml @@ -0,0 +1,121 @@ +run: + timeout: 10m + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-use-default: false +linters: + disable-all: true + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused + - funlen + - gci + - goconst + - gocritic + - gocyclo + - gofmt + - goheader + - goimports + - gosec + - lll + - misspell + - nakedret + - revive + - unconvert + - unparam +linters-settings: + errcheck: + exclude-functions: + - (*os.File).Close + - (io.Closer).Close + - (net/http.ResponseWriter).Write + - github.com/go-chi/render.Render + - io.Copy + - os.RemoveAll + lll: + line-length: 120 + funlen: + lines: 90 + statements: -1 + gocyclo: + min-complexity: 30 + govet: + check-shadowing: true + goimports: + local-prefixes: github.com/Tencent/bk-bcs/bcs-services/bcs-bkcmdb-synchronizer + gci: + sections: + - standard + - default + - prefix(github.com/Tencent/bk-bcs/bcs-services/bcs-bkcmdb-synchronizer) + gocritic: + settings: + ifElseChain: + minThreshold: 3 + gosec: + includes: + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 + goheader: + values: + regexp: + YEAR: 20\d\d + template: |- + * Tencent is pleased to support the open source community by making Blueking Container Service available. + * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * 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. + misspell: + locale: US + revive: + confidence: 0 + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: early-return + - name: error-naming + - name: error-return + - name: error-strings + - name: errorf + - name: exported + - name: increment-decrement + - name: indent-error-flow + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: var-declaration diff --git a/bcs-services/bcs-bkcmdb-synchronizer/go.mod b/bcs-services/bcs-bkcmdb-synchronizer/go.mod index 69ff6d8cbf..6771d3bad1 100644 --- a/bcs-services/bcs-bkcmdb-synchronizer/go.mod +++ b/bcs-services/bcs-bkcmdb-synchronizer/go.mod @@ -23,7 +23,7 @@ require ( github.com/parnurzeal/gorequest v0.2.16 github.com/patrickmn/go-cache v2.1.0+incompatible github.com/rabbitmq/amqp091-go v1.5.0 - google.golang.org/grpc v1.46.0 + google.golang.org/grpc v1.51.0 k8s.io/api v0.24.2 ) @@ -42,9 +42,10 @@ require ( github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f // indirect github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect github.com/davecgh/go-spew v1.1.1 // indirect + github.com/elazarl/goproxy v0.0.0-20210110162100-a92cc753f88e // indirect github.com/emicklei/go-restful v2.15.0+incompatible // indirect github.com/emicklei/go-restful/v3 v3.7.4 // indirect - github.com/envoyproxy/protoc-gen-validate v0.1.0 // indirect + github.com/envoyproxy/protoc-gen-validate v0.6.13 // indirect github.com/fsnotify/fsnotify v1.5.4 // indirect github.com/ghodss/yaml v1.0.0 // indirect github.com/gin-contrib/sse v0.1.0 // indirect @@ -73,7 +74,7 @@ require ( github.com/leodido/go-urn v1.2.2 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattbaird/jsonpatch v0.0.0-20200820163806-098863c1fc24 // indirect - github.com/mattn/go-isatty v0.0.14 // indirect + github.com/mattn/go-isatty v0.0.16 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/miekg/dns v1.1.50 // indirect github.com/mitchellh/hashstructure v1.1.0 // indirect @@ -87,8 +88,10 @@ require ( github.com/prometheus/client_model v0.3.0 // indirect github.com/prometheus/common v0.41.0 // indirect github.com/prometheus/procfs v0.9.0 // indirect + github.com/rogpeppe/go-internal v1.9.0 // indirect github.com/rs/xid v1.4.0 // indirect github.com/samuel/go-zookeeper v0.0.0-20201211165307-7117e9ea2414 // indirect + github.com/smartystreets/goconvey v1.7.2 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/tidwall/gjson v1.14.1 // indirect github.com/tidwall/match v1.1.1 // indirect @@ -99,16 +102,16 @@ require ( go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.17.0 // indirect golang.org/x/crypto v0.7.0 // indirect - golang.org/x/mod v0.8.0 // indirect + golang.org/x/mod v0.10.0 // indirect golang.org/x/net v0.10.0 // indirect golang.org/x/oauth2 v0.5.0 // indirect golang.org/x/sys v0.8.0 // indirect golang.org/x/term v0.8.0 // indirect golang.org/x/text v0.9.0 // indirect - golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect - golang.org/x/tools v0.6.0 // indirect + golang.org/x/time v0.1.0 // indirect + golang.org/x/tools v0.9.1 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac // indirect + google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect google.golang.org/protobuf v1.28.1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect diff --git a/bcs-services/bcs-bkcmdb-synchronizer/internal/pkg/handler/handler.go b/bcs-services/bcs-bkcmdb-synchronizer/internal/pkg/handler/handler.go index 2c630333ec..dc31ced368 100644 --- a/bcs-services/bcs-bkcmdb-synchronizer/internal/pkg/handler/handler.go +++ b/bcs-services/bcs-bkcmdb-synchronizer/internal/pkg/handler/handler.go @@ -11,6 +11,7 @@ */ // Package handler define methods for handling mq event +// NOCC:tosa/comment_ratio(ignore),gofmt/notformat(ignore) package handler import ( @@ -23,6 +24,7 @@ import ( "time" bkcmdbkube "configcenter/src/kube/types" + "github.com/Tencent/bk-bcs/bcs-common/common/blog" pmp "github.com/Tencent/bk-bcs/bcs-common/pkg/bcsapi/bcsproject" cmp "github.com/Tencent/bk-bcs/bcs-common/pkg/bcsapi/clustermanager" @@ -91,6 +93,7 @@ func (b *BcsBkcmdbSynchronizerHandler) HandleMsg(chn *amqp.Channel, messages <-c header := msg.Headers + // handle header if v, ok := header["resourceType"]; ok { blog.Infof("resourceType: %v", v) switch v.(string) { @@ -113,6 +116,7 @@ func (b *BcsBkcmdbSynchronizerHandler) HandleMsg(chn *amqp.Channel, messages <-c } } + // ack if err := msg.Ack(false); err != nil { blog.Infof("Unable to acknowledge the message, err: %s", err.Error()) } @@ -132,6 +136,7 @@ func (b *BcsBkcmdbSynchronizerHandler) handleCluster(msg amqp.Delivery) error { return err } + // get cluster manager grpc gw client cmCli, err := b.getClusterManagerGrpcGwClient() if err != nil { blog.Errorf("get cluster manager grpc gw client failed, err: %s", err.Error()) @@ -142,6 +147,7 @@ func (b *BcsBkcmdbSynchronizerHandler) handleCluster(msg amqp.Delivery) error { ClusterID: msgHeader.ClusterId, } + // list cluster resp, err := cmCli.Cli.ListCluster(cmCli.Ctx, &lcReq) if err != nil { blog.Errorf("list cluster failed, err: %s", err.Error()) @@ -163,9 +169,11 @@ func (b *BcsBkcmdbSynchronizerHandler) handleCluster(msg amqp.Delivery) error { blackList = strings.Split(b.Syncer.BkcmdbSynchronizerOption.Synchronizer.BlackList, ",") } + // white list blog.Infof("whiteList: %v, len: ", whiteList, len(whiteList)) blog.Infof("blackList: %v, len: ", blackList, len(blackList)) + // loop clusters for _, cluster := range clusters { blog.Infof("1cluster: %s", cluster.ClusterID) if len(whiteList) > 0 { @@ -183,6 +191,7 @@ func (b *BcsBkcmdbSynchronizerHandler) handleCluster(msg amqp.Delivery) error { blog.Infof("3cluster: %s", cluster.ClusterID) + // virtual cluster if cluster.ClusterType == "virtual" { continue } @@ -199,6 +208,7 @@ func (b *BcsBkcmdbSynchronizerHandler) handleCluster(msg amqp.Delivery) error { } + // get bk cluster bkCluster, err := b.Syncer.GetBkCluster(clusterMap[msgHeader.ClusterId]) if err != nil { blog.Errorf("handleCluster: Unable to get bkcluster, err: %s", err.Error()) @@ -210,6 +220,7 @@ func (b *BcsBkcmdbSynchronizerHandler) handleCluster(msg amqp.Delivery) error { return nil } +// handle pod func (b *BcsBkcmdbSynchronizerHandler) handlePod(msg amqp.Delivery) { blog.Infof("handlePod Message: %v", msg.Headers) msgHeader, err := getMsgHeader(&msg.Headers) @@ -226,6 +237,7 @@ func (b *BcsBkcmdbSynchronizerHandler) handlePod(msg amqp.Delivery) { return } + // handle event switch msgHeader.Event { case "update": // nolint err = b.handlePodUpdate(pod) @@ -242,6 +254,7 @@ func (b *BcsBkcmdbSynchronizerHandler) handlePod(msg amqp.Delivery) { } } +// handle pod update func (b *BcsBkcmdbSynchronizerHandler) handlePodUpdate(pod *corev1.Pod) error { bkPods, err := b.Syncer.GetBkPods(b.BkCluster.BizID, &client.PropertyFilter{ Condition: "AND", @@ -271,6 +284,7 @@ func (b *BcsBkcmdbSynchronizerHandler) handlePodUpdate(pod *corev1.Pod) error { return fmt.Errorf("len(bkPods) = %d", len(*bkPods)) } + // handle pod create if len(*bkPods) == 0 { err := b.handlePodCreate(pod) if err != nil { @@ -282,6 +296,7 @@ func (b *BcsBkcmdbSynchronizerHandler) handlePodUpdate(pod *corev1.Pod) error { return nil } +// handle pod delete func (b *BcsBkcmdbSynchronizerHandler) handlePodDelete(pod *corev1.Pod) error { bkPods, err := b.Syncer.GetBkPods(b.BkCluster.BizID, &client.PropertyFilter{ Condition: "AND", @@ -330,6 +345,7 @@ func (b *BcsBkcmdbSynchronizerHandler) handlePodDelete(pod *corev1.Pod) error { return err } +// handle pod create func (b *BcsBkcmdbSynchronizerHandler) handlePodCreate(pod *corev1.Pod) error { var operator []string cmCli, err := b.getClusterManagerGrpcGwClient() diff --git a/bcs-services/bcs-bkcmdb-synchronizer/internal/pkg/syncer/syncer.go b/bcs-services/bcs-bkcmdb-synchronizer/internal/pkg/syncer/syncer.go index 70e1faf13b..05c023df66 100644 --- a/bcs-services/bcs-bkcmdb-synchronizer/internal/pkg/syncer/syncer.go +++ b/bcs-services/bcs-bkcmdb-synchronizer/internal/pkg/syncer/syncer.go @@ -11,6 +11,7 @@ */ // Package syncer define syncer methods +// NOCC:tosa/comment_ratio(ignore),gofmt/notformat(ignore) package syncer import ( @@ -21,6 +22,7 @@ import ( "strconv" bkcmdbkube "configcenter/src/kube/types" + "github.com/Tencent/bk-bcs/bcs-common/common/blog" "github.com/Tencent/bk-bcs/bcs-common/common/ssl" "github.com/Tencent/bk-bcs/bcs-common/pkg/bcsapi" @@ -2856,6 +2858,7 @@ func (s *Syncer) CompareGameDeployment(bkGameDeployment *bkcmdbkube.GameDeployme needToUpdate = true } + // NOCC:ineffassign/assign(ignore) rud := bkcmdbkube.RollingUpdateGameDeployment{} if k8sGameDeployment.Data.Spec.UpdateStrategy.MaxUnavailable != nil && k8sGameDeployment.Data.Spec.UpdateStrategy.MaxSurge != nil { @@ -3008,6 +3011,7 @@ func (s *Syncer) CompareGameStatefulSet(bkGameStatefulSet *bkcmdbkube.GameStatef needToUpdate = true } + // NOCC:ineffassign/assign(ignore) rus := bkcmdbkube.RollingUpdateGameStatefulSetStrategy{} if k8sGameStatefulSet.Data.Spec.UpdateStrategy.RollingUpdate != nil { diff --git a/bcs-services/bcs-bscp/.golangci.yml b/bcs-services/bcs-bscp/.golangci.yml index b6c06b807f..6e5b5137ec 100644 --- a/bcs-services/bcs-bscp/.golangci.yml +++ b/bcs-services/bcs-bscp/.golangci.yml @@ -1,26 +1,39 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ + - cmd/data-service/service/config_item.go + - cmd/data-service/service/group.go + - test/benchmark/run/template.go + - test/mock/repo/service/node.go + - pkg/version/version.go issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +49,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +59,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +80,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +123,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-services/bcs-bscp/cmd/api-server/service/kv.go b/bcs-services/bcs-bscp/cmd/api-server/service/kv.go index 094aa0b92d..62fa537a89 100644 --- a/bcs-services/bcs-bscp/cmd/api-server/service/kv.go +++ b/bcs-services/bcs-bscp/cmd/api-server/service/kv.go @@ -176,11 +176,13 @@ func validateKvType(kvType string) error { } // 读取json文件 +// NOCC:golint/noptr(误报) func readJSONFile(bytes []byte, result *map[string]interface{}) bool { return !json.Valid(bytes) && json.Unmarshal(bytes, &result) == nil } // 读取yaml文件 +// NOCC:golint/noptr(误报) func readYAMLFile(bytes []byte, result *map[string]interface{}) bool { return yaml.Unmarshal(bytes, &result) == nil } diff --git a/bcs-services/bcs-bscp/cmd/vault-server/service/gateway.go b/bcs-services/bcs-bscp/cmd/vault-server/service/gateway.go index 96bf895a23..f9142d5537 100644 --- a/bcs-services/bcs-bscp/cmd/vault-server/service/gateway.go +++ b/bcs-services/bcs-bscp/cmd/vault-server/service/gateway.go @@ -10,7 +10,6 @@ * limitations under the License. */ -// Package service provides the functionality for the service layer package service import ( diff --git a/bcs-services/bcs-bscp/cmd/vault-server/service/service.go b/bcs-services/bcs-bscp/cmd/vault-server/service/service.go index 2a63cba7c3..45b3436d42 100644 --- a/bcs-services/bcs-bscp/cmd/vault-server/service/service.go +++ b/bcs-services/bcs-bscp/cmd/vault-server/service/service.go @@ -10,6 +10,7 @@ * limitations under the License. */ +// Package service provides the functionality for the service layer package service import ( diff --git a/bcs-services/bcs-bscp/cmd/vault-server/vault-sidecar/init.go b/bcs-services/bcs-bscp/cmd/vault-server/vault-sidecar/init.go index 5ad00071ef..c0fd54df8f 100644 --- a/bcs-services/bcs-bscp/cmd/vault-server/vault-sidecar/init.go +++ b/bcs-services/bcs-bscp/cmd/vault-server/vault-sidecar/init.go @@ -31,6 +31,7 @@ const ( ) // #nosec G101 +// NOCC:tosa/indent(ignore) var secretTmpl = `global: vault: unsealKeys: diff --git a/bcs-services/bcs-bscp/cmd/vault-server/vault/.golangci.yml b/bcs-services/bcs-bscp/cmd/vault-server/vault/.golangci.yml index 892c126317..7bfd304a2f 100644 --- a/bcs-services/bcs-bscp/cmd/vault-server/vault/.golangci.yml +++ b/bcs-services/bcs-bscp/cmd/vault-server/vault/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +54,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +75,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-services/bcs-bscp/pkg/audit/routematch/matcher.go b/bcs-services/bcs-bscp/pkg/audit/routematch/matcher.go index 3dd9ba77c6..24a6ecfc1e 100644 --- a/bcs-services/bcs-bscp/pkg/audit/routematch/matcher.go +++ b/bcs-services/bcs-bscp/pkg/audit/routematch/matcher.go @@ -72,6 +72,7 @@ func (m *RouteMatcher) Match(method, path string) (string, error) { for _, pattern := range patterns { // 使用正则表达式查找匹配 + // NOCC:gas/error(忽略) match, _ := regexp.MatchString("^(/bscp)?"+pattern+"/?$", path) // 如果找到匹配并且比当前最长匹配更长,则更新最长匹配 diff --git a/bcs-services/bcs-bscp/pkg/components/bkpaas/auth.go b/bcs-services/bcs-bscp/pkg/components/bkpaas/auth.go index 1cb165b373..484d614688 100644 --- a/bcs-services/bcs-bscp/pkg/components/bkpaas/auth.go +++ b/bcs-services/bcs-bscp/pkg/components/bkpaas/auth.go @@ -10,7 +10,6 @@ * limitations under the License. */ -// Package bkpaas provides bkpaas auth client. package bkpaas import ( diff --git a/bcs-services/bcs-bscp/pkg/components/bkpaas/bkpaas.go b/bcs-services/bcs-bscp/pkg/components/bkpaas/bkpaas.go index 9ae18680cf..e6f430b3e9 100644 --- a/bcs-services/bcs-bscp/pkg/components/bkpaas/bkpaas.go +++ b/bcs-services/bcs-bscp/pkg/components/bkpaas/bkpaas.go @@ -10,6 +10,7 @@ * limitations under the License. */ +// Package bkpaas provides bkpaas auth client. package bkpaas import ( diff --git a/bcs-services/bcs-bscp/pkg/dal/repository/bkrepo.go b/bcs-services/bcs-bscp/pkg/dal/repository/bkrepo.go index fa805b9f67..1954283eee 100644 --- a/bcs-services/bcs-bscp/pkg/dal/repository/bkrepo.go +++ b/bcs-services/bcs-bscp/pkg/dal/repository/bkrepo.go @@ -10,7 +10,6 @@ * limitations under the License. */ -// Package repository is interface and its implementation for different repositories package repository import ( diff --git a/bcs-services/bcs-bscp/pkg/dal/repository/repository.go b/bcs-services/bcs-bscp/pkg/dal/repository/repository.go index 15f14f9074..5b34fd9df7 100644 --- a/bcs-services/bcs-bscp/pkg/dal/repository/repository.go +++ b/bcs-services/bcs-bscp/pkg/dal/repository/repository.go @@ -10,6 +10,7 @@ * limitations under the License. */ +// Package repository is interface and its implementation for different repositories package repository import ( diff --git a/bcs-services/bcs-bscp/pkg/protocol/auth-server/convert.go b/bcs-services/bcs-bscp/pkg/protocol/auth-server/convert.go index 676ac43e0d..3c359c25be 100644 --- a/bcs-services/bcs-bscp/pkg/protocol/auth-server/convert.go +++ b/bcs-services/bcs-bscp/pkg/protocol/auth-server/convert.go @@ -381,7 +381,7 @@ func GrantResourceCreatorActionAncetors(ancetors []*GrantResourceCreatorActionRe // to client GrantResourceCreatorActionAncestor // //nolint:lll -func GrantResourceCreatorActionAncetor(ancetor *GrantResourceCreatorActionReq_Ancestor) client.GrantResourceCreatorActionAncestor { +func GrantResourceCreatorActionAncetor(ancetor *GrantResourceCreatorActionReq_Ancestor) client.GrantResourceCreatorActionAncestor { // NOCC:tosa/fn_length(ignore) return client.GrantResourceCreatorActionAncestor{ System: ancetor.System, Type: client.TypeID(ancetor.Type), @@ -393,7 +393,7 @@ func GrantResourceCreatorActionAncetor(ancetor *GrantResourceCreatorActionReq_An // to pb GrantResourceCreatorActionReq_Ancestor // //nolint:lll -func PbGrantResourceCreatorActionAncestor(ancetor client.GrantResourceCreatorActionAncestor) *GrantResourceCreatorActionReq_Ancestor { +func PbGrantResourceCreatorActionAncestor(ancetor client.GrantResourceCreatorActionAncestor) *GrantResourceCreatorActionReq_Ancestor { // NOCC:tosa/fn_length(ignore) return &GrantResourceCreatorActionReq_Ancestor{ System: ancetor.System, Type: string(ancetor.Type), @@ -405,7 +405,7 @@ func PbGrantResourceCreatorActionAncestor(ancetor client.GrantResourceCreatorAct // to pb GrantResourceCreatorActionReq_Ancestor array // //nolint:lll -func PbGrantResourceCreatorActionAncestors(ancetors []client.GrantResourceCreatorActionAncestor) []*GrantResourceCreatorActionReq_Ancestor { +func PbGrantResourceCreatorActionAncestors(ancetors []client.GrantResourceCreatorActionAncestor) []*GrantResourceCreatorActionReq_Ancestor { // NOCC:tosa/fn_length(ignore) result := make([]*GrantResourceCreatorActionReq_Ancestor, len(ancetors)) if len(ancetors) == 0 { diff --git a/bcs-services/bcs-bscp/pkg/runtime/archive/tgz.go b/bcs-services/bcs-bscp/pkg/runtime/archive/tgz.go index 8a6cb2e901..9f310f2918 100644 --- a/bcs-services/bcs-bscp/pkg/runtime/archive/tgz.go +++ b/bcs-services/bcs-bscp/pkg/runtime/archive/tgz.go @@ -65,6 +65,7 @@ func (t *TgzHandler) UnTar(r io.Reader, destPath string) error { func (t *TgzHandler) unTarFile(hdr *tar.Header, tr *tar.Reader, fp string) error { parentDir, _ := filepath.Split(fp) + // NOCC:gas/permission(ignore) if err := os.MkdirAll(parentDir, 0o740); err != nil { return err } diff --git a/bcs-services/bcs-bscp/pkg/runtime/archive/zip.go b/bcs-services/bcs-bscp/pkg/runtime/archive/zip.go index 6cea5389c5..ff2e71d48c 100644 --- a/bcs-services/bcs-bscp/pkg/runtime/archive/zip.go +++ b/bcs-services/bcs-bscp/pkg/runtime/archive/zip.go @@ -82,6 +82,7 @@ func (z *ZipHandler) unzipFile(f *zip.File, destPath string) error { return err } defer func() { + // NOCC:gas/error(ignore) _ = rc.Close() }() diff --git a/bcs-services/bcs-bscp/pkg/runtime/selector/label_test.go b/bcs-services/bcs-bscp/pkg/runtime/selector/label_test.go index 077251d240..e1ee45e9a1 100644 --- a/bcs-services/bcs-bscp/pkg/runtime/selector/label_test.go +++ b/bcs-services/bcs-bscp/pkg/runtime/selector/label_test.go @@ -164,6 +164,7 @@ func TestUnmarshalGreaterThanElement(t *testing.T) { } // nolint +// NOCC:tosa/fn_length(ignore) func TestUnmarshalGreaterThanEqualElement(t *testing.T) { const geJSON = ` diff --git a/bcs-services/bcs-bscp/pkg/tools/algorithm.go b/bcs-services/bcs-bscp/pkg/tools/algorithm.go index 9a1920a7d3..d650c5101c 100644 --- a/bcs-services/bcs-bscp/pkg/tools/algorithm.go +++ b/bcs-services/bcs-bscp/pkg/tools/algorithm.go @@ -10,7 +10,6 @@ * limitations under the License. */ -// Package tools provides bscp common tools. package tools import ( diff --git a/bcs-services/bcs-bscp/pkg/tools/tools.go b/bcs-services/bcs-bscp/pkg/tools/tools.go index 0d1101e1af..07cf0182f7 100644 --- a/bcs-services/bcs-bscp/pkg/tools/tools.go +++ b/bcs-services/bcs-bscp/pkg/tools/tools.go @@ -10,6 +10,7 @@ * limitations under the License. */ +// Package tools provides bscp common tools. package tools import ( diff --git a/bcs-services/bcs-bscp/pkg/types/cache.go b/bcs-services/bcs-bscp/pkg/types/cache.go index 3f4f952c66..06dc9d0e7c 100644 --- a/bcs-services/bcs-bscp/pkg/types/cache.go +++ b/bcs-services/bcs-bscp/pkg/types/cache.go @@ -124,10 +124,10 @@ type FilePermissionCache struct { // CredentialCache cache struct. type CredentialCache struct { - Enabled bool `json:"enabled"` - Scope []string `json:"scope"` - scopeMap map[string][]string `json:"-"` // app:scope nolint - isPreprocess bool `json:"-"` // nolint + Enabled bool `json:"enabled"` + Scope []string `json:"scope"` + scopeMap map[string][]string + isPreprocess bool } // preprocess 预处理数据结构, 格式化为app:scope, 方便鉴权处理 diff --git a/bcs-services/bcs-cli/bcs-cluster-manager/.golangci.yml b/bcs-services/bcs-cli/bcs-cluster-manager/.golangci.yml index 64ec85bf97..05c8ef5b8f 100644 --- a/bcs-services/bcs-cli/bcs-cluster-manager/.golangci.yml +++ b/bcs-services/bcs-cli/bcs-cluster-manager/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +54,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +75,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-services/bcs-cli/bcs-data-manager/.golangci.yml b/bcs-services/bcs-cli/bcs-data-manager/.golangci.yml index cbde268e40..4029202c57 100644 --- a/bcs-services/bcs-cli/bcs-data-manager/.golangci.yml +++ b/bcs-services/bcs-cli/bcs-data-manager/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +54,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +75,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-services/bcs-cli/bcs-project-manager/.golangci.yml b/bcs-services/bcs-cli/bcs-project-manager/.golangci.yml index c15e01af66..13035cc49c 100644 --- a/bcs-services/bcs-cli/bcs-project-manager/.golangci.yml +++ b/bcs-services/bcs-cli/bcs-project-manager/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +54,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +75,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-services/bcs-cli/bcs-user-manager/.golangci.yml b/bcs-services/bcs-cli/bcs-user-manager/.golangci.yml index bf1e9766ea..9f573097f6 100644 --- a/bcs-services/bcs-cli/bcs-user-manager/.golangci.yml +++ b/bcs-services/bcs-cli/bcs-user-manager/.golangci.yml @@ -1,26 +1,35 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ + - cmd/create.go issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +45,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +55,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +76,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +119,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-services/bcs-cli/bcs-user-manager/pkg/user.go b/bcs-services/bcs-cli/bcs-user-manager/pkg/user.go index d1849ad8ba..a9e07f3f46 100644 --- a/bcs-services/bcs-cli/bcs-user-manager/pkg/user.go +++ b/bcs-services/bcs-cli/bcs-user-manager/pkg/user.go @@ -247,11 +247,11 @@ type UserInfoResponse struct { func (c *UserManagerClient) GetUserInfo() (*UserInfoResponse, error) { data, err := c.do(getUserInfo, http.MethodGet, nil, nil) if err != nil { - return nil, errors.Wrapf(err, "validate user auth token failed: ") + return nil, errors.Wrapf(err, "validate user auth token failed: ") // nolint } resp := new(UserInfoResponse) if err := json.Unmarshal(data, resp); err != nil { - return nil, errors.Wrapf(err, "Get UserInfo response ", + return nil, errors.Wrapf(err, "Get UserInfo response ", // nolint string(data)) } return resp, nil diff --git a/bcs-services/bcs-cluster-manager/.golangci.yml b/bcs-services/bcs-cluster-manager/.golangci.yml index 4cfe11fcb9..2c0d5f22cb 100644 --- a/bcs-services/bcs-cluster-manager/.golangci.yml +++ b/bcs-services/bcs-cluster-manager/.golangci.yml @@ -1,26 +1,41 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + - api/* + - internal/cloudprovider/component/* + - internal/cloudprovider/qcloud/api/common_* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ + - internal/cloudprovider/qcloud/tasks/createNodeGroup.go + - internal/cloudprovider/qcloud/tasks/createNodeGroup.go + - internal/cloudprovider/qcloud/tasks/createClusterTask.go + - internal/remote/resource/tresource/resource.go issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +51,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +61,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +82,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +125,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-services/bcs-cluster-manager/internal/options/options.go b/bcs-services/bcs-cluster-manager/internal/options/options.go index b5a1a72b15..f02fd7dc64 100644 --- a/bcs-services/bcs-cluster-manager/internal/options/options.go +++ b/bcs-services/bcs-cluster-manager/internal/options/options.go @@ -14,7 +14,7 @@ package options import ( - "github.com/Tencent/bk-bcs/bcs-common/common/encryptv2" + "github.com/Tencent/bk-bcs/bcs-common/common/encryptv2" // nolint cmproto "github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager/api/clustermanager" ) diff --git a/bcs-services/bcs-cluster-manager/internal/remote/encrypt/client.go b/bcs-services/bcs-cluster-manager/internal/remote/encrypt/client.go index 40f4f0f710..dde83cbf23 100644 --- a/bcs-services/bcs-cluster-manager/internal/remote/encrypt/client.go +++ b/bcs-services/bcs-cluster-manager/internal/remote/encrypt/client.go @@ -14,7 +14,7 @@ package encrypt import ( - "github.com/Tencent/bk-bcs/bcs-common/common/encryptv2" + "github.com/Tencent/bk-bcs/bcs-common/common/encryptv2" // nolint "github.com/Tencent/bk-bcs/bcs-common/common/static" proto "github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager/api/clustermanager" diff --git a/bcs-services/bcs-cluster-manager/internal/store/store.go b/bcs-services/bcs-cluster-manager/internal/store/store.go index 864f29bfb1..ae05a85ca7 100644 --- a/bcs-services/bcs-cluster-manager/internal/store/store.go +++ b/bcs-services/bcs-cluster-manager/internal/store/store.go @@ -197,7 +197,7 @@ type ModelSet struct { // NewModelSet create model set func NewModelSet(db drivers.DB) ClusterManagerModel { - storeClient = &ModelSet{ + storeClient = &ModelSet{ // nolint ModelCluster: cluster.New(db), ModelNode: node.New(db), ModelClusterCredential: clustercredential.New(db), diff --git a/bcs-services/bcs-cluster-manager/internal/store/util/credentials.go b/bcs-services/bcs-cluster-manager/internal/store/util/credentials.go index 7dcc09ada1..0ca1f7ed0b 100644 --- a/bcs-services/bcs-cluster-manager/internal/store/util/credentials.go +++ b/bcs-services/bcs-cluster-manager/internal/store/util/credentials.go @@ -16,7 +16,7 @@ package util import ( "fmt" - "github.com/Tencent/bk-bcs/bcs-common/common/encryptv2" + "github.com/Tencent/bk-bcs/bcs-common/common/encryptv2" // nolint proto "github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager/api/clustermanager" "github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-manager/internal/remote/encrypt" diff --git a/bcs-services/bcs-client/.golangci.yml b/bcs-services/bcs-cluster-reporter/.golangci.yml similarity index 69% rename from bcs-services/bcs-client/.golangci.yml rename to bcs-services/bcs-cluster-reporter/.golangci.yml index b30e2625fd..ec348101e3 100644 --- a/bcs-services/bcs-client/.golangci.yml +++ b/bcs-services/bcs-cluster-reporter/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,39 +54,39 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: - local-prefixes: github.com/Tencent/bk-bcs/bcs-services/bcs-client + local-prefixes: github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-reporter gci: sections: - standard - default - - prefix(github.com/Tencent/bk-bcs/bcs-services/bcs-client) + - prefix(github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-reporter) gocritic: settings: ifElseChain: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-services/bcs-cluster-reporter/cmd/root.go b/bcs-services/bcs-cluster-reporter/cmd/root.go index 7cabc9759a..0be22d3da3 100644 --- a/bcs-services/bcs-cluster-reporter/cmd/root.go +++ b/bcs-services/bcs-cluster-reporter/cmd/root.go @@ -51,7 +51,7 @@ var ( Short: "bcs-cluster-reporter", Long: ` Basic Commands (Beginner): - Get Create a resource from a file or from stdin + Get Create a resource from a file or from stdin `, // nolint Run: func(cmd *cobra.Command, args []string) { CheckErr(Complete(cmd, args)) @@ -117,7 +117,8 @@ func Run() error { OnStoppedLeading: func() { klog.Infof("leader lost: %s", id) cancel() - ctx, cancel = context.WithCancel(context.Background()) // nolint + ctx, cancel = context.WithCancel(context.Background()) + // NOCC:vet/vet(忽略) }, }, }) diff --git a/bcs-services/bcs-cluster-reporter/internal/api/bcs/clustermanager.go b/bcs-services/bcs-cluster-reporter/internal/api/bcs/clustermanager.go index b949fee864..faae4cb98b 100644 --- a/bcs-services/bcs-cluster-reporter/internal/api/bcs/clustermanager.go +++ b/bcs-services/bcs-cluster-reporter/internal/api/bcs/clustermanager.go @@ -50,6 +50,7 @@ func (t *BcsTransport) RoundTrip(req *http.Request) (*http.Response, error) { tr := &http.Transport{ TLSClientConfig: &tls.Config{ + // NOCC:gas/tls(设计如此) InsecureSkipVerify: true, // 设置为 true 来禁用证书验证 nolint }, } diff --git a/bcs-services/bcs-cluster-reporter/internal/metric_manager/metric_test.go b/bcs-services/bcs-cluster-reporter/internal/metric_manager/metric_test.go index f739118bd0..8087b8a969 100644 --- a/bcs-services/bcs-cluster-reporter/internal/metric_manager/metric_test.go +++ b/bcs-services/bcs-cluster-reporter/internal/metric_manager/metric_test.go @@ -29,7 +29,7 @@ func TestSendMessage(t *testing.T) { }, []string{"target", "target_biz", "status"}) Register(vec) SetMetric(vec, []*GaugeVecSet{ - &GaugeVecSet{ + { Labels: []string{"1", "2", "3"}, Value: 1, }, diff --git a/bcs-services/bcs-cluster-reporter/internal/plugin/clustercheck/clustercheck.go b/bcs-services/bcs-cluster-reporter/internal/plugin/clustercheck/clustercheck.go index c6a57ca72a..a75776bbc7 100644 --- a/bcs-services/bcs-cluster-reporter/internal/plugin/clustercheck/clustercheck.go +++ b/bcs-services/bcs-cluster-reporter/internal/plugin/clustercheck/clustercheck.go @@ -16,13 +16,14 @@ package clustercheck import ( "context" "fmt" - "k8s.io/client-go/kubernetes" "os" "runtime/debug" "strings" "sync" "time" + "k8s.io/client-go/kubernetes" + "github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-reporter/internal/k8s" "github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-reporter/internal/metric_manager" "github.com/Tencent/bk-bcs/bcs-services/bcs-cluster-reporter/internal/plugin_manager" @@ -39,6 +40,10 @@ import ( "k8s.io/klog" ) +const ( + configError = "配置失败" +) + // Plugin xxx type Plugin struct { stopChan chan int @@ -101,9 +106,9 @@ func (p *Plugin) Setup(configFilePath string) error { updateNestedMap(objectMap, []string{"spec", "template", "metadata", "labels", "bcs-cluster-reporter"}, "bcs-cluster-reporter") //updateNestedMap(objectMap, []string{"spec", "selector", "matchLabels", "bcs-cluster-reporter"}, - // "bcs-cluster-reporter") + // "bcs-cluster-reporter") //updateNestedMap(objectMap, []string{"spec", "selector", "matchLabels", "bcs-cluster-reporter"}, - // "bcs-cluster-reporter") + // "bcs-cluster-reporter") //klog.Info(objectMap) unstructuredObj.SetUnstructuredContent(objectMap) default: @@ -239,14 +244,14 @@ func (p *Plugin) Check() { clusterAvailabilityMapLock.Unlock() metric_manager.SetMetric(clusterAvailabilityMap[clusterId][0], []*metric_manager.GaugeVecSet{ - &metric_manager.GaugeVecSet{Labels: []string{clusterId, clusterbiz, status}, Value: float64(1)}, + {Labels: []string{clusterId, clusterbiz, status}, Value: float64(1)}, }) metric_manager.SetMetric(clusterAvailabilityMap[clusterId][1], []*metric_manager.GaugeVecSet{ - &metric_manager.GaugeVecSet{ + { Labels: []string{clusterId, clusterbiz, "create_pod"}, Value: float64(workloadToPodCost) / 1000000000}, - &metric_manager.GaugeVecSet{ + { Labels: []string{clusterId, clusterbiz, "schedule_pod"}, Value: float64(workloadToScheduleCost) / 1000000000}, - &metric_manager.GaugeVecSet{ + { Labels: []string{clusterId, clusterbiz, "start_pod"}, Value: float64(worloadToRunningCost) / 1000000000}, }) @@ -292,13 +297,13 @@ func testClusterByCreateUnstructuredObj(unstructuredObj *unstructured.Unstructur clientSet, err := k8s.GetClientsetByConfig(config) if err != nil { - *status = "配置失败" // nolint + *status = configError err = fmt.Errorf("GetClientsetByConfig failed: %s", err.Error()) return } if clientSet == nil { - *status = "配置失败" // nolint + *status = configError err = fmt.Errorf("Get clientSet failed %s", err.Error()) return } @@ -335,27 +340,27 @@ func testClusterByCreateUnstructuredObj(unstructuredObj *unstructured.Unstructur // discovery client if it does not support legacy-only discovery. discoveryInterface := clientSet.Discovery().WithLegacy() if discoveryInterface == nil { - *status = "配置失败" // nolint + *status = configError err = fmt.Errorf("Get discoveryInterface failed %s", err.Error()) return } // discoveryInterface.ServerGroupsAndResources() groupResource, err := restmapper.GetAPIGroupResources(discoveryInterface) if err != nil { - *status = "配置失败" // nolint + *status = configError err = fmt.Errorf("GetAPIGroupResources failed %s", err.Error()) } mapper := restmapper.NewDiscoveryRESTMapper(groupResource) mapping, err := mapper.RESTMapping(clusterGVK.GroupKind(), clusterGVK.Version) if err != nil { - *status = "配置失败" // nolint + *status = configError err = fmt.Errorf("RESTMapping failed %s", err.Error()) return } dynamicConfig, err := dynamic.NewForConfig(config) if err != nil { - *status = "配置失败" + *status = configError err = fmt.Errorf("create dynamicConfig %s", err.Error()) return } diff --git a/bcs-services/bcs-cluster-reporter/internal/plugin/logrecorder/logrecorder.go b/bcs-services/bcs-cluster-reporter/internal/plugin/logrecorder/logrecorder.go index dcd5814682..52b54d90c8 100644 --- a/bcs-services/bcs-cluster-reporter/internal/plugin/logrecorder/logrecorder.go +++ b/bcs-services/bcs-cluster-reporter/internal/plugin/logrecorder/logrecorder.go @@ -294,7 +294,7 @@ func LogAnalysis(cluster plugin_manager.ClusterConfig) { if index+1 < len(etcdTookTooLongGaugeVecSetList) { etcdTookTooLongGaugeVecSetList = append(etcdTookTooLongGaugeVecSetList[:index+1], append( - []*metric_manager.GaugeVecSet{&metric_manager.GaugeVecSet{Labels: []string{cluster.ClusterID, + []*metric_manager.GaugeVecSet{{Labels: []string{cluster.ClusterID, cluster.BusinessID, request}, Value: float64(size)}}, etcdTookTooLongGaugeVecSetList[index+1:]...)...) } else { diff --git a/bcs-services/bcs-cluster-reporter/internal/plugin/masterpodcheck/masterpodcheck.go b/bcs-services/bcs-cluster-reporter/internal/plugin/masterpodcheck/masterpodcheck.go index 77f7cd74eb..b3042116f7 100644 --- a/bcs-services/bcs-cluster-reporter/internal/plugin/masterpodcheck/masterpodcheck.go +++ b/bcs-services/bcs-cluster-reporter/internal/plugin/masterpodcheck/masterpodcheck.go @@ -438,18 +438,17 @@ func (p *Plugin) checkStaticPodConsistency(podList []corev1.Pod) string { func checkArguments(argList1 []string, argList2 []string) error { if len(argList1) != len(argList2) { return fmt.Errorf("length not equal") - } else { - for index, arg1 := range argList1 { - arg2 := argList2[index] - if arg1 != arg2 { - // exclude ip address - re, _ := regexp.Compile( - "(([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])") - arg1WithoutIp := re.ReplaceAllString(arg1, "") - arg2WithoutIp := re.ReplaceAllString(arg2, "") - if arg1WithoutIp != arg2WithoutIp { - return fmt.Errorf("arg %s not equal", arg1WithoutIp) - } + } + for index, arg1 := range argList1 { + arg2 := argList2[index] + if arg1 != arg2 { + // exclude ip address + re, _ := regexp.Compile( + "(([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])") + arg1WithoutIp := re.ReplaceAllString(arg1, "") + arg2WithoutIp := re.ReplaceAllString(arg2, "") + if arg1WithoutIp != arg2WithoutIp { + return fmt.Errorf("arg %s not equal", arg1WithoutIp) } } } diff --git a/bcs-services/bcs-data-manager/.golangci.yml b/bcs-services/bcs-data-manager/.golangci.yml index cfbebf8dbf..7811b90a97 100644 --- a/bcs-services/bcs-data-manager/.golangci.yml +++ b/bcs-services/bcs-data-manager/.golangci.yml @@ -1,26 +1,35 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + - pkg/mock/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +45,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +55,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +76,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +119,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-services/bcs-data-manager/pkg/store/mongo/cloudnativeworkload.go b/bcs-services/bcs-data-manager/pkg/store/mongo/cloudnativeworkload.go index 1a913bf170..ac2d7cd0ae 100644 --- a/bcs-services/bcs-data-manager/pkg/store/mongo/cloudnativeworkload.go +++ b/bcs-services/bcs-data-manager/pkg/store/mongo/cloudnativeworkload.go @@ -10,7 +10,6 @@ * limitations under the License. */ -// Package mongo xxx package mongo import ( diff --git a/bcs-services/bcs-data-manager/pkg/store/mongo/mongo.go b/bcs-services/bcs-data-manager/pkg/store/mongo/mongo.go index b9c6d73611..57c4510753 100644 --- a/bcs-services/bcs-data-manager/pkg/store/mongo/mongo.go +++ b/bcs-services/bcs-data-manager/pkg/store/mongo/mongo.go @@ -10,6 +10,7 @@ * limitations under the License. */ +// Package mongo xxx package mongo import ( diff --git a/bcs-services/bcs-gateway-discovery/.golangci.yml b/bcs-services/bcs-gateway-discovery/.golangci.yml index b7f2d91bd0..1c40539d8c 100644 --- a/bcs-services/bcs-gateway-discovery/.golangci.yml +++ b/bcs-services/bcs-gateway-discovery/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +54,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +75,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-services/bcs-helm-manager/.golangci.yml b/bcs-services/bcs-helm-manager/.golangci.yml index 00cf8c8386..188d8d4270 100644 --- a/bcs-services/bcs-helm-manager/.golangci.yml +++ b/bcs-services/bcs-helm-manager/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +54,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +75,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-services/bcs-helm-manager/go.mod b/bcs-services/bcs-helm-manager/go.mod index 91c885b948..dd76788980 100644 --- a/bcs-services/bcs-helm-manager/go.mod +++ b/bcs-services/bcs-helm-manager/go.mod @@ -13,6 +13,7 @@ replace ( k8s.io/apimachinery => k8s.io/apimachinery v0.27.2 k8s.io/cli-runtime => k8s.io/cli-runtime v0.27.2 k8s.io/client-go => k8s.io/client-go v0.27.2 + k8s.io/kubernetes => k8s.io/kubernetes v1.13.0 ) require ( @@ -31,7 +32,6 @@ require ( github.com/spf13/cobra v1.7.0 github.com/spf13/viper v1.10.0 github.com/tidwall/pretty v1.0.0 - github.com/ugorji/go/codec v1.2.6 // indirect github.com/vmware-tanzu/carvel-ytt v0.40.1 go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect @@ -85,7 +85,7 @@ require ( github.com/TencentBlueKing/crypto-golang-sdk v1.0.0 // indirect github.com/TencentBlueKing/iam-go-sdk v0.0.8 // indirect github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535 // indirect - github.com/aws/aws-sdk-go v1.37.27 // indirect + github.com/aws/aws-sdk-go v1.43.16 // indirect github.com/benbjohnson/clock v1.3.0 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/bitly/go-simplejson v0.5.0 // indirect @@ -98,6 +98,7 @@ require ( github.com/cyphar/filepath-securejoin v0.2.3 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgraph-io/ristretto v0.1.1 // indirect + github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13 // indirect github.com/docker/cli v20.10.24+incompatible // indirect github.com/docker/distribution v2.8.2+incompatible // indirect github.com/docker/docker v20.10.24+incompatible // indirect @@ -201,6 +202,7 @@ require ( github.com/spf13/cast v1.5.0 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/subosito/gotenv v1.2.0 // indirect + github.com/ugorji/go/codec v1.2.6 // indirect github.com/xanzy/ssh-agent v0.3.2 // indirect github.com/xdg-go/pbkdf2 v1.0.0 // indirect github.com/xdg-go/scram v1.0.2 // indirect @@ -218,11 +220,11 @@ require ( golang.org/x/crypto v0.7.0 // indirect golang.org/x/mod v0.9.0 // indirect golang.org/x/net v0.10.0 // indirect - golang.org/x/oauth2 v0.4.0 // indirect + golang.org/x/oauth2 v0.5.0 // indirect golang.org/x/sys v0.8.0 // indirect golang.org/x/term v0.8.0 // indirect golang.org/x/text v0.9.0 // indirect - golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect + golang.org/x/time v0.1.0 // indirect golang.org/x/tools v0.7.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect google.golang.org/appengine v1.6.7 // indirect diff --git a/bcs-services/bcs-helm-manager/internal/app/app.go b/bcs-services/bcs-helm-manager/internal/app/app.go index de232ca580..70c6b0b9ad 100644 --- a/bcs-services/bcs-helm-manager/internal/app/app.go +++ b/bcs-services/bcs-helm-manager/internal/app/app.go @@ -30,7 +30,7 @@ import ( "github.com/Tencent/bk-bcs/bcs-common/common/blog" "github.com/Tencent/bk-bcs/bcs-common/common/encrypt" - "github.com/Tencent/bk-bcs/bcs-common/common/encryptv2" + "github.com/Tencent/bk-bcs/bcs-common/common/encryptv2" // nolint "github.com/Tencent/bk-bcs/bcs-common/common/http/ipv6server" "github.com/Tencent/bk-bcs/bcs-common/common/ssl" "github.com/Tencent/bk-bcs/bcs-common/common/static" diff --git a/bcs-services/bcs-helm-manager/internal/store/repository/repository.go b/bcs-services/bcs-helm-manager/internal/store/repository/repository.go index 8269152fbb..7ee4c4b064 100644 --- a/bcs-services/bcs-helm-manager/internal/store/repository/repository.go +++ b/bcs-services/bcs-helm-manager/internal/store/repository/repository.go @@ -20,7 +20,7 @@ import ( "time" "github.com/Tencent/bk-bcs/bcs-common/common/blog" - "github.com/Tencent/bk-bcs/bcs-common/common/encryptv2" + "github.com/Tencent/bk-bcs/bcs-common/common/encryptv2" // nolint "github.com/Tencent/bk-bcs/bcs-common/pkg/odm/drivers" "github.com/Tencent/bk-bcs/bcs-common/pkg/odm/operator" "go.mongodb.org/mongo-driver/bson" diff --git a/bcs-services/bcs-helm-manager/internal/store/store.go b/bcs-services/bcs-helm-manager/internal/store/store.go index 95853de0f9..60b7cf3796 100644 --- a/bcs-services/bcs-helm-manager/internal/store/store.go +++ b/bcs-services/bcs-helm-manager/internal/store/store.go @@ -16,7 +16,7 @@ package store import ( "context" - "github.com/Tencent/bk-bcs/bcs-common/common/encryptv2" + "github.com/Tencent/bk-bcs/bcs-common/common/encryptv2" // nolint "github.com/Tencent/bk-bcs/bcs-common/pkg/odm/drivers" "github.com/Tencent/bk-bcs/bcs-common/pkg/odm/operator" @@ -75,7 +75,7 @@ type modelSet struct { // New return a new ResourceManagerModel instance func New(db drivers.DB, cryptor encryptv2.Cryptor) HelmManagerModel { - return &modelSet{ + return &modelSet{ // nolint ModelRepository: repository.New(db, cryptor), ModelRelease: release.New(db), } diff --git a/bcs-services/bcs-k8s-watch/.golangci.yml b/bcs-services/bcs-k8s-watch/.golangci.yml index 40a1317859..a547c64446 100644 --- a/bcs-services/bcs-k8s-watch/.golangci.yml +++ b/bcs-services/bcs-k8s-watch/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +54,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +75,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-services/bcs-k8s-watch/app/k8s/watcher.go b/bcs-services/bcs-k8s-watch/app/k8s/watcher.go index ff827cf27b..1f6f2c922c 100644 --- a/bcs-services/bcs-k8s-watch/app/k8s/watcher.go +++ b/bcs-services/bcs-k8s-watch/app/k8s/watcher.go @@ -124,6 +124,7 @@ func (wo *WatcherOptions) Validate() error { } // NewWatcher creates a new watcher of target type resource. +// nolint func NewWatcher(wo *WatcherOptions) (*Watcher, error) { if wo == nil { return nil, fmt.Errorf("WatcherOptions can not be nil pointer") diff --git a/bcs-services/bcs-kube-agent/.golangci.yml b/bcs-services/bcs-kube-agent/.golangci.yml index 458c3b102d..b885379c63 100644 --- a/bcs-services/bcs-kube-agent/.golangci.yml +++ b/bcs-services/bcs-kube-agent/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +54,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +75,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-services/bcs-mesh-manager/.golangci.yml b/bcs-services/bcs-mesh-manager/.golangci.yml deleted file mode 100644 index c8bae36544..0000000000 --- a/bcs-services/bcs-mesh-manager/.golangci.yml +++ /dev/null @@ -1,117 +0,0 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - -run: - timeout: 10m - -issues: - # 显示所有 issue - max-issues-per-linter: 0 - max-same-issues: 0 - exclude-use-default: false - -linters: - disable-all: true - enable: - # enable by default - - errcheck - - gosimple - - govet - - ineffassign - - staticcheck - - unused - - # custom - - funlen - - gci - - goconst - - gocritic - - gocyclo - - gofmt - - goheader - - goimports - - gosec - - lll - - misspell - - nakedret - - revive - - unconvert - - unparam - -linters-settings: - # 只开启特定的规则 - errcheck: - exclude-functions: - - (*os.File).Close - - (io.Closer).Close - - (net/http.ResponseWriter).Write - - github.com/go-chi/render.Render - - io.Copy - - os.RemoveAll - lll: - line-length: 120 # widely used and popular community recommended length - funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 - gocyclo: - min-complexity: 30 # 函数圈复杂度 - govet: - check-shadowing: true - goimports: - local-prefixes: github.com/Tencent/bk-bcs/bcs-services/bcs-mesh-manager - gci: - sections: - - standard - - default - - prefix(github.com/Tencent/bk-bcs/bcs-services/bcs-mesh-manager) - gocritic: - settings: - ifElseChain: - minThreshold: 3 - gosec: - includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi - goheader: - values: - regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 - template: |- - * Tencent is pleased to support the open source community by making Blueking Container Service available. - * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. - * Licensed under the MIT License (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * http://opensource.org/licenses/MIT - * 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. - misspell: - locale: US - revive: - confidence: 0 - rules: - - name: blank-imports - - name: context-as-argument - - name: context-keys-type - - name: dot-imports - - name: early-return - - name: error-naming - - name: error-return - - name: error-strings - - name: errorf - - name: exported - - name: increment-decrement - - name: indent-error-flow - - name: package-comments - - name: range - - name: receiver-naming - - name: time-naming - # - name: unexported-return - - name: var-declaration - # - name: var-naming diff --git a/bcs-services/bcs-monitor/.golangci.yml b/bcs-services/bcs-monitor/.golangci.yml index 71d097fc69..78e9c8fa0d 100644 --- a/bcs-services/bcs-monitor/.golangci.yml +++ b/bcs-services/bcs-monitor/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +54,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +75,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-services/bcs-netservice/bcs-ipam/.golangci.yml b/bcs-services/bcs-netservice/bcs-ipam/.golangci.yml deleted file mode 100644 index dd8d07723e..0000000000 --- a/bcs-services/bcs-netservice/bcs-ipam/.golangci.yml +++ /dev/null @@ -1,117 +0,0 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - -run: - timeout: 10m - -issues: - # 显示所有 issue - max-issues-per-linter: 0 - max-same-issues: 0 - exclude-use-default: false - -linters: - disable-all: true - enable: - # enable by default - - errcheck - - gosimple - - govet - - ineffassign - - staticcheck - - unused - - # custom - - funlen - - gci - - goconst - - gocritic - - gocyclo - - gofmt - - goheader - - goimports - - gosec - - lll - - misspell - - nakedret - - revive - - unconvert - - unparam - -linters-settings: - # 只开启特定的规则 - errcheck: - exclude-functions: - - (*os.File).Close - - (io.Closer).Close - - (net/http.ResponseWriter).Write - - github.com/go-chi/render.Render - - io.Copy - - os.RemoveAll - lll: - line-length: 120 # widely used and popular community recommended length - funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 - gocyclo: - min-complexity: 30 # 函数圈复杂度 - govet: - check-shadowing: true - goimports: - local-prefixes: github.com/Tencent/bk-bcs/bcs-services/bcs-netservice/bcs-ipam - gci: - sections: - - standard - - default - - prefix(github.com/Tencent/bk-bcs/bcs-services/bcs-netservice/bcs-ipam) - gocritic: - settings: - ifElseChain: - minThreshold: 3 - gosec: - includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi - goheader: - values: - regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 - template: |- - * Tencent is pleased to support the open source community by making Blueking Container Service available. - * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. - * Licensed under the MIT License (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * http://opensource.org/licenses/MIT - * 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. - misspell: - locale: US - revive: - confidence: 0 - rules: - - name: blank-imports - - name: context-as-argument - - name: context-keys-type - - name: dot-imports - - name: early-return - - name: error-naming - - name: error-return - - name: error-strings - - name: errorf - - name: exported - - name: increment-decrement - - name: indent-error-flow - - name: package-comments - - name: range - - name: receiver-naming - - name: time-naming - # - name: unexported-return - - name: var-declaration - # - name: var-naming diff --git a/bcs-services/bcs-nodegroup-manager/.golangci.yml b/bcs-services/bcs-nodegroup-manager/.golangci.yml index 612e685b3a..e10338529d 100644 --- a/bcs-services/bcs-nodegroup-manager/.golangci.yml +++ b/bcs-services/bcs-nodegroup-manager/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +54,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +75,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-services/bcs-project-manager/.golangci.yml b/bcs-services/bcs-project-manager/.golangci.yml index bc975079eb..f6e298037d 100644 --- a/bcs-services/bcs-project-manager/.golangci.yml +++ b/bcs-services/bcs-project-manager/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +54,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +75,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-services/bcs-storage/.golangci.yml b/bcs-services/bcs-storage/.golangci.yml index ac3112aa51..3c2796b650 100644 --- a/bcs-services/bcs-storage/.golangci.yml +++ b/bcs-services/bcs-storage/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +54,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +75,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-services/bcs-user-manager/.golangci.yml b/bcs-services/bcs-user-manager/.golangci.yml index 738707d9ac..7ec36f80ec 100644 --- a/bcs-services/bcs-user-manager/.golangci.yml +++ b/bcs-services/bcs-user-manager/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +54,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +75,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-services/bcs-user-manager/app/user-manager/storages/sqlstore/token.go b/bcs-services/bcs-user-manager/app/user-manager/storages/sqlstore/token.go index adce411c42..e7b3ec0323 100644 --- a/bcs-services/bcs-user-manager/app/user-manager/storages/sqlstore/token.go +++ b/bcs-services/bcs-user-manager/app/user-manager/storages/sqlstore/token.go @@ -16,7 +16,7 @@ import ( "time" "github.com/Tencent/bk-bcs/bcs-common/common/blog" - "github.com/Tencent/bk-bcs/bcs-common/common/encryptv2" + "github.com/Tencent/bk-bcs/bcs-common/common/encryptv2" // nolint "github.com/jinzhu/gorm" "github.com/Tencent/bk-bcs/bcs-services/bcs-user-manager/app/pkg/constant" diff --git a/bcs-services/bcs-user-manager/app/user-manager/user-manager.go b/bcs-services/bcs-user-manager/app/user-manager/user-manager.go index bd9f9ef36e..8f8c6b73a6 100644 --- a/bcs-services/bcs-user-manager/app/user-manager/user-manager.go +++ b/bcs-services/bcs-user-manager/app/user-manager/user-manager.go @@ -26,7 +26,7 @@ import ( "github.com/Tencent/bk-bcs/bcs-common/common" "github.com/Tencent/bk-bcs/bcs-common/common/blog" - "github.com/Tencent/bk-bcs/bcs-common/common/encryptv2" + "github.com/Tencent/bk-bcs/bcs-common/common/encryptv2" // nolint bcshttp "github.com/Tencent/bk-bcs/bcs-common/common/http" "github.com/Tencent/bk-bcs/bcs-common/common/http/httpserver" "github.com/Tencent/bk-bcs/bcs-common/common/ssl" diff --git a/bcs-services/bcs-user-manager/config/config.go b/bcs-services/bcs-user-manager/config/config.go index ee35be43d8..f6a9ec6f2a 100644 --- a/bcs-services/bcs-user-manager/config/config.go +++ b/bcs-services/bcs-user-manager/config/config.go @@ -16,7 +16,7 @@ package config import ( "crypto/tls" - "github.com/Tencent/bk-bcs/bcs-common/common/encryptv2" + "github.com/Tencent/bk-bcs/bcs-common/common/encryptv2" // nolint "github.com/Tencent/bk-bcs/bcs-common/common/static" "github.com/Tencent/bk-bcs/bcs-common/pkg/auth/iam" registry "github.com/Tencent/bk-bcs/bcs-common/pkg/registryv4" diff --git a/bcs-services/bcs-user-manager/go.mod b/bcs-services/bcs-user-manager/go.mod index 7fbf6dd6fe..b8f34f07cc 100644 --- a/bcs-services/bcs-user-manager/go.mod +++ b/bcs-services/bcs-user-manager/go.mod @@ -1,6 +1,6 @@ module github.com/Tencent/bk-bcs/bcs-services/bcs-user-manager -go 1.20 +go 1.17 replace ( github.com/TencentBlueKing/iam-go-sdk => github.com/TencentBlueKing/iam-go-sdk v0.1.5 @@ -44,7 +44,7 @@ require ( require ( github.com/Microsoft/go-winio v0.6.1 // indirect - github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 // indirect + github.com/ProtonMail/go-crypto v0.0.0-20220824120805-4b6e5c587895 // indirect github.com/PuerkitoBio/purell v1.1.1 // indirect github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect github.com/TencentBlueKing/bk-audit-go-sdk v0.0.5 // indirect @@ -56,13 +56,14 @@ require ( github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect github.com/cenkalti/backoff/v4 v4.2.1 // indirect github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cloudflare/circl v1.2.0 // indirect github.com/coreos/go-semver v0.3.0 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/emicklei/go-restful-openapi v1.4.1 // indirect - github.com/emirpasic/gods v1.12.0 // indirect + github.com/emirpasic/gods v1.18.1 // indirect github.com/felixge/httpsnoop v1.0.3 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/go-git/gcfg v1.5.0 // indirect @@ -87,14 +88,15 @@ require ( github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/imdario/mergo v0.3.12 // indirect + github.com/imdario/mergo v0.3.13 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jinzhu/now v1.1.1 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/jtolds/gls v4.20.0+incompatible // indirect github.com/juju/ratelimit v1.0.1 // indirect - github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect + github.com/kevinburke/ssh_config v1.2.0 // indirect github.com/leodido/go-urn v1.2.2 // indirect github.com/mailru/easyjson v0.7.6 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect @@ -106,23 +108,25 @@ require ( github.com/modern-go/reflect2 v1.0.2 // indirect github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect github.com/nxadm/tail v1.4.8 // indirect + github.com/onsi/ginkgo/v2 v2.1.3 // indirect github.com/openzipkin/zipkin-go v0.3.0 // indirect github.com/oxtoacart/bpool v0.0.0-20190530202638-03653db5a59c // indirect + github.com/parnurzeal/gorequest v0.2.16 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/prometheus/client_model v0.3.0 // indirect github.com/prometheus/common v0.41.0 // indirect github.com/prometheus/procfs v0.9.0 // indirect - github.com/russross/blackfriday/v2 v2.0.1 // indirect - github.com/sergi/go-diff v1.1.0 // indirect - github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect + github.com/russross/blackfriday/v2 v2.1.0 // indirect + github.com/sergi/go-diff v1.2.0 // indirect github.com/signalfx/splunk-otel-go v1.4.0 // indirect github.com/signalfx/splunk-otel-go/instrumentation/database/sql/splunksql v1.4.0 // indirect github.com/signalfx/splunk-otel-go/instrumentation/internal v1.4.0 // indirect + github.com/smartystreets/assertions v1.2.0 // indirect github.com/spf13/pflag v1.0.5 // indirect github.com/stretchr/objx v0.5.0 // indirect github.com/ugorji/go/codec v1.2.9 // indirect github.com/urfave/cli/v2 v2.3.0 // indirect - github.com/xanzy/ssh-agent v0.3.0 // indirect + github.com/xanzy/ssh-agent v0.3.2 // indirect go.etcd.io/etcd/api/v3 v3.5.2 // indirect go.etcd.io/etcd/client/pkg/v3 v3.5.2 // indirect go.opentelemetry.io/otel/exporters/jaeger v1.3.0 // indirect @@ -164,7 +168,6 @@ require ( github.com/dustin/go-humanize v1.0.0 github.com/go-micro/plugins/v4/registry/etcd v1.1.0 github.com/google/uuid v1.3.1 - github.com/parnurzeal/gorequest v0.2.16 // indirect go-micro.dev/v4 v4.10.2 go.etcd.io/etcd/client/v3 v3.5.2 go.opentelemetry.io/otel v1.17.0 diff --git a/bcs-services/bcs-webconsole/.golangci.yml b/bcs-services/bcs-webconsole/.golangci.yml index 952b20e9d6..41b5d88b8d 100644 --- a/bcs-services/bcs-webconsole/.golangci.yml +++ b/bcs-services/bcs-webconsole/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +54,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +75,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-services/cluster-resources/.golangci.yml b/bcs-services/cluster-resources/.golangci.yml index f44fa8f9f4..4d7d446dc0 100644 --- a/bcs-services/cluster-resources/.golangci.yml +++ b/bcs-services/cluster-resources/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +54,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +75,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-services/pkg/.golangci.yml b/bcs-services/pkg/.golangci.yml index bb01d9c11e..bf59ab9758 100644 --- a/bcs-services/pkg/.golangci.yml +++ b/bcs-services/pkg/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +54,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +75,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-services/pkg/bcs-auth-v4/.golangci.yml b/bcs-services/pkg/bcs-auth-v4/.golangci.yml index c3cc98ebf1..bc19dde673 100644 --- a/bcs-services/pkg/bcs-auth-v4/.golangci.yml +++ b/bcs-services/pkg/bcs-auth-v4/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +54,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +75,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/bcs-ui/.golangci.yml b/bcs-ui/.golangci.yml index 81fa6e4a87..2bff6731c6 100644 --- a/bcs-ui/.golangci.yml +++ b/bcs-ui/.golangci.yml @@ -1,26 +1,34 @@ -# Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m - + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ issues: - # 显示所有 issue max-issues-per-linter: 0 max-same-issues: 0 exclude-use-default: false - linters: disable-all: true enable: - # enable by default - errcheck - gosimple - govet - ineffassign - staticcheck - unused - - # custom - funlen - gci - goconst @@ -36,9 +44,7 @@ linters: - revive - unconvert - unparam - linters-settings: - # 只开启特定的规则 errcheck: exclude-functions: - (*os.File).Close @@ -48,12 +54,12 @@ linters-settings: - io.Copy - os.RemoveAll lll: - line-length: 120 # widely used and popular community recommended length + line-length: 120 funlen: - lines: 90 # 函数长度 default * 1.5 - statements: -1 # 不限制语句数量, 通过圈复杂度处理 + lines: 90 + statements: -1 gocyclo: - min-complexity: 30 # 函数圈复杂度 + min-complexity: 30 govet: check-shadowing: true goimports: @@ -69,18 +75,18 @@ linters-settings: minThreshold: 3 gosec: includes: - - G201 # SQL query construction using format string - - G202 # SQL query construction using string concatenation - - G101 # Look for hard coded credentials - - G401 # Detect the usage of DES, RC4, MD5 or SHA1 - - G402 # Look for bad TLS connection settings - - G403 # Ensure minimum RSA key length of 2048 bits - - G404 # Insecure random number source (rand) - - G504 # Import blocklist: net/http/cgi + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 goheader: values: regexp: - YEAR: 20\d\d # 头部时间变量, 如: 2019等, 新增的为当前年份即可 + YEAR: 20\d\d template: |- * Tencent is pleased to support the open source community by making Blueking Container Service available. * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. @@ -112,6 +118,4 @@ linters-settings: - name: range - name: receiver-naming - name: time-naming - # - name: unexported-return - name: var-declaration - # - name: var-naming diff --git a/go.mod b/go.mod index eda2133105..5c7a991333 100644 --- a/go.mod +++ b/go.mod @@ -26,6 +26,7 @@ require ( github.com/emicklei/go-restful v2.15.0+incompatible github.com/fsnotify/fsnotify v1.4.9 github.com/fsouza/go-dockerclient v1.6.0 + github.com/goccy/go-yaml v1.11.3 github.com/golang/protobuf v1.4.3 github.com/google/cadvisor v0.32.0 github.com/gorilla/websocket v1.4.2 @@ -45,7 +46,7 @@ require ( github.com/samuel/go-zookeeper v0.0.0-20201211165307-7117e9ea2414 github.com/spf13/pflag v1.0.5 go4.org v0.0.0-20190313082347-94abd6928b1d - golang.org/x/net v0.0.0-20201224014010-6772e930b67b + golang.org/x/net v0.8.0 google.golang.org/grpc v1.33.1 k8s.io/api v0.18.16 k8s.io/apiextensions-apiserver v0.18.6 @@ -76,6 +77,7 @@ require ( github.com/docker/go-units v0.4.0 // indirect github.com/envoyproxy/protoc-gen-validate v0.1.0 // indirect github.com/farsightsec/golang-framestream v0.0.0-20181102145529-8a0cb8ba8710 // indirect + github.com/fatih/color v1.10.0 // indirect github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 // indirect github.com/go-logr/logr v0.1.0 // indirect github.com/go-openapi/analysis v0.19.6 // indirect @@ -108,6 +110,8 @@ require ( github.com/klauspost/compress v1.9.5 // indirect github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect github.com/mailru/easyjson v0.7.0 // indirect + github.com/mattn/go-colorable v0.1.8 // indirect + github.com/mattn/go-isatty v0.0.17 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/micro/go-micro/v2 v2.9.1 // indirect github.com/mitchellh/hashstructure v1.0.0 // indirect @@ -134,15 +138,16 @@ require ( go.uber.org/multierr v1.3.0 // indirect go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee // indirect go.uber.org/zap v1.13.0 // indirect - golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect + golang.org/x/crypto v0.7.0 // indirect golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f // indirect - golang.org/x/mod v0.3.0 // indirect + golang.org/x/mod v0.8.0 // indirect golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect golang.org/x/sync v0.1.0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/text v0.3.5 // indirect + golang.org/x/sys v0.6.0 // indirect + golang.org/x/term v0.6.0 // indirect + golang.org/x/text v0.8.0 // indirect golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect - golang.org/x/tools v0.0.0-20210106214847-113979e3529a // indirect + golang.org/x/tools v0.6.0 // indirect golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect google.golang.org/appengine v1.6.1 // indirect google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect diff --git a/install/cryptool/.golangci.yml b/install/cryptool/.golangci.yml new file mode 100644 index 0000000000..78c5eee3c9 --- /dev/null +++ b/install/cryptool/.golangci.yml @@ -0,0 +1,121 @@ +run: + timeout: 10m + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - .*/third_party/* + skip-files: + - .*\.docs\.go$ + - .*\.gen\.go$ + - .*\.pb\.go$ + - .*\.pb.gw\.go$ + - .*\.pb.micro\.go$ + - .*\.pb.validate\.go$ + - .*\_test\.go$ +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-use-default: false +linters: + disable-all: true + enable: + - errcheck + - gosimple + - govet + - ineffassign + - staticcheck + - unused + - funlen + - gci + - goconst + - gocritic + - gocyclo + - gofmt + - goheader + - goimports + - gosec + - lll + - misspell + - nakedret + - revive + - unconvert + - unparam +linters-settings: + errcheck: + exclude-functions: + - (*os.File).Close + - (io.Closer).Close + - (net/http.ResponseWriter).Write + - github.com/go-chi/render.Render + - io.Copy + - os.RemoveAll + lll: + line-length: 120 + funlen: + lines: 90 + statements: -1 + gocyclo: + min-complexity: 30 + govet: + check-shadowing: true + goimports: + local-prefixes: github.com/Tencent/bk-bcs/install/cryptool + gci: + sections: + - standard + - default + - prefix(github.com/Tencent/bk-bcs/install/cryptool) + gocritic: + settings: + ifElseChain: + minThreshold: 3 + gosec: + includes: + - G201 + - G202 + - G101 + - G401 + - G402 + - G403 + - G404 + - G504 + goheader: + values: + regexp: + YEAR: 20\d\d + template: |- + * Tencent is pleased to support the open source community by making Blueking Container Service available. + * Copyright (C) {{ YEAR }} THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * 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. + misspell: + locale: US + revive: + confidence: 0 + rules: + - name: blank-imports + - name: context-as-argument + - name: context-keys-type + - name: dot-imports + - name: early-return + - name: error-naming + - name: error-return + - name: error-strings + - name: errorf + - name: exported + - name: increment-decrement + - name: indent-error-flow + - name: package-comments + - name: range + - name: receiver-naming + - name: time-naming + - name: var-declaration diff --git a/install/cryptool/main.go b/install/cryptool/main.go index f7d650c8ab..74a675f377 100644 --- a/install/cryptool/main.go +++ b/install/cryptool/main.go @@ -8,16 +8,16 @@ * 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 main is the main package of cryptool package main import ( "fmt" "os" - "github.com/Tencent/bk-bcs/bcs-common/common/encryptv2" + "github.com/Tencent/bk-bcs/bcs-common/common/encryptv2" // nolint ) func main() { @@ -68,14 +68,14 @@ func main() { fmt.Printf("%s encrypt from original failed: %s\n", os.Args[1], err.Error()) return } - fmt.Printf("%s Encrypt text: %s\n", os.Args[1], string(out)) + fmt.Printf("%s Encrypt text: %s\n", os.Args[1], string(out)) // nolint case "decrypt": out, err := cryptor.Decrypt(os.Args[5]) if err != nil { fmt.Printf("%s Decrypt from Base failed: %s\n", os.Args[1], err.Error()) return } - fmt.Printf("%s Original text: %s\n", os.Args[1], string(out)) + fmt.Printf("%s Original text: %s\n", os.Args[1], string(out)) // nolint default: fmt.Printf("Unknown action...\n") } @@ -83,5 +83,5 @@ func main() { fmt.Printf("Unknown Algorithm, please [normal|SM4|AES-GCM]...\n") } - return + return // nolint } diff --git a/bcs-services/bcs-alert-manager/.golangci.yml b/scripts/gen-lint/.golangci.yml.tpl similarity index 84% rename from bcs-services/bcs-alert-manager/.golangci.yml rename to scripts/gen-lint/.golangci.yml.tpl index dbe12bda90..4ae07d1dd7 100644 --- a/bcs-services/bcs-alert-manager/.golangci.yml +++ b/scripts/gen-lint/.golangci.yml.tpl @@ -1,7 +1,23 @@ # Code generated by scripts/gen-lint. DO NOT EDIT. - run: timeout: 10m + skip-dirs: + - bcs-services/bcs-upgrader + - bcs-services/bcs-service-prometheus + - bcs-network + - bcs-runtime/bcs-mesos + - bcs-runtime/bcs-k8s/bcs-component/bcs-cc-agent + - bcs-runtime/bcs-k8s/bcs-component/bcs-cpuset-device + - ".*/third_party/*" + skip-files: + # Proto file + - ".*\\.docs\\.go$" + - ".*\\.gen\\.go$" + - ".*\\.pb\\.go$" + - ".*\\.pb.gw\\.go$" + - ".*\\.pb.micro\\.go$" + - ".*\\.pb.validate\\.go$" + - ".*\\_test\\.go$" issues: # 显示所有 issue @@ -57,12 +73,12 @@ linters-settings: govet: check-shadowing: true goimports: - local-prefixes: github.com/Tencent/bk-bcs/bcs-services/bcs-alert-manager + local-prefixes: github.com/Tencent/bk-bcs gci: sections: - standard - default - - prefix(github.com/Tencent/bk-bcs/bcs-services/bcs-alert-manager) + - prefix(github.com/Tencent/bk-bcs) gocritic: settings: ifElseChain: diff --git a/scripts/gen-lint/golangci-lint.sh b/scripts/gen-lint/golangci-lint.sh new file mode 100755 index 0000000000..432834fc3f --- /dev/null +++ b/scripts/gen-lint/golangci-lint.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +parent_path=$(pwd) +find . -type d | while read dir; do + if [[ -f "$dir/.golangci.yml" ]]; then + cd $dir; go mod tidy; golangci-lint run ;cd $parent_path + fi +done \ No newline at end of file diff --git a/scripts/gen-lint/main.go b/scripts/gen-lint/main.go index edf586dc15..d057f089f4 100644 --- a/scripts/gen-lint/main.go +++ b/scripts/gen-lint/main.go @@ -14,43 +14,131 @@ package main import ( + "bufio" "fmt" + "os" "path" "regexp" "strings" "github.com/bitfield/script" + goyaml "github.com/goccy/go-yaml" + "github.com/goccy/go-yaml/parser" ) -var testMod = []string{ - "bcs-ui", - "bcs-common", - "bcs-services", +func getBlackList() ([]string, error) { + file, err := os.Open("./scripts/gen-lint/modules_black_list") + if err != nil { + return nil, err + } + defer file.Close() + + // 创建Scanner来逐行读取 + scanner := bufio.NewScanner(file) + + // 创建一个string类型的切片来存储文件中的每一行 + var lines []string + + // 逐行扫描 + for scanner.Scan() { + // 将扫描到的行添加到切片中 + lines = append(lines, scanner.Text()) + } + + // 检查是否有可能的错误 + if err := scanner.Err(); err != nil { + return nil, err + } + return lines, nil } -func matchTestMod(line string) bool { - for _, m := range testMod { - if strings.Contains(line, m) { +func matchBlackList(line string, blackList []string) bool { + for _, m := range blackList { + if line == m { return true } } return false } +func getGolangciYmlTemplate() (string, error) { + content, err := os.ReadFile("./scripts/gen-lint/.golangci.yml.tpl") + if err != nil { + return "", err + } + return string(content), nil +} + +// get skip files from code cc +func getSkipFiles() ([]string, error) { + content, err := os.ReadFile(".code.yml") + if err != nil { + return nil, err + } + + filePath, err := goyaml.PathString("$.source.test_source.filepath_regex") + if err != nil { + return nil, err + } + skipFiles := []string{} + _ = filePath.Read(strings.NewReader(string(content)), &skipFiles) + return skipFiles, nil +} + +func findModuleSkipFilesAndDirs(moduleDir string, files []string) ([]string, []string) { + skipDirs := []string{} + skipFiles := []string{} + for _, file := range files { + file = strings.TrimPrefix(file, "/") + if strings.HasPrefix(file, moduleDir) { + file = strings.Replace(file, moduleDir, "", 1) + file = strings.TrimPrefix(file, "/") + if strings.HasSuffix(file, ".go") { + skipFiles = append(skipFiles, file) + } + if strings.HasSuffix(file, ".*") { + file = strings.ReplaceAll(file, ".*", "*") + skipDirs = append(skipDirs, file) + } + } + } + return skipFiles, skipDirs +} + func main() { + blackList, err := getBlackList() + if err != nil { + panic(err) + } mods, err := script.FindFiles("./").Match("go.mod").String() if err != nil { panic(err) } + tpl, err := getGolangciYmlTemplate() + if err != nil { + panic(err) + } + skipFiles, err := getSkipFiles() + if err != nil { + panic(err) + } + // parse origin yaml + f, err := parser.ParseBytes([]byte(tpl), 0) + if err != nil { + panic(err) + } + re := regexp.MustCompile(`module\s+(.*)`) for _, line := range strings.Split(mods, "\n") { line = strings.TrimSpace(line) if line == "" { continue } - if !matchTestMod(line) { + dir := path.Dir(line) + if matchBlackList(dir, blackList) { continue } + v, err := script.File(line).String() if err != nil { continue @@ -60,21 +148,50 @@ func main() { continue } module := match[1] - d := path.Dir(line) - _, err = script.File("./.golangci.yml"). - Replace("# - gci", "- gci"). - Replace("# goimports", "goimports"). - Replace("# local-prefixes: github.com/Tencent/bk-bcs", fmt.Sprintf(" local-prefixes: %s", module)). - Replace("# gci", "gci"). - Replace("# sections", " sections"). - Replace("# - standard", " - standard"). - Replace("# - default", " - default"). - Replace("# - prefix(github.com/Tencent/bk-bcs)", fmt.Sprintf(" - prefix(%s)", module)). - Replace("run:", "# Code generated by scripts/gen-lint. DO NOT EDIT.\n\nrun:"). - WriteFile(path.Join(d, "./.golangci.yml")) + + // get skip files and dirs + gotSkipFiles, gotSkipDirs := findModuleSkipFilesAndDirs(dir, skipFiles) + skipDirsPath, err := goyaml.PathString("$.run.skip-dirs") if err != nil { - panic(err) + continue + } + skipFilesPath, err := goyaml.PathString("$.run.skip-files") + if err != nil { + continue } - fmt.Printf("generate .golangci.yml to %s done.\n", d) + + // append skip files and dirs + skipDirs := []string{} + skipFiles := []string{} + _ = skipDirsPath.Read(strings.NewReader(tpl), &skipDirs) + _ = skipFilesPath.Read(strings.NewReader(tpl), &skipFiles) + _ = skipDirsPath.ReplaceWithReader(f, strings.NewReader(stringsToYAML(append(skipDirs, gotSkipDirs...)))) + _ = skipFilesPath.ReplaceWithReader(f, strings.NewReader(stringsToYAML(append(skipFiles, gotSkipFiles...)))) + + // append gci local-prefixes + localPrefixesPath, err := goyaml.PathString("$.linters-settings.goimports.local-prefixes") + if err != nil { + continue + } + _ = localPrefixesPath.ReplaceWithReader(f, strings.NewReader(module)) + + // append gci prefix + gciPath, err := goyaml.PathString("$.linters-settings.gci.sections") + if err != nil { + continue + } + _ = gciPath.ReplaceWithReader(f, strings.NewReader(stringsToYAML([]string{"standard", "default", + fmt.Sprintf("prefix(%s)", module)}))) + + _ = os.WriteFile(path.Join(dir, "./.golangci.yml"), []byte(f.String()), 0644) + fmt.Printf("generate .golangci.yml to %s done.\n", dir) + } +} + +func stringsToYAML(v []string) string { + s := "" + for _, i := range v { + s += fmt.Sprintf("- %s\n", i) } + return s } diff --git a/scripts/gen-lint/modules_black_list b/scripts/gen-lint/modules_black_list new file mode 100644 index 0000000000..6748e16e28 --- /dev/null +++ b/scripts/gen-lint/modules_black_list @@ -0,0 +1,17 @@ +bcs-scenarios/kourse +bcs-services/bcs-mesh-manager +bcs-services/bcs-api +bcs-services/bcs-alert-manager +bcs-services/bcs-log-manager +bcs-services/bcs-netservice +bcs-services/bcs-netservice/bcs-ipam +bcs-services/bcs-argocd-manager +bcs-services/bcs-client +bcs-runtime/bcs-k8s/kubebkbcs +bcs-runtime/bcs-k8s/kubedeprecated +bcs-runtime/bcs-k8s/bcs-component/bcs-k8s-driver +bcs-runtime/bcs-mesos/mesosv2 +bcs-runtime/bcs-mesos/bmsf-mesh +bcs-runtime/bcs-mesos/kubebkbcsv2 +bcs-runtime/bcs-mesos/bcs-clb-controller +bcs-runtime/bcs-mesos/bcs-scheduler \ No newline at end of file