Skip to content

Commit

Permalink
Update: fix webconsole perm redirect bug (merge request !1406)
Browse files Browse the repository at this point in the history
Squash merge branch 'bcs-webconsole' into 'master'
Update: remove deprecated linter
  • Loading branch information
ifooth committed Sep 6, 2023
1 parent 5aff391 commit e69957f
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 78 deletions.
2 changes: 0 additions & 2 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@ linters:
disable-all: true
enable:
# enable by default
- deadcode
- errcheck
- gosimple
- govet
- ineffassign
- staticcheck
- structcheck
- typecheck
- unused
# custom
Expand Down
3 changes: 2 additions & 1 deletion bcs-services/bcs-webconsole/console/web/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ import (
"path"

gintrace "github.com/Tencent/bk-bcs/bcs-common/pkg/otel/trace/gin"
"github.com/gin-gonic/gin"

"github.com/Tencent/bk-bcs/bcs-services/bcs-webconsole/console/config"
"github.com/Tencent/bk-bcs/bcs-services/bcs-webconsole/console/i18n"
"github.com/Tencent/bk-bcs/bcs-services/bcs-webconsole/console/metrics"
"github.com/Tencent/bk-bcs/bcs-services/bcs-webconsole/console/podmanager"
"github.com/Tencent/bk-bcs/bcs-services/bcs-webconsole/console/tracing"
"github.com/Tencent/bk-bcs/bcs-services/bcs-webconsole/route"
"github.com/gin-gonic/gin"
)

type service struct {
Expand Down
13 changes: 10 additions & 3 deletions bcs-services/bcs-webconsole/console/web/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ package web
import (
"net/http"

"github.com/gin-gonic/gin"

"github.com/Tencent/bk-bcs/bcs-services/bcs-webconsole/console/api"
"github.com/Tencent/bk-bcs/bcs-services/bcs-webconsole/console/components/bcs"
"github.com/Tencent/bk-bcs/bcs-services/bcs-webconsole/console/components/iam"
"github.com/Tencent/bk-bcs/bcs-services/bcs-webconsole/console/config"
"github.com/Tencent/bk-bcs/bcs-services/bcs-webconsole/console/i18n"
"github.com/Tencent/bk-bcs/bcs-services/bcs-webconsole/route"

"github.com/gin-gonic/gin"
)

// UserPermRequestRedirect 用户权限申请URL
Expand All @@ -32,8 +34,13 @@ func (s *service) UserPermRequestRedirect(c *gin.Context) {
api.APIError(c, i18n.GetMessage(c, "project_id is required"))
return
}
project, err := bcs.GetProject(c.Request.Context(), config.G.BCS, projectId)
if err != nil {
api.APIError(c, i18n.GetMessage(c, "项目不正确"))
return
}

redirectUrl, err := iam.MakeResourceApplyUrl(c.Request.Context(), projectId, clusterId, route.GetNamespace(c), "")
redirectUrl, err := iam.MakeResourceApplyUrl(c.Request.Context(), project.ProjectId, clusterId, route.GetNamespace(c), "")
if err != nil {
api.APIError(c, i18n.GetMessage(c, err.Error()))
return
Expand Down
47 changes: 27 additions & 20 deletions bcs-services/bcs-webconsole/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ module github.com/Tencent/bk-bcs/bcs-services/bcs-webconsole
go 1.20

require (
github.com/Tencent/bk-bcs/bcs-common v0.0.0-20230607093333-1f5cd2719e19
github.com/Tencent/bk-bcs/bcs-common/pkg/otel v0.0.0-20230802065941-49e19e258f38
github.com/Tencent/bk-bcs/bcs-services/pkg v0.0.0-20220926153300-4e631deaebe4
github.com/TencentBlueKing/iam-go-sdk v0.0.8
github.com/Tencent/bk-bcs/bcs-common v0.0.0-20230906015939-61de9e6ddee9
github.com/Tencent/bk-bcs/bcs-common/pkg/auth v0.0.0-20230906015939-61de9e6ddee9
github.com/Tencent/bk-bcs/bcs-common/pkg/otel v0.0.0-20230906015939-61de9e6ddee9
github.com/Tencent/bk-bcs/bcs-services/pkg v0.0.0-20230906015939-61de9e6ddee9
github.com/TencentBlueKing/iam-go-sdk v0.1.4
github.com/dustin/go-humanize v1.0.0
github.com/gin-contrib/cors v1.3.1
github.com/gin-contrib/i18n v0.0.1
Expand All @@ -26,29 +27,31 @@ require (
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/pborman/ansi v1.0.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.11.1
github.com/prometheus/client_golang v1.14.0
github.com/prometheus/prometheus v1.8.2-0.20200811193703-869f1bc587e6
github.com/stretchr/testify v1.8.2
github.com/urfave/cli/v2 v2.3.0
go-micro.dev/v4 v4.10.2
go.opentelemetry.io/otel v1.14.0
go.opentelemetry.io/otel/trace v1.14.0
golang.org/x/sync v0.1.0
golang.org/x/sync v0.2.0
golang.org/x/text v0.9.0
google.golang.org/grpc v1.54.0
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.23.1
k8s.io/apimachinery v0.23.1
k8s.io/client-go v0.23.1
k8s.io/klog/v2 v2.90.1
k8s.io/klog/v2 v2.100.1
sigs.k8s.io/yaml v1.2.0
)

require (
github.com/BurntSushi/toml v1.1.0 // indirect
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20220824120805-4b6e5c587895 // indirect
github.com/TencentBlueKing/bk-audit-go-sdk v0.0.5 // indirect
github.com/TencentBlueKing/gopkg v1.1.0 // indirect
github.com/acomagu/bufpipe v1.0.3 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bitly/go-simplejson v0.5.0 // indirect
Expand Down Expand Up @@ -76,26 +79,30 @@ require (
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.11.2 // indirect
github.com/go-sql-driver/mysql v1.7.1 // indirect
github.com/goccy/go-json v0.10.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang-migrate/migrate/v4 v4.16.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/googleapis/gnostic v0.5.5 // indirect
github.com/gosimple/unidecode v1.0.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.3 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kevinburke/ssh_config v1.2.0 // indirect
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/leodido/go-urn v1.2.2 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/miekg/dns v1.1.50 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/hashstructure v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/moby/spdystream v0.2.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
Expand All @@ -105,12 +112,12 @@ require (
github.com/parnurzeal/gorequest v0.2.16 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.30.0 // indirect
github.com/prometheus/procfs v0.7.3 // 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.1.0 // indirect
github.com/sergi/go-diff v1.2.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.9 // indirect
Expand All @@ -129,14 +136,14 @@ require (
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.17.0 // indirect
golang.org/x/arch v0.0.0-20210923205945-b76863e36670 // indirect
golang.org/x/crypto v0.5.0 // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/crypto v0.7.0 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/net v0.10.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/term v0.7.0 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/term v0.8.0 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
golang.org/x/tools v0.7.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-20230526161137-0005af68ea54 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230525234035-dd9d682886f9 // indirect
Expand Down
Loading

0 comments on commit e69957f

Please sign in to comment.