Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/containerapp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Upcoming
* 'az containerapp create/update': --yaml support properties for api-version 2023-04-01-preview (e.g. subPath, mountOptions)
* 'az containerapp service': add support for creation and deletion of kafka
* 'az containerapp create': --registry-server support registry with custom port

* Add regex to fix validation for containerapp name

0.3.33
++++++
Expand Down
12 changes: 0 additions & 12 deletions src/containerapp/azext_containerapp/_up_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -979,18 +979,6 @@ def _get_registry_details(cmd, app: "ContainerApp", source):
)


def _validate_containerapp_name(name):
is_valid = True
is_valid = is_valid and name.lower() == name
is_valid = is_valid and len(name) <= MAXIMUM_CONTAINER_APP_NAME_LENGTH
is_valid = is_valid and '--' not in name
name = name.replace('-', '')
is_valid = is_valid and name.isalnum()
is_valid = is_valid and name[0].isalpha()
if not is_valid:
raise ValidationError(f"Invalid Container App name {name}. A name must consist of lower case alphanumeric characters or '-', start with a letter, end with an alphanumeric character, cannot have '--', and must be less than {MAXIMUM_CONTAINER_APP_NAME_LENGTH} characters.")


# attempt to populate defaults for managed env, RG, ACR, etc
def _set_up_defaults(
cmd,
Expand Down
13 changes: 5 additions & 8 deletions src/containerapp/azext_containerapp/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,11 @@ def register_provider_if_needed(cmd, rp_name):


def validate_container_app_name(name, appType):
if (appType == AppType.ContainerAppJob.name):
if name and len(name) > MAXIMUM_CONTAINER_APP_NAME_LENGTH:
raise ValidationError(f"Container App Job names cannot be longer than {MAXIMUM_CONTAINER_APP_NAME_LENGTH}. "
f"Please shorten {name}")
if (appType == AppType.ContainerApp.name):
if name and len(name) > MAXIMUM_CONTAINER_APP_NAME_LENGTH:
raise ValidationError(f"Container App Job names cannot be longer than {MAXIMUM_CONTAINER_APP_NAME_LENGTH}. "
f"Please shorten {name}")
name_regex = re.compile(r'^(?=.{1,32}$)[a-z]((?!.*--)[-a-z0-9]*[a-z0-9])?$', re.IGNORECASE)
match = name_regex.match(name)

if not match:
raise ValidationError(f"Invalid {appType} name {name}. A name must consist of lower case alphanumeric characters or '-', start with a letter, end with an alphanumeric character, cannot have '--', and must be less than {MAXIMUM_CONTAINER_APP_NAME_LENGTH} characters.")


def retry_until_success(operation, err_txt, retry_limit, *args, **kwargs):
Expand Down
4 changes: 1 addition & 3 deletions src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -4260,13 +4260,11 @@ def containerapp_up(cmd,
from ._up_utils import (_validate_up_args, _reformat_image, _get_dockerfile_content, _get_ingress_and_target_port,
ResourceGroup, ContainerAppEnvironment, ContainerApp, _get_registry_from_app,
_get_registry_details, _create_github_action, _set_up_defaults, up_output,
check_env_name_on_rg, get_token, _validate_containerapp_name, _has_dockerfile)
check_env_name_on_rg, get_token, _has_dockerfile)
from ._github_oauth import cache_github_token
HELLOWORLD = "mcr.microsoft.com/k8se/quickstart"
dockerfile = "Dockerfile" # for now the dockerfile name must be "Dockerfile" (until GH actions API is updated)

_validate_containerapp_name(name)

register_provider_if_needed(cmd, CONTAINER_APPS_RP)
_validate_up_args(cmd, source, image, repo, registry_server)
validate_container_app_name(name, AppType.ContainerApp.name)
Expand Down