-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ab2f285
Showing
2,367 changed files
with
363,242 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
source: | ||
# 文件或目录使用绝对路径,绝对路径按代码库根目录计算,以/开头。 | ||
# 提供产品代码库中编写的测试代码存放目录或文件名格式,以便代码检查时进行排除处理 | ||
# */等正则表达式屏蔽掉所有代码,会使得代码存在风险,还会导致Coverity扫不到任何代码而失败 | ||
test_source: | ||
#用于匹配文件; 匹配方式为正则表达式,例如[".*/java/test/.*", ".*/test.java"] | ||
filepath_regex: | ||
# 提供产品代码库中工具或框架自动生成的且在代码库中的代码,没有可为空。以便代码检查时进行排除处理。 | ||
auto_generate_source: | ||
# 自动生成代码文件的正则表达式,若无统一标识格式,可以指定具体目录,样例可参考test_source举例 | ||
filepath_regex: | ||
- "./docs/.*" | ||
- ".*/.*_gen\.go" | ||
- ".*/.*\.pb\.go" | ||
# 提供产品代码库中直接以源码形式存在的第三方代码目录或代码文件名的正则表达。 | ||
# 此处备注的第三方代码将在代码检查时进行排除,若代码库中不存在需要排除的第三方代码,该项配置标识可为空 | ||
third_party_source: | ||
#第三方代码文件的正则表达式,若无统一标识格式,可以指定具体目录,样例可参考test_source举例 | ||
filepath_regex: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# IDE | ||
*.DS_Store | ||
.idea/ | ||
.vscode/ | ||
__pycache__/ | ||
.codecc/ | ||
build.yml | ||
dist/ | ||
|
||
go.work | ||
go.work.sum | ||
|
||
*_tmp | ||
.codecc | ||
.idea | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# Tencent is pleased to support the open source community by making | ||
# 蓝鲸智云 - 监控平台 (BlueKing - Monitor) available. | ||
# Copyright (C) 2022 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. | ||
|
||
# 完整版本在 https://golangci-lint.run/usage/configuration/ | ||
linters-settings: | ||
funlen: | ||
lines: 80 | ||
statements: 80 | ||
goconst: | ||
min-len: 3 | ||
min-occurrences: 3 | ||
gocyclo: | ||
min-complexity: 40 | ||
revive: | ||
confidence: 0 | ||
rules: | ||
- name: var-declaration | ||
- name: package-comments | ||
- name: dot-imports | ||
- name: blank-imports | ||
- name: exported | ||
- name: var-naming | ||
- name: indent-error-flow | ||
- name: range | ||
- name: errorf | ||
- name: error-naming | ||
- name: error-strings | ||
- name: receiver-naming | ||
- name: increment-decrement | ||
- name: error-return | ||
- name: unexported-return | ||
- name: time-naming | ||
- name: context-keys-type | ||
- name: context-as-argument | ||
govet: | ||
check-shadowing: true | ||
lll: | ||
line-length: 120 | ||
errcheck: | ||
check-type-assertions: true | ||
gocritic: | ||
enabled-checks: | ||
- nestingReduce | ||
- commentFormatting | ||
settings: | ||
nestingReduce: | ||
bodyWidth: 5 | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- goconst | ||
- gocyclo | ||
- gofmt | ||
- ineffassign | ||
- staticcheck | ||
- typecheck | ||
- goimports | ||
- gosimple | ||
- unused | ||
- gocritic | ||
|
||
run: | ||
timeout: 20m | ||
skip-files: | ||
- ".*_test\\.go$" | ||
|
||
issues: | ||
exclude-use-default: true | ||
|
||
# The list of ids of default excludes to include or disable. By default it's empty. | ||
include: | ||
- EXC0004 # govet (possible misuse of unsafe.Pointer|should have signature) | ||
- EXC0005 # staticcheck ineffective break statement. Did you mean to break out of the outer loop | ||
- EXC0012 # revive exported (method|function|type|const) (.+) should have comment or be unexported | ||
- EXC0013 # revive package comment should be of the form "(.+)... | ||
- EXC0014 # revive comment on exported (.+) should be of the form "(.+)..." | ||
- EXC0015 # revive should have a package comment, unless it's in another file for this package | ||
|
||
exclude-rules: | ||
- linters: | ||
- staticcheck | ||
text: "SA6002: argument should be pointer-like to avoid allocations" # sync.pool.Put(buf), slice `var buf []byte` will tiger this | ||
- linters: | ||
- lll | ||
source: "^//go:generate " # Exclude lll issues for long lines with go:generate | ||
|
||
max-same-issues: 0 | ||
new: false | ||
max-issues-per-linter: 0 | ||
|
||
output: | ||
sort-results: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# See https://pre-commit.com for more information | ||
# See https://pre-commit.com/hooks.html for more hooks | ||
default_stages: [ commit ] | ||
default_install_hook_types: [ pre-commit, commit-msg ] | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.3.0 | ||
hooks: | ||
- id: check-merge-conflict | ||
- id: detect-private-key | ||
- repo: local | ||
hooks: | ||
# 提交前,需要检查提交 message | ||
- id: check-commit-message | ||
name: Check commit message | ||
entry: python3 scripts/pre_commit/check_commit_message.py | ||
language: system | ||
stages: [ commit-msg ] | ||
verbose: true | ||
|
||
# 提交前检查敏感 IP 信息 | ||
- id: ip | ||
name: Check ip | ||
description: Check ip | ||
entry: scripts/pre_commit/sensitive_info_check/ip.sh | ||
language: script | ||
verbose: true | ||
files: "" | ||
|
||
# 提交前检查文件是否已经带上版权信息头,但是不做强制修改 | ||
# go install github.com/google/addlicense@latest | ||
- id: check-license | ||
name: check license header | ||
entry: scripts/pre_commit/check_license.sh | ||
language: script | ||
verbose: true | ||
files: "(.*\\.go|.*\\.sh|.*\\.py)$" | ||
|
||
# 提交前执行 gofmt 格式化文件 | ||
- id: gofmt | ||
name: go format files | ||
entry: scripts/pre_commit/gofmt.sh | ||
language: script | ||
verbose: true | ||
files: ".*\\.go$" | ||
|
||
# goimports-reviser,检查 import 的顺序格式化 | ||
- id: goimports-reviser | ||
name: go import checks | ||
entry: scripts/pre_commit/goimport.sh | ||
language: script | ||
verbose: true | ||
files: ".*\\.go" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021~2022 腾讯蓝鲸 | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
PWD = $(shell pwd) | ||
MODULES ?= bkmonitorbeat collector operator transfer unify-query influxdb-proxy ingester offline-data-archive bk-monitor-worker | ||
RELEASE_PATH ?= $(PWD)/dist | ||
BUILD_NO ?= 1 | ||
COMMIT_ID = $(shell git rev-parse HEAD) | ||
MODULE = '' | ||
RELEASE ?= false | ||
|
||
MODULE_VERSION = $(subst v,ee-V, $(shell cat $(PWD)/pkg/$(MODULE)/VERSION||echo '')) | ||
BRANCH ?= $(shell git symbolic-ref --short HEAD) | ||
|
||
ifeq ($(RELEASE), true) | ||
PACKAGE_VERSION = $(MODULE_VERSION) | ||
else | ||
PACKAGE_VERSION = $(MODULE_VERSION)-$(BRANCH) | ||
endif | ||
|
||
VERSION = $(subst v,,$(subst x,$(BUILD_NO),$(shell cat $(PWD)/pkg/$(MODULE)/VERSION || echo ''))) | ||
TAG = pkg/$(MODULE)/v$(VERSION) | ||
PIP_PATH ?= $(shell which pip) | ||
|
||
.PHONY: all | ||
all: bkmonitorbeat collector operator transfer unify-query influxdb-proxy ingester offline-data-archive bk-monitor-worker | ||
|
||
.PHONY: .check_module_vars | ||
.check_module_vars: | ||
@test $${MODULE?Please set environment variable MODULE} | ||
|
||
.PHONY: build | ||
build: .check_module_vars | ||
mkdir -p $(RELEASE_PATH)/$(MODULE) | ||
@echo make module: $(MODULE) BUILD_NO: $(BUILD_NO) COMMIT_ID: $(COMMIT_ID) | ||
cd $(PWD)/pkg/$(MODULE) && make RELEASE_PATH=$(RELEASE_PATH)/$(MODULE) VERSION=$(VERSION) BUILD_NO=$(BUILD_NO) COMMIT_ID=$(COMMIT_ID) build | ||
|
||
.PHONY: bkmonitorbeat | ||
bkmonitorbeat: | ||
$(MAKE) MODULE=bkmonitorbeat build | ||
|
||
.PHONY: collector | ||
collector: | ||
$(MAKE) MODULE=collector build | ||
|
||
.PHONY: operator | ||
operator: | ||
$(MAKE) MODULE=operator build | ||
|
||
.PHONY: transfer | ||
transfer: | ||
$(MAKE) MODULE=transfer build | ||
|
||
.PHONY: unify-query | ||
unify-query: | ||
$(MAKE) MODULE=unify-query build | ||
|
||
.PHONY: influxdb-proxy | ||
influxdb-proxy: | ||
$(MAKE) MODULE=influxdb-proxy build | ||
|
||
.PHONY: ingester | ||
ingester: | ||
$(MAKE) MODULE=ingester build | ||
|
||
.PHONY: offline-data-archive | ||
offline-data-archive: | ||
$(MAKE) MODULE=offline-data-archive build | ||
|
||
.PHONY: bk-monitor-worker | ||
bk-monitor-worker: | ||
$(MAKE) MODULE=bk-monitor-worker build | ||
|
||
.PHONY: version | ||
version: .check_module_vars | ||
@echo $(VERSION) | ||
|
||
.PHONY: package_version | ||
package_version: | ||
@echo $(PACKAGE_VERSION) | ||
|
||
.PHONY: tag | ||
tag: .check_module_vars | ||
cd $(PWD)/pkg/$(MODULE) || exit 1 | ||
@echo tag: $(TAG) | ||
git tag $(TAG) | ||
git push --tags | ||
|
||
.PHONY: lint | ||
lint: | ||
cd $(PWD)/pkg/$(MODULE) && make lint | ||
|
||
.PHONY: test | ||
test: | ||
cd $(PWD)/pkg/$(MODULE) && make test | ||
|
||
.PHONY: fmt | ||
fmt: | ||
cd $(PWD)/pkg/$(MODULE) && go fmt ./... | ||
|
||
.PHONY: debug | ||
debug: .check_module_vars | ||
mkdir -p $(RELEASE_PATH)/$(MODULE) | ||
@echo make module: $(MODULE) BUILD_NO: $(BUILD_NO) COMMIT_ID: $(COMMIT_ID) | ||
cd $(PWD)/pkg/$(MODULE) && make RELEASE_PATH=$(RELEASE_PATH)/$(MODULE) VERSION=$(VERSION) BUILD_NO=$(BUILD_NO) COMMIT_ID=$(COMMIT_ID) debug | ||
|
||
.PHONY: pre-commit | ||
pre-commit: | ||
pre-commit run -a | ||
|
||
.check_pip_vars: | ||
@test $(PIP_PATH)||(echo 'pip command or PIP_PATH not found'&&exit 1) | ||
|
||
.PHONY: pre-commit-install | ||
pre-commit-install: .check_pip_vars | ||
$(PIP_PATH) install -U pre-commit | ||
go install github.com/google/addlicense@latest | ||
go install github.com/incu6us/goimports-reviser/v3@latest | ||
pre-commit clean | ||
pre-commit install | ||
|
||
.PHONY: addlicense | ||
addlicense: | ||
find ./ -type f \( -iname \*.go -o -iname \*.py -iname \*.sh \)|xargs addlicense -v -f scripts/license.txt -ignore vendor/* | ||
|
||
.PHONY: imports | ||
imports: addlicense | ||
goimports-reviser -project-name "github.com/TencentBlueKing/bkmonitor-datalink/pkg" ./... |
Oops, something went wrong.