Skip to content

Commit

Permalink
feat: bcs-monitor rest 泛型优化
Browse files Browse the repository at this point in the history
  • Loading branch information
LidolLxf committed Feb 21, 2025
1 parent 64f4eaa commit e7fee4d
Show file tree
Hide file tree
Showing 30 changed files with 1,518 additions and 760 deletions.
54 changes: 27 additions & 27 deletions bcs-services/bcs-monitor/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ require (
github.com/chonla/format v0.0.0-20220105105701-1119f4a3f36f
github.com/dustin/go-humanize v1.0.0
github.com/fsnotify/fsnotify v1.6.0
github.com/gin-contrib/cors v1.3.1
github.com/gin-contrib/requestid v0.0.4
github.com/ggicci/httpin v0.19.0
github.com/gin-contrib/sse v0.1.0
github.com/gin-gonic/gin v1.9.1
github.com/go-chi/chi/v5 v5.0.11
github.com/go-chi/render v1.0.3
github.com/go-kit/log v0.2.1
github.com/go-micro/plugins/v4/registry/etcd v1.1.0
github.com/go-redis/redis/v8 v8.11.5
Expand All @@ -36,14 +36,14 @@ require (
github.com/spf13/cobra v1.7.0
github.com/spf13/viper v1.12.0
github.com/stretchr/testify v1.9.0
github.com/swaggo/files v0.0.0-20210815190702-a29dd2bc99b2
github.com/swaggo/gin-swagger v1.4.3
github.com/swaggo/http-swagger v1.3.4
github.com/swaggo/swag v1.8.1
github.com/thanos-io/thanos v0.26.0
go-micro.dev/v4 v4.10.2
go.opentelemetry.io/contrib/instrumentation/go.mongodb.org/mongo-driver/mongo/otelmongo v0.44.0
go.opentelemetry.io/otel/metric v1.18.0
go.uber.org/automaxprocs v1.5.1
golang.org/x/sync v0.6.0
golang.org/x/sync v0.10.0
google.golang.org/grpc v1.62.1
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
Expand All @@ -59,20 +59,18 @@ require (
dario.cat/mergo v1.0.0 // indirect
github.com/TencentBlueKing/bk-audit-go-sdk v0.0.6 // indirect
github.com/TencentBlueKing/gopkg v1.1.0 // indirect
github.com/ajg/form v1.5.1 // indirect
github.com/aws/aws-sdk-go-v2 v1.21.0 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.41 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.17.0 // indirect
github.com/bytedance/sonic v1.10.2 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.1 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/frankban/quicktest v1.14.4 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
github.com/gabriel-vasile/mimetype v1.4.7 // indirect
github.com/ggicci/owl v0.8.2 // indirect
github.com/go-sql-driver/mysql v1.7.1 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang-migrate/migrate/v4 v4.17.0 // indirect
github.com/google/s2a-go v0.1.7 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.2 // indirect
Expand All @@ -81,16 +79,20 @@ require (
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
github.com/labstack/echo/v4 v4.12.0 // indirect
github.com/labstack/gommon v0.4.2 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe // indirect
github.com/onsi/ginkgo/v2 v2.11.0 // indirect
github.com/openzipkin/zipkin-go v0.3.0 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/skeema/knownhosts v1.2.2 // indirect
github.com/smartystreets/assertions v1.2.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasttemplate v1.2.2 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.2 // indirect
github.com/xdg-go/stringprep v1.0.4 // indirect
Expand All @@ -101,9 +103,7 @@ require (
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.17.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.17.0 // indirect
go.opentelemetry.io/otel/exporters/zipkin v1.3.0 // indirect
go.opentelemetry.io/otel/metric v1.18.0 // indirect
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
golang.org/x/arch v0.6.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
k8s.io/klog/v2 v2.100.1 // indirect
Expand Down Expand Up @@ -185,7 +185,6 @@ require (
github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20190605223551-bc2310a04743 // indirect
github.com/lightstep/lightstep-tracer-go v0.18.1 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/miekg/dns v1.1.50 // indirect
github.com/mitchellh/hashstructure v1.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
Expand All @@ -212,7 +211,7 @@ require (
github.com/subosito/gotenv v1.4.1 // 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/ugorji/go/codec v1.2.12 // indirect
github.com/vimeo/galaxycache v0.0.0-20210323154928-b7e5d71c067a // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
Expand All @@ -232,18 +231,18 @@ require (
go.opentelemetry.io/otel/trace v1.18.0
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/goleak v1.2.1 // indirect
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/crypto v0.31.0 // indirect
golang.org/x/mod v0.17.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/term v0.27.0 // indirect
golang.org/x/text v0.21.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.13.0 // indirect
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
google.golang.org/api v0.150.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.33.0 // indirect
google.golang.org/protobuf v1.36.1 // indirect
gopkg.in/alecthomas/kingpin.v2 v2.2.6 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand All @@ -266,10 +265,10 @@ require (
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-openapi/spec v0.20.6 // indirect
github.com/go-openapi/swag v0.21.1 // indirect
github.com/go-playground/validator/v10 v10.19.0 // indirect
github.com/go-playground/validator/v10 v10.23.0 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/urfave/cli/v2 v2.8.1 // indirect
go.uber.org/multierr v1.8.0 // indirect
Expand All @@ -287,4 +286,5 @@ replace (
github.com/vimeo/galaxycache => github.com/thanos-community/galaxycache v0.0.0-20211122094458-3a32041a1f1e
// from github.com/thanos-io/thanos
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp => go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.44.0
go.opentelemetry.io/otel/metric => go.opentelemetry.io/otel/metric v0.38.0
)
18 changes: 18 additions & 0 deletions bcs-services/bcs-monitor/pkg/api/logrule/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,19 @@ const (
bkLogPrefix = "bklog|"
)

// ListLogCollectorsReq list log collectors request
type ListLogCollectorsReq struct {
ProjectId string `in:"path=projectId;required"`
ClusterId string `in:"path=clusterId;required"`
}

// GetLogRuleReq get log rule request
type GetLogRuleReq struct {
ProjectId string `json:"-" in:"path=projectId;required"`
ClusterId string `json:"-" in:"path=clusterId;required"`
ID string `in:"path=id;required"`
}

// GetLogRuleResp log rule resp
type GetLogRuleResp struct {
ID string `json:"id"`
Expand Down Expand Up @@ -104,6 +117,8 @@ func (l GetLogRuleRespSortByStatus) Swap(i, j int) { l[i], l[j] = l[j], l[i] }

// CreateLogRuleReq req
type CreateLogRuleReq struct {
ProjectId string `json:"-" in:"path=projectId;required"`
ClusterId string `json:"-" in:"path=clusterId;required"`
DisplayName string `json:"display_name" form:"display_name"`
Name string `json:"name" form:"name" binding:"required" validate:"max=30,min=5,regexp=^[A-Za-z0-9_]+$"`
RuleName string `json:"-" form:"-"`
Expand Down Expand Up @@ -158,6 +173,9 @@ func (req *CreateLogRuleReq) toBKLog(c *rest.Context) *bklog.CreateBCSCollectorR

// UpdateLogRuleReq req
type UpdateLogRuleReq struct {
ProjectId string `json:"-" in:"path=projectId;required"`
ClusterId string `json:"-" in:"path=clusterId;required"`
ID string `json:"-" in:"path=id;required"`
DisplayName string `json:"display_name" form:"display_name"`
Description string `json:"description"`
Rule bklog.LogRule `json:"rule"`
Expand Down
Loading

0 comments on commit e7fee4d

Please sign in to comment.