Skip to content

Commit

Permalink
feat: 服务管理页面添加“配置客户端”引导--story=119561674 (#3502)
Browse files Browse the repository at this point in the history
* fix: 配置文件绝对路径问题优化

* fix: 顶栏下拉框国际化内容调整

* feat: 服务管理页面添加“配置客户端”引导

* fix: 键值型配置已生成版本不支持编辑
  • Loading branch information
Ambition9186 authored and AlkaidChan committed Sep 25, 2024
1 parent 247b59f commit 997ac50
Show file tree
Hide file tree
Showing 8 changed files with 623 additions and 485 deletions.
2 changes: 2 additions & 0 deletions bcs-services/bcs-bscp/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ replace github.com/go-resty/resty/v2 => github.com/ifooth/resty/v2 v2.0.0-202302
require (
github.com/Tencent/bk-bcs/bcs-common v0.0.0-20240418123107-72b120390195
github.com/TencentBlueKing/iam-go-sdk v0.1.6
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394
github.com/bluele/gcache v0.0.2
github.com/dustin/go-humanize v1.0.1
github.com/go-chi/chi/v5 v5.0.10
Expand All @@ -32,6 +33,7 @@ require (
github.com/panjf2000/ants/v2 v2.8.2
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.19.0
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d
github.com/samber/lo v1.39.0
github.com/shimingyah/pool v1.0.0
github.com/sirupsen/logrus v1.9.3
Expand Down
4 changes: 4 additions & 0 deletions bcs-services/bcs-bscp/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj
github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI=
github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394 h1:OYA+5W64v3OgClL+IrOD63t4i/RW7RqrAVl9LTZ9UqQ=
github.com/axgle/mahonia v0.0.0-20180208002826-3358181d7394/go.mod h1:Q8n74mJTIgjX4RBBcHnJ05h//6/k6foqmgE45jTQtxg=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
Expand Down Expand Up @@ -582,6 +584,8 @@ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk=
github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc=
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d h1:hrujxIzL1woJ7AwssoOcM/tq5JjjG2yYOc8odClEiXA=
github.com/saintfish/chardet v0.0.0-20230101081208-5e3ef4b5456d/go.mod h1:uugorj2VCxiV1x+LzaIdVa9b4S4qGAcH6cbhh4qVxOU=
github.com/samber/lo v1.39.0 h1:4gTz1wUhNYLhFSKl6O+8peW0v2F4BCY034GRpU9WnuA=
github.com/samber/lo v1.39.0/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA=
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 h1:n661drycOFuPLCN3Uc8sB6B/s6Z4t2xvBgU1htSHuq8=
Expand Down
41 changes: 11 additions & 30 deletions bcs-services/bcs-bscp/pkg/criteria/validator/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,49 +25,30 @@ import (
"github.com/TencentBlueKing/bk-bcs/bcs-services/bcs-bscp/pkg/kit"
)

// validUnixFileSubPathRegexp sub path support character:
// chinese, english, number, '-', '_', '#', '%', ',', '@', '^', '+', '=', '[', ']', '{', '}, '.'
var validUnixFileSubPathRegexp = regexp.MustCompile("^[\u4e00-\u9fa5A-Za-z0-9-_#%,.@^+=\\[\\]{}]+$")

// ValidateUnixFilePath validate unix os file path.
func ValidateUnixFilePath(kit *kit.Kit, path string) error {
if len(path) < 1 {
return errf.Errorf(errf.InvalidArgument, i18n.T(kit, "invalid path, length should >= 1"))
return errf.Errorf(errf.InvalidArgument, i18n.T(kit, "invalid path %s, length should >= 1", path))
}

if len(path) > 1024 {
return errf.Errorf(errf.InvalidArgument, i18n.T(kit, "invalid path, length should <= 1024"))
return errf.Errorf(errf.InvalidArgument, i18n.T(kit, "invalid path %s, length should <= 1024", path))
}

// 1. should start with '/'
// 1. 检查是否以 '/' 开头
if !strings.HasPrefix(path, "/") {
return errf.Errorf(errf.InvalidArgument, i18n.T(kit, "invalid path, should start with '/'"))
return errf.Errorf(errf.InvalidArgument, i18n.T(kit, "invalid path %s, the path must start with '/'", path))
}

// Split the path into parts
parts := strings.Split(path, "/")[1:] // Ignore the first empty part due to the leading '/'

if strings.HasSuffix(path, "/") {
parts = parts[:len(parts)-1] // Ignore the last empty part due to the trailing '/'
// 2. 检查是否包含连续的 '/'
if strings.Contains(path, "//") {
return errf.Errorf(errf.InvalidArgument, i18n.T(kit, "invalid path %s, the path"+
"cannot contain consecutive '/'", path))
}

// Iterate over each part to validate
for _, part := range parts {

// 2. the verification path cannot all be '{'. '}'
if dotsRegexp.MatchString(part) {
return errf.Errorf(errf.InvalidArgument, i18n.T(kit, "invalid path %s, path cannot all be '.' ", part))
}

// 3. each sub path support character:
// chinese, english, number, '-', '_', '#', '%', ',', '@', '^', '+', '=', '[', ']', '{', '}'
if !validUnixFileSubPathRegexp.MatchString(part) {
return errf.Errorf(errf.InvalidArgument, i18n.T(kit, fmt.Sprintf(`invalid path, each sub path should only
contain chinese, english, number, '-', '_', '#', '%%', ',', '@', '^', '+', '=', '[', ']', '{', '}', '{'. '}`)))
}

// 4. each sub path should be separated by '/'
// (handled by strings.Split above)
// 3. 检查是否以 '/' 结尾(除非是根路径)
if len(path) > 1 && strings.HasSuffix(path, "/") {
return errf.Errorf(errf.InvalidArgument, i18n.T(kit, "invalid path %s, the path cannot end with '/'", path))
}

return nil
Expand Down
Loading

0 comments on commit 997ac50

Please sign in to comment.