From e1ef6967a483eb4ca5c7fb8e5bd440326adc918f Mon Sep 17 00:00:00 2001 From: Calvin Date: Fri, 11 Mar 2022 10:13:37 -0800 Subject: [PATCH] More p0 fixes (#20) * Remove --registry-login-server, only allow --registry-server * Rename --environment-variables to --env-vars * If no image is supplied, use default quickstart image --- src/containerapp/azext_containerapp/_help.py | 8 ++++---- src/containerapp/azext_containerapp/_params.py | 4 ++-- src/containerapp/azext_containerapp/_validators.py | 6 +++--- src/containerapp/azext_containerapp/custom.py | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/containerapp/azext_containerapp/_help.py b/src/containerapp/azext_containerapp/_help.py index 6122a3d895a..0720d816793 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: | @@ -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 @@ -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 \\ @@ -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 545f6b8d05a..e6fb2908f67 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') @@ -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 6908f9d6371..f814103c875 100644 --- a/src/containerapp/azext_containerapp/custom.py +++ b/src/containerapp/azext_containerapp/custom.py @@ -336,8 +336,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') @@ -671,7 +671,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: @@ -696,7 +696,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