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

fix: 创建前检测非模板配置和模板配置是否存在冲突 --bug=122816798 #3124

Merged

Conversation

Ambition9186
Copy link
Contributor

No description provided.

@Ambition9186 Ambition9186 changed the title fix: 创建前检测非模板配置和模板配置是否存在冲突 fix: 创建前检测非模板配置和模板配置是否存在冲突 --bug=122816798 Apr 15, 2024
@Ambition9186 Ambition9186 reopened this Apr 15, 2024
@AlkaidChan AlkaidChan added the bcs-bscp feature or bugfix for bscp label Apr 17, 2024
@Ambition9186 Ambition9186 force-pushed the hotfix/config_item_duplicates branch 2 times, most recently from 8b3da64 to b5f2c30 Compare April 24, 2024 09:42
@Ambition9186 Ambition9186 force-pushed the hotfix/config_item_duplicates branch from b5f2c30 to d592912 Compare May 8, 2024 02:27
Comment on lines 302 to 299
fileDir = strings.Replace(path, rootDir, "", 1)
fileDir = strings.ReplaceAll(fileDir, "\\", "/")
lastSlashIndex := strings.LastIndex(fileDir, "/")
if lastSlashIndex >= 0 {
fileDir = fileDir[:lastSlashIndex]
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里做的事情应该是以下几步吧:

  1. 获取相对路径
  2. 统一分隔符为 '/'
  3. 获取文件的父目录

可以直接用内置函数来解决,可读性比较强

fileDir = filepath.Rel(fileDir, path)
fileDir = strings.ReplaceAll(fileDir, "\\", "/")
fileDir = filepath.Dir(fileDir)

for _, v2 := range b {
path2 := path.Join(v2.Path, v2.Name)
if path1 == path2 {
continue
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

反了吧,应该是 path1 == path2 就直接报错冲突了吧

@@ -38,6 +39,20 @@ func (s *Service) CreateRelease(ctx context.Context, req *pbcs.CreateReleaseReq)
return nil, err
}

// 创建版本前验证非模板配置和模板配置是否存在冲突
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在 GenerateReleaseAndPublish 接口也加上这个判断

// validate in table config_items
if _, err := s.dao.ConfigItem().GetByUniqueKey(grpcKit, req.ConfigItemAttachment.BizId,
req.ConfigItemAttachment.AppId, req.ConfigItemSpec.Name, req.ConfigItemSpec.Path); err == nil {
if tools.CheckPathConflict(path.Join(req.ConfigItemSpec.Path, req.ConfigItemSpec.Name), existingPaths) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BatchUpsertConfigItems 也要加上这个逻辑,这两个接口也要考虑下会不会导致路径冲突
image

return
}

// 获取服务下某个空间下的所有套餐
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里应该是获取空间下的所有模板吧,和服务、套餐没关系

Comment on lines 466 to 468
// getAllConfigFileByApp 获取服务下的配置项以及关联后的空间模板配置
func (c *configImport) getAllConfigFileByApp(kt *kit.Kit, newFiles []types.CIUniqueKey) error {
// 获取服务下所有配置模板
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这两个注释都不对吧,这里应该是获取服务下的所有非模板配置

@Ambition9186 Ambition9186 force-pushed the hotfix/config_item_duplicates branch 3 times, most recently from 5060dc7 to 733aa86 Compare May 14, 2024 05:54
@Ambition9186 Ambition9186 force-pushed the hotfix/config_item_duplicates branch from 733aa86 to a4de386 Compare May 14, 2024 07:08
@AlkaidChan AlkaidChan merged commit d3c36fa into TencentBlueKing:master May 14, 2024
11 checks passed
wenxinlee2015 added a commit that referenced this pull request May 16, 2024
* github-bk-bcs/master:
  fix: 客户端体验问题优化 (#3200)
  refactor: 文件型配置表格优化 (#3201)
  feat: 组件类型版本分布数据支持下钻 (#3197)
  refactor: 更新前端icon资源 (#3199)
  fix: 修复下载zip类型配置项文件损坏的问题 (#3198)
  fix: 客户端验收问题修复 (#3196)
  feature: 客户端事件列表支持时分秒搜索 (#3195)
  feat: 客户端统计新增在线/离线状态搜索 (#3194)
  fix: 修复数据下钻标签没加搜索 (#3193)
  fix: 修复客户端添加搜索条件时心跳时间被覆盖问题 (#3192)
  fix: 创建前检测非模板配置和模板配置是否存在冲突 (#3124)
  feat: 客户端统计新增多维度查询和下钻 (#3189)
  feat: 客户端统计补全下钻功能及验收问题修复 (#3188)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bcs-bscp feature or bugfix for bscp
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants