Skip to content

Commit

Permalink
pref:完善研发商店组件配置文件参数校验 TencentBlueKing#11269
Browse files Browse the repository at this point in the history
  • Loading branch information
Kzhou991 committed Dec 4, 2024
1 parent 5a10e57 commit 2753813
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ object StoreMessageCode {
const val USER_PULL_FILE_FAIL = "2120041"
// 插件包文件[{0}]不存在,请检查文件所在路径是否正确
const val ATOM_PACKAGE_FILE_NOT_FOUND = "2120042"
const val USER_REPOSITORY_TASK_JSON_FIELD_IS_NOT_SUPPORT = "2120043"//研发商店:插件配置文件[task.json]{0}字段暂时只支持{1},{2},{3},{4}

const val USER_TEMPLATE_VERSION_IS_NOT_FINISH = "2120201" // 研发商店:模板{0}的{1}版本发布未结束,请稍后再试
const val USER_TEMPLATE_RELEASE_STEPS_ERROR = "2120202" // 研发商店:模板发布流程状态变更顺序不正确
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,7 @@

package com.tencent.devops.store.atom.service.impl

import com.tencent.devops.common.api.constant.COMPONENT
import com.tencent.devops.common.api.constant.CommonMessageCode
import com.tencent.devops.common.api.constant.INIT_VERSION
import com.tencent.devops.common.api.constant.KEY_OS
import com.tencent.devops.common.api.constant.KEY_OS_ARCH
import com.tencent.devops.common.api.constant.KEY_OS_NAME
import com.tencent.devops.common.api.constant.REQUIRED
import com.tencent.devops.common.api.constant.TYPE
import com.tencent.devops.common.api.constant.*
import com.tencent.devops.common.api.enums.FrontendTypeEnum
import com.tencent.devops.common.api.exception.ErrorCodeException
import com.tencent.devops.common.api.pojo.Result
Expand Down Expand Up @@ -389,19 +382,20 @@ class MarketAtomCommonServiceImpl : MarketAtomCommonService {
)
}
//pref:完善研发商店组件配置文件参数校验 #11269
val atomLanguage = marketAtomEnvInfoDao.getAtomLanguage(dslContext, atomCode, version)
val supportedLanguages = setOf(JAVA, PYTHON, GOLANG, NODEJS)
val language = executionInfoMap[KEY_LANGUAGE]?.let { language ->
when (language) {
is String -> {
if (StringUtils.equals(atomLanguage, language)) {
if (language in supportedLanguages) {
language
} else {
throw ErrorCodeException(
errorCode = StoreMessageCode.USER_REPOSITORY_TASK_JSON_FIELD_IS_NOT_MATCH,
errorCode = StoreMessageCode.USER_REPOSITORY_TASK_JSON_FIELD_IS_NOT_SUPPORT,
params = arrayOf(KEY_LANGUAGE)
)
}
}

else -> throw ErrorCodeException(
errorCode = StoreMessageCode.USER_REPOSITORY_TASK_JSON_FIELD_IS_INVALID,
params = arrayOf(KEY_LANGUAGE)
Expand Down
1 change: 1 addition & 0 deletions support-files/i18n/store/message_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
2120934=store: Failed to delete the component repository file
2120935=When the queryProjectComponentFlag, installed, or updateFlag parameters are not empty, the projectCode parameter must be non-empty
2120936=store: Unreleased versions are not allowed to be removed from the shelves
2120043=store: The [task.json] file's {0} field currently only supports {1}, {2}, {3}, {4}
ATOM.classify.common=Others
ATOM.classify.compileBuild=Compile
ATOM.classify.deploy=Deploy
Expand Down
1 change: 1 addition & 0 deletions support-files/i18n/store/message_zh_CN.properties
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
2120040=研发商店:插件配置文件[task.json]config配置格式不正确,{0}
2120041=研发商店: 拉取文件[{0}]失败,失败原因:{1}
2120042=插件包文件[{0}]不存在,请检查文件所在路径是否正确
2120043=研发商店:插件配置文件[task.json]{0}字段暂时只支持{1},{2},{3},{4}
2120201=研发商店: 模板{0}的{1}版本发布未结束,请稍后再试
2120202=研发商店: 模板发布流程状态变更顺序不正确
2120203=研发商店: 模板的可见范围不在插件{0}的可见范围之内,如有需要请联系插件的发布者
Expand Down

0 comments on commit 2753813

Please sign in to comment.