Skip to content

Commit

Permalink
feat: 资源视图表单 cronjob 表达式支持正则
Browse files Browse the repository at this point in the history
  • Loading branch information
LidolLxf committed Sep 26, 2024
1 parent 5cd9e2e commit 1038838
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bcs-services/cluster-resources/pkg/i18n/locale/lc_msgs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@
en: "must start and end with alphanumeric, can contain '-', '_', '.' and alphanumeric"
- msgID: "不应少于 1 个项"
en: "Should not be less than 1 item."
- msgID: "格式无效,请参考 Cron 格式"
en: "Invalid format, please refer to Cron format."
- msgID: "资源类型 %s APIVersion %s 不在受支持的版本列表 %v 中,请改用 Yaml 模式而非表单化"
en: "resource kind %s apiVersion %s not in the list of supported versions %v, please use yaml rather than form edit mode"
- msgID: 标签有重复的键,请检查
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,5 +206,22 @@ func genSchemaRules(ctx context.Context) map[string]interface{} {
"validator": "{{ $self.value.length > 0 }}",
"message": i18n.GetMsg(ctx, "不应少于 1 个项"),
},
"scheduleValid": map[string]interface{}{
"validator": `/^(\*|([0-5]?\d)(,[0-5]?\d)*|([0-5]?\d)-([0-5]?\d))(\/([0-5]?\d)(,[0-5]?\d)*)?\s+` +
`(\*|([01]?\d|2[0-3])(,[01]?\d|2[0-3])*|([01]?\d|2[0-3])-` +
`([01]?\d|2[0-3]))(\/([01]?\d|2[0-3])(,[01]?\d|2[0-3])*)?\s+` +
`(\*|(0?[1-9]|[12][0-9]|3[01])(,(0?[1-9]|[12][0-9]|3[01]))*|` +
`(0?[1-9]|[12][0-9]|3[01])-(0?[1-9]|[12][0-9]|3[01])|\?)` +
`(\/(0?[1-9]|[12][0-9]|3[01])(,(0?[1-9]|[12][0-9]|3[01]))*)?\s+` +
`(\*|(0?[1-9]|1[0-2]|JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)` +
`(,(0?[1-9]|1[0-2]|JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC))*|` +
`(0?[1-9]|1[0-2]|JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)-` +
`(0?[1-9]|1[0-2]|JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC))` +
`(\/((0?[1-9]|1[0-2])(,((0?[1-9]|1[0-2]|JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)))*))?\s+` +
`(\*|([0-6]|SUN|MON|TUE|WED|THU|FRI|SAT)(,[0-6]|SUN|MON|TUE|WED|THU|FRI|SAT)*|` +
`([0-6]|SUN|MON|TUE|WED|THU|FRI|SAT)-([0-6]|SUN|MON|TUE|WED|THU|FRI|SAT)|\?)` +
`(\/([0-6](,([0-6]|SUN|MON|TUE|WED|THU|FRI|SAT))*))?$/`,
"message": i18n.GetMsg(ctx, "格式无效,请参考 Cron 格式"),
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,7 @@ jobManage:
ui:rules:
- required
- maxLength64
- scheduleValid
concurrencyPolicy:
title: {{ i18n "并发策略" .lang }}
type: string
Expand Down

0 comments on commit 1038838

Please sign in to comment.