Skip to content

Commit

Permalink
fix: Add regex for helm appName (#1077)
Browse files Browse the repository at this point in the history
  • Loading branch information
liiil825 authored and sunnywx committed Mar 29, 2019
1 parent 61e8293 commit f241ea6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/locales/zh/deploy.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"STEPPER_FOOTER_APP_DEPLOY_1": "部署完成的实例将会出现在「我的实例」列表中",
"STEPPER_TITLE_APP_DEPLOY_TEST_1": "部署测试实例",
"STEPPER_FOOTER_APP_DEPLOY_TEST_1": "部署完成的测试实例将会出现在「测试实例/沙盒实例」列表中",
"HELM_APP_NAME_ERROR": "实例名称必须是$t(HELM_APP_NAME_TIP)",
"HELM_APP_NAME_TIP": "小写字母开头,最长14个字符(支持数字/小写字母/连字符)",
"No available version": "没有可用版本"
}
4 changes: 4 additions & 0 deletions src/pages/Dashboard/Apps/Deploy/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const keysShouldBeNumber = [
'instance_class',
'count'
];
const appNameRegex = /^[a-z][a-z0-9-]{0,13}$/;

@withTranslation()
@inject(({ rootStore }) => ({
Expand Down Expand Up @@ -179,6 +180,9 @@ export default class AppDeploy extends Component {
if (!name) {
return appDeployStore.error(t('Name should not be empty'));
}
if (!appNameRegex.test(name)) {
return appDeployStore.error(t('HELM_APP_NAME_ERROR'));
}

let conf;
if (isK8s) {
Expand Down

0 comments on commit f241ea6

Please sign in to comment.