Skip to content

Commit

Permalink
feat: smart 应用ID 支持 20 个字符 (#750)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiayuan929 authored Oct 16, 2023
1 parent 9b858a3 commit 380f60f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apiserver/paasng/paasng/engine/deploy/bg_build/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

def generate_builder_name(app: 'WlApp') -> str:
"""Get the builder name"""
return f"slug-builder--{app.scheduler_safe_name}"
return f"slug-builder--{app.module_name}"


def generate_slug_path(bp: BuildProcess) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ class AppDescriptionSLZ(serializers.Serializer):
region = serializers.ChoiceField(required=False, allow_null=True, choices=get_region().get_choices())
bk_app_code = AppIDField(
# DNS safe(prefix)
# S-mart 应用ID 长度限制为 20 个字符
max_length=20,
regex="^(?![0-9]+.*$)(?!-)[a-zA-Z0-9-_]{,63}(?<!-)$",
validators=[ReservedWordValidator("应用 ID"), AppIDUniqueValidator()],
error_messages={'invalid': _('格式错误,只能包含小写字母(a-z)、数字(0-9)和半角连接符(-)和下划线(_)')},
Expand Down
4 changes: 1 addition & 3 deletions apiserver/paasng/tests/engine/deploy/bg_build/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ def test_generate_slug_path(self, wl_app, build_proc):
def test_prepare_slugbuilder_template_without_metadata(self, _, wl_app, build_proc):
env_vars = generate_builder_env_vars(build_proc, {})
slug_tmpl = prepare_slugbuilder_template(wl_app, env_vars, None)
assert (
slug_tmpl.name == f"slug-builder--{wl_app.scheduler_safe_name}"
), "slugbuilder_template 的 name 与app的 name 不一致"
assert slug_tmpl.name == f"slug-builder--{wl_app.module_name}", "slugbuilder_template 的 name 与app的 name 不一致"
assert slug_tmpl.namespace == wl_app.namespace, "slugbuilder_template 的namespace 与 app 的 namespace 不一致"
assert slug_tmpl.runtime.image == settings.DEFAULT_SLUGBUILDER_IMAGE, "slugbuilder_template 的镜像与默认镜像不一致"
assert slug_tmpl.runtime.envs == env_vars, "slugbuilder_template 的 ConfigVars 与生成的环境变量不一致"
Expand Down

0 comments on commit 380f60f

Please sign in to comment.