Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for show ComapctionTasks #275

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.49
version: v1.55.2

# Optional: working directory, useful for monorepos
# working-directory: somedir
Expand Down
86 changes: 76 additions & 10 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,86 @@
run:
go: "1.21"
skip-dirs:
- bin
- configs
- deployments
- docs
- scripts
- internal/core
build-tags:
- "WKAFKA"
skip-files:
- main.go

linters:
disable-all: true
enable:
- typecheck
- goimports
- misspell
- gosimple
- govet
- ineffassign
- gosimple
- staticcheck
- decorder
- gofmt
- goimports
- gosec
- revive
- unconvert
- misspell
- typecheck
- durationcheck
- gci
- whitespace
- gofumpt
- gocritic

linters-settings:
gci:
sections:
- standard
- default
- prefix(github.com/milvus-io)
custom-order: true
gofumpt:
lang-version: "1.18"
module-path: github.com/milvus-io
goimports:
local-prefixes: github.com/milvus-io
revive:
rules:
- name: unused-parameter
disabled: true
- name: var-naming
severity: warning
disabled: false
arguments:
- ["ID"] # Allow list
- name: context-as-argument
severity: warning
disabled: false
arguments:
- allowTypesBefore: "*testing.T"
- name: datarace
severity: warning
disabled: false
- name: duplicated-imports
severity: warning
disabled: false
- name: waitgroup-by-value
severity: warning
disabled: false
- name: indent-error-flow
severity: warning
disabled: false
arguments:
- "preserveScope"
- name: range-val-in-closure
severity: warning
disabled: false
- name: range-val-address
severity: warning
disabled: false
- name: string-of-int
severity: warning
disabled: false
misspell:
locale: US
gocritic:
Expand All @@ -42,24 +101,31 @@ issues:
- which can be annoying to use
# Binds to all network interfaces
- G102
# Use of unsafe calls should be audited
- G103
# Errors unhandled
- G104
# file/folder Permission
- G301
- G302
# Potential file inclusion via variable
- G304
# Deferring unsafe method like *os.File Close
# Deferring unsafe method like *os.File Close
- G307
# TLS MinVersion too low
- G402
# Use of weak random number generator math/rand
- G404
# Exclude copylocks
- copylocks
# Unused parameters
- SA1019
# defer return errors
- SA5001

# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-issues-per-linter: 0
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
max-same-issues: 0

service:
golangci-lint-version: 1.27.0 # use the fixed version to not introduce new linters unexpectedly

# use the fixed version to not introduce new linters unexpectedly
golangci-lint-version: 1.55.2
51 changes: 47 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
GO ?= go

all: static-check birdwatcher
INSTALL_PATH := $(PWD)/bin
GOLANGCI_LINT_VERSION := 1.55.2
GOLANGCI_LINT_OUTPUT := $(shell $(INSTALL_PATH)/golangci-lint --version 2>/dev/null)
INSTALL_GOLANGCI_LINT := $(findstring $(GOLANGCI_LINT_VERSION), $(GOLANGCI_LINT_OUTPUT))

# gci
GCI_VERSION := 0.11.2
GCI_OUTPUT := $(shell $(INSTALL_PATH)/gci --version 2>/dev/null)
INSTALL_GCI := $(findstring $(GCI_VERSION),$(GCI_OUTPUT))


GOFUMPT_VERSION := 0.5.0
GOFUMPT_OUTPUT := $(shell $(INSTALL_PATH)/gofumpt --version 2>/dev/null)
INSTALL_GOFUMPT := $(findstring $(GOFUMPT_VERSION),$(GOFUMPT_OUTPUT))

all: static-check birdwatcher

birdwatcher:
@echo "Compiling birdwatcher"
Expand All @@ -12,7 +27,35 @@ birdwatcher_wkafka:
@mkdir -p bin
@CGO_ENABLED=1 go build -o bin/birdwatcher_wkafka -tags WKAFKA main.go

static-check:
getdeps:
@mkdir -p $(INSTALL_PATH)
@if [ -z "$(INSTALL_GOLANGCI_LINT)" ]; then \
echo "Installing golangci-lint into ./bin/" && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(INSTALL_PATH) v${GOLANGCI_LINT_VERSION} ; \
else \
echo "golangci-lint v@$(GOLANGCI_LINT_VERSION) already installed"; \
fi

static-check: getdeps
@echo "Running static-check"
@golangci-lint cache clean
@golangci-lint run --timeout=10m --config ./.golangci.yml ./...
@$(INSTALL_PATH)/golangci-lint cache clean
@$(INSTALL_PATH)/golangci-lint run --timeout=10m --config ./.golangci.yml ./...

