From d231de3e2fccc8caadc336fa2d46cfec0150835b Mon Sep 17 00:00:00 2001 From: Calvin Chan Date: Thu, 10 Mar 2022 13:30:26 -0800 Subject: [PATCH 1/3] Remove --registry-login-server, only allow --registry-server --- src/containerapp/azext_containerapp/_help.py | 4 ++-- src/containerapp/azext_containerapp/_params.py | 2 +- src/containerapp/azext_containerapp/_validators.py | 6 +++--- src/containerapp/azext_containerapp/custom.py | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/containerapp/azext_containerapp/_help.py b/src/containerapp/azext_containerapp/_help.py index f4d7713ce93..0a65e3b0672 100644 --- a/src/containerapp/azext_containerapp/_help.py +++ b/src/containerapp/azext_containerapp/_help.py @@ -39,7 +39,7 @@ az containerapp create -n MyContainerapp -g MyResourceGroup \\ --image MyContainerImage -e MyContainerappEnv \\ --secrets mypassword=verysecurepassword \\ - --registry-login-server MyRegistryServerAddress \\ + --registry-server MyRegistryServerAddress \\ --registry-username MyUser \\ --registry-password mypassword \\ --query properties.configuration.ingress.fqdn @@ -85,7 +85,7 @@ az containerapp update -n MyContainerapp -g MyResourceGroup \\ --image MyNewContainerImage \\ --secrets mypassword=verysecurepassword \\ - --registry-login-server MyRegistryServerAddress \\ + --registry-server MyRegistryServerAddress \\ --registry-username MyUser \\ --registry-password mypassword - name: Update a Containerapp using a specified startup command and arguments diff --git a/src/containerapp/azext_containerapp/_params.py b/src/containerapp/azext_containerapp/_params.py index 6bec838fb93..b4757b962d1 100644 --- a/src/containerapp/azext_containerapp/_params.py +++ b/src/containerapp/azext_containerapp/_params.py @@ -56,7 +56,7 @@ def load_arguments(self, _): # Configuration with self.argument_context('containerapp', arg_group='Configuration') as c: c.argument('revisions_mode', arg_type=get_enum_type(['single', 'multiple']), options_list=['--revisions-mode'], help="The active revisions mode for the containerapp.") - c.argument('registry_server', type=str, validator=validate_registry_server, options_list=['--registry-server', '--registry-login-server'], help="The url of the registry, e.g. myregistry.azurecr.io") + c.argument('registry_server', type=str, validator=validate_registry_server, options_list=['--registry-server'], help="The url of the registry, e.g. myregistry.azurecr.io") c.argument('registry_pass', type=str, validator=validate_registry_pass, options_list=['--registry-password'], help="The password to log in container image registry server. If stored as a secret, value must start with \'secretref:\' followed by the secret name.") c.argument('registry_user', type=str, validator=validate_registry_user, options_list=['--registry-username'], help="The username to log in container image registry server") c.argument('secrets', nargs='*', options_list=['--secrets', '-s'], help="A list of secret(s) for the containerapp. Space-separated values in 'key=value' format.") diff --git a/src/containerapp/azext_containerapp/_validators.py b/src/containerapp/azext_containerapp/_validators.py index c95d675cb00..916d9eb5b57 100644 --- a/src/containerapp/azext_containerapp/_validators.py +++ b/src/containerapp/azext_containerapp/_validators.py @@ -53,19 +53,19 @@ def validate_registry_server(namespace): if namespace.registry_server: if not namespace.registry_user or not namespace.registry_pass: if ".azurecr.io" not in namespace.registry_server: - raise ValidationError("Usage error: --registry-login-server, --registry-password and --registry-username are required together if not using Azure Container Registry") + raise ValidationError("Usage error: --registry-server, --registry-password and --registry-username are required together if not using Azure Container Registry") def validate_registry_user(namespace): if "create" in namespace.command.lower(): if namespace.registry_user: if not namespace.registry_server or (not namespace.registry_pass and ".azurecr.io" not in namespace.registry_server): - raise ValidationError("Usage error: --registry-login-server, --registry-password and --registry-username are required together if not using Azure Container Registry") + raise ValidationError("Usage error: --registry-server, --registry-password and --registry-username are required together if not using Azure Container Registry") def validate_registry_pass(namespace): if "create" in namespace.command.lower(): if namespace.registry_pass: if not namespace.registry_server or (not namespace.registry_user and ".azurecr.io" not in namespace.registry_server): - raise ValidationError("Usage error: --registry-login-server, --registry-password and --registry-username are required together if not using Azure Container Registry") + raise ValidationError("Usage error: --registry-server, --registry-password and --registry-username are required together if not using Azure Container Registry") def validate_target_port(namespace): if "create" in namespace.command.lower(): diff --git a/src/containerapp/azext_containerapp/custom.py b/src/containerapp/azext_containerapp/custom.py index d346cc75f65..01e9d1038c9 100644 --- a/src/containerapp/azext_containerapp/custom.py +++ b/src/containerapp/azext_containerapp/custom.py @@ -661,7 +661,7 @@ def update_containerapp(cmd, registries_def = containerapp_def["properties"]["configuration"]["registries"] if not registry_server: - raise ValidationError("Usage error: --registry-login-server is required when adding or updating a registry") + raise ValidationError("Usage error: --registry-server is required when adding or updating a registry") # Infer credentials if not supplied and its azurecr if not registry_user or not registry_pass: @@ -686,7 +686,7 @@ def update_containerapp(cmd, # If not updating existing registry, add as new registry if not updating_existing_registry: if not(registry_server is not None and registry_user is not None and registry_pass is not None): - raise ValidationError("Usage error: --registry-login-server, --registry-password and --registry-username are required when adding a registry") + raise ValidationError("Usage error: --registry-server, --registry-password and --registry-username are required when adding a registry") registry = RegistryCredentialsModel registry["server"] = registry_server From 7a2a6079d1e7dfb48a49c0bc8fcc90f81c35c558 Mon Sep 17 00:00:00 2001 From: Calvin Chan Date: Thu, 10 Mar 2022 13:33:40 -0800 Subject: [PATCH 2/3] Rename --environment-variables to --env-vars --- src/containerapp/azext_containerapp/_help.py | 4 ++-- src/containerapp/azext_containerapp/_params.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/containerapp/azext_containerapp/_help.py b/src/containerapp/azext_containerapp/_help.py index 0a65e3b0672..335832c07e2 100644 --- a/src/containerapp/azext_containerapp/_help.py +++ b/src/containerapp/azext_containerapp/_help.py @@ -26,7 +26,7 @@ az containerapp create -n MyContainerapp -g MyResourceGroup \\ --image MyContainerImage -e MyContainerappEnv \\ --secrets mysecret=escapefromtarkov,anothersecret=isadifficultgame \\ - --environment-variables myenvvar=foo,anotherenvvar=bar \\ + --env-vars myenvvar=foo,anotherenvvar=bar \\ --query properties.configuration.ingress.fqdn - name: Create a Containerapp that only accepts internal traffic text: | @@ -75,7 +75,7 @@ text: | az containerapp update -n MyContainerapp -g MyResourceGroup \\ --secrets mysecret=secretfoo,anothersecret=secretbar - --environment-variables myenvvar=foo,anotherenvvar=secretref:mysecretname + --env-vars myenvvar=foo,anotherenvvar=secretref:mysecretname - name: Update a Containerapp's ingress setting to internal text: | az containerapp update -n MyContainerapp -g MyResourceGroup \\ diff --git a/src/containerapp/azext_containerapp/_params.py b/src/containerapp/azext_containerapp/_params.py index b4757b962d1..7758e79c1bb 100644 --- a/src/containerapp/azext_containerapp/_params.py +++ b/src/containerapp/azext_containerapp/_params.py @@ -35,7 +35,7 @@ def load_arguments(self, _): c.argument('image_name', type=str, options_list=['--image-name'], help="Name of the Container image.") c.argument('cpu', type=float, validator=validate_cpu, options_list=['--cpu'], help="Required CPU in cores, e.g. 0.5") c.argument('memory', type=str, validator=validate_memory, options_list=['--memory'], help="Required memory, e.g. 1.0Gi") - c.argument('env_vars', nargs='*', options_list=['--env-vars', '--environment-variables'], help="A list of environment variable(s) for the containerapp. Space-separated values in 'key=value' format. Empty string to clear existing values") + c.argument('env_vars', nargs='*', options_list=['--env-vars'], help="A list of environment variable(s) for the containerapp. Space-separated values in 'key=value' format. Empty string to clear existing values") c.argument('startup_command', nargs='*', options_list=['--command'], help="A list of supported commands on the container app that will executed during container startup. Space-separated values e.g. \"/bin/queue\" \"mycommand\". Empty string to clear existing values") c.argument('args', nargs='*', options_list=['--args'], help="A list of container startup command argument(s). Space-separated values e.g. \"-c\" \"mycommand\". Empty string to clear existing values") c.argument('revision_suffix', type=str, options_list=['--revision-suffix'], help='User friendly suffix that is appended to the revision name') From 48e724e7ae75ec2124e4ed8cd5b7d3f72c5571b7 Mon Sep 17 00:00:00 2001 From: Calvin Chan Date: Fri, 11 Mar 2022 09:54:49 -0800 Subject: [PATCH 3/3] If no image is supplied, use default quickstart image --- src/containerapp/azext_containerapp/custom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/containerapp/azext_containerapp/custom.py b/src/containerapp/azext_containerapp/custom.py index 01e9d1038c9..50d110474ce 100644 --- a/src/containerapp/azext_containerapp/custom.py +++ b/src/containerapp/azext_containerapp/custom.py @@ -326,8 +326,8 @@ def create_containerapp(cmd, logger.warning('Additional flags were passed along with --yaml. These flags will be ignored, and the configuration defined in the yaml will be used instead') return create_containerapp_yaml(cmd=cmd, name=name, resource_group_name=resource_group_name, file_name=yaml, no_wait=no_wait) - if image is None: - raise RequiredArgumentMissingError('Usage error: --image is required if not using --yaml') + if not image: + image = "mcr.microsoft.com/azuredocs/containerapps-helloworld:latest" if managed_env is None: raise RequiredArgumentMissingError('Usage error: --environment is required if not using --yaml')