Skip to content

Commit

Permalink
Merge pull request Azure#159 from RakeshMohanMSFT/patch-3
Browse files Browse the repository at this point in the history
{containerapp} Fix #23934: Add validation for revision suffix parameter
  • Loading branch information
StrawnSC authored Oct 4, 2022
2 parents 8efcac5 + a06f555 commit f116d49
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/containerapp/azext_containerapp/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from ._ssh_utils import ping_container_app
from ._utils import safe_get, is_registry_msi_system
from ._constants import ACR_IMAGE_SUFFIX
import re


logger = get_logger(__name__)
Expand All @@ -38,6 +39,14 @@ def _is_number(s):
return False


def validate_revision_suffix(value):
if value is not None:
matched = re.match(r"^[a-z](?!.*-{2})([-a-z0-9]*[a-z0-9])?$", value)
if not matched:
raise ValidationError(f"Invalid Container App revision name {value}. A revision name must consist of lower case alphanumeric characters or '-', start with a letter, end with an alphanumeric character and cannot have '--'.")



def validate_memory(namespace):
if namespace.memory is not None:
valid = False
Expand Down
3 changes: 2 additions & 1 deletion src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
validate_hostname, patch_new_custom_domain, get_custom_domains, _validate_revision_name, set_managed_identity,
create_acrpull_role_assignment, is_registry_msi_system, clean_null_values, _populate_secret_values,
validate_environment_location, safe_set, parse_metadata_flags, parse_auth_flags)
from ._validators import validate_create
from ._validators import validate_create, validate_revision_suffix
from ._ssh_utils import (SSH_DEFAULT_ENCODING, WebSocketConnection, read_ssh, get_stdin_writer, SSH_CTRL_C_MSG,
SSH_BACKUP_ENCODING)
from ._constants import (MAXIMUM_SECRET_LENGTH, MICROSOFT_SECRET_SETTING_NAME, FACEBOOK_SECRET_SETTING_NAME, GITHUB_SECRET_SETTING_NAME,
Expand Down Expand Up @@ -346,6 +346,7 @@ def create_containerapp(cmd,
register_provider_if_needed(cmd, CONTAINER_APPS_RP)
validate_container_app_name(name)
validate_create(registry_identity, registry_pass, registry_user, registry_server, no_wait)
validate_revision_suffix(revision_suffix)

if registry_identity and not is_registry_msi_system(registry_identity):
logger.info("Creating an acrpull role assignment for the registry identity")
Expand Down

0 comments on commit f116d49

Please sign in to comment.