lint-fix: getdeps
@mkdir -p $(INSTALL_PATH)
@if [ -z "$(INSTALL_GCI)" ]; then \
echo "Installing gci v$(GCI_VERSION) to ./bin/" && GOBIN=$(INSTALL_PATH) go install github.com/daixiang0/gci@v$(GCI_VERSION); \
else \
echo "gci v$(GCI_VERSION) already installed"; \
fi
@if [ -z "$(INSTALL_GOFUMPT)" ]; then \
echo "Installing gofumpt v$(GOFUMPT_VERSION) to ./bin/" && GOBIN=$(INSTALL_PATH) go install mvdan.cc/gofumpt@v$(GOFUMPT_VERSION); \
else \
echo "gofumpt v$(GOFUMPT_VERSION) already installed"; \
fi
@echo "Running gofumpt fix"
@$(INSTALL_PATH)/gofumpt -l -w ./
@echo "Running gci fix"
@$(INSTALL_PATH)/gci write ./ --skip-generated -s standard -s default -s "prefix(github.com/milvus-io)" --custom-order
@echo "Running golangci-lint auto-fix"
@$(INSTALL_PATH)/golangci-lint cache clean
@$(INSTALL_PATH)/golangci-lint run --fix --timeout=30m --config ./.golangci.yml;
4 changes: 2 additions & 2 deletions bapps/go_prompt.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import (
"time"

"github.com/c-bata/go-prompt"
"github.com/samber/lo"

"github.com/milvus-io/birdwatcher/configs"
"github.com/milvus-io/birdwatcher/history"
"github.com/milvus-io/birdwatcher/states"
"github.com/samber/lo"
)

// PromptApp wraps go-prompt as application.
Expand Down Expand Up @@ -151,7 +152,6 @@ func (a *PromptApp) promptExecute(in string) {

// completeInput auto-complete logic entry.
func (a *PromptApp) completeInput(d prompt.Document) []prompt.Suggest {

input := d.CurrentLineBeforeCursor()
if a.sugguestHistory {
return a.historySuggestions(input)
Expand Down
3 changes: 2 additions & 1 deletion bapps/olc.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (
"os"
"strings"

"github.com/milvus-io/birdwatcher/states"
"github.com/samber/lo"

"github.com/milvus-io/birdwatcher/states"
)

type olcApp struct {
Expand Down
1 change: 1 addition & 0 deletions bapps/promptui.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"

"github.com/manifoldco/promptui"

"github.com/milvus-io/birdwatcher/states"
)

Expand Down
5 changes: 2 additions & 3 deletions bapps/webserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"strings"

"github.com/gin-gonic/gin"

"github.com/milvus-io/birdwatcher/common"
"github.com/milvus-io/birdwatcher/configs"
"github.com/milvus-io/birdwatcher/framework"
Expand Down Expand Up @@ -103,7 +104,7 @@ func (app *WebServerApp) parseMethod(r *gin.Engine, mt reflect.Method, name stri
}
}

//fmt.Println(mt.Name)
// fmt.Println(mt.Name)
cp := reflect.New(paramType.Elem()).Interface().(framework.CmdParam)
fUse, _ := states.GetCmdFromFlag(cp)
if len(use) == 0 {
Expand All @@ -124,13 +125,11 @@ func (app *WebServerApp) parseMethod(r *gin.Engine, mt reflect.Method, name stri
// fmt.Printf("path: /%s\n", lastKw)

r.GET(fmt.Sprintf("/%s", lastKw), func(c *gin.Context) {

info := &InstanceInfo{}
c.ShouldBind(info)

start := states.Start(app.config)
s, err := start.Process(fmt.Sprintf("connect --etcd=%s --rootPath=%s", info.EtcdAddr, info.RootPath))

if err != nil {
c.Error(err)
return
Expand Down
1 change: 0 additions & 1 deletion configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ func (c *Config) createDefault() error {
}

file, err := os.Create(c.getConfigPath())

if err != nil {
return err
}
Expand Down
14 changes: 6 additions & 8 deletions framework/resultset.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@ const (
FormatTable
)

var (
name2Format = map[string]Format{
"default": FormatDefault,
"plain": FormatPlain,
"json": FormatJSON,
"table": FormatTable,
}
)
var name2Format = map[string]Format{
"default": FormatDefault,
"plain": FormatPlain,
"json": FormatJSON,
"table": FormatTable,
}

// ResultSet is the interface for command result set.
type ResultSet interface {
Expand Down
2 changes: 1 addition & 1 deletion history/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func NewHistoryHelper(filePath string) *Helper {
readFile.Close()
}
// open file and create if non-existent
hFile, err := os.OpenFile(filePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
hFile, err := os.OpenFile(filePath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644)
if err != nil {
fmt.Println("[WARN] failed to open history file", err.Error())
}
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func main() {
var appFactory func(config *configs.Config) bapps.BApp

switch {
//Print current birdwatcher version
// Print current birdwatcher version
case *printVersion:
fmt.Println("Birdwatcher Version", common.Version)
return
Expand All @@ -41,7 +41,7 @@ func main() {
default:
defer handleExit()
// open file and create if non-existent
file, err := os.OpenFile("bw_debug.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
file, err := os.OpenFile("bw_debug.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644)
if err != nil {
log.Fatal(err)
}
Expand Down
3 changes: 2 additions & 1 deletion models/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ import (
"strings"
"sync"

"github.com/samber/lo"

"github.com/milvus-io/birdwatcher/proto/v2.0/commonpb"
"github.com/milvus-io/birdwatcher/proto/v2.0/etcdpb"
"github.com/milvus-io/birdwatcher/proto/v2.0/schemapb"
commonpbv2 "github.com/milvus-io/birdwatcher/proto/v2.2/commonpb"
etcdpbv2 "github.com/milvus-io/birdwatcher/proto/v2.2/etcdpb"
schemapbv2 "github.com/milvus-io/birdwatcher/proto/v2.2/schemapb"
"github.com/samber/lo"
)

// Collection model for collection information.
Expand Down
Loading
Loading