Skip to content

Commit

Permalink
More p0 fixes (#20)
Browse files Browse the repository at this point in the history
* Remove --registry-login-server, only allow --registry-server

* Rename --environment-variables to --env-vars

* If no image is supplied, use default quickstart image
  • Loading branch information
calvinsID authored Mar 11, 2022
1 parent ae8fb6a commit e1ef696
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/containerapp/azext_containerapp/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
Expand Down Expand Up @@ -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 \\
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/containerapp/azext_containerapp/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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.")
Expand Down
6 changes: 3 additions & 3 deletions src/containerapp/azext_containerapp/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
8 changes: 4 additions & 4 deletions src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit e1ef696

Please sign in to comment.