Skip to content

Commit

Permalink
various fixes, helptext
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinsID committed Apr 11, 2022
1 parent 7735595 commit 83d89cc
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/containerapp/azext_containerapp/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,13 @@
- name: Create an environment with an auto-generated Log Analytics workspace.
text: |
az containerapp env create -n MyContainerappEnvironment -g MyResourceGroup \\
--location "Canada Central"
--location eastus2
- name: Create an environment with an existing Log Analytics workspace.
text: |
az containerapp env create -n MyContainerappEnvironment -g MyResourceGroup \\
--logs-workspace-id myLogsWorkspaceID \\
--logs-workspace-key myLogsWorkspaceKey \\
--location "Canada Central"
--location eastus2
"""


Expand Down
7 changes: 5 additions & 2 deletions src/containerapp/azext_containerapp/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ def load_arguments(self, _):
with self.argument_context('containerapp', arg_group='Container') as c:
c.argument('image', type=str, options_list=['--image', '-i'], help="Container image, e.g. publisher/image-name:tag.")
c.argument('container_name', type=str, help="Name of the container.")
c.argument('cpu', type=float, validator=validate_cpu, help="Required CPU in cores, e.g. 0.5")
c.argument('memory', type=str, validator=validate_memory, help="Required memory, e.g. 1.0Gi")
c.argument('cpu', type=float, validator=validate_cpu, help="Required CPU in cores from 0.25 - 2.0, e.g. 0.5")
c.argument('memory', type=str, validator=validate_memory, help="Required memory from 0.5 - 4.0 ending with \"Gi\", e.g. 1.0Gi")
c.argument('env_vars', nargs='*', help="A list of environment variable(s) for the container. Space-separated values in 'key=value' format. Empty string to clear existing values. Prefix value with 'secretref:' to reference a secret.")
c.argument('startup_command', nargs='*', options_list=['--command'], help="A list of supported commands on the container that will executed during startup. Space-separated values e.g. \"/bin/queue\" \"mycommand\". Empty string to clear existing values")
c.argument('args', nargs='*', help="A list of container startup command argument(s). Space-separated values e.g. \"-c\" \"mycommand\". Empty string to clear existing values")
Expand Down Expand Up @@ -175,5 +175,8 @@ def load_arguments(self, _):
with self.argument_context('containerapp registry list') as c:
c.argument('name', id_part=None)

with self.argument_context('containerapp secret list') as c:
c.argument('name', id_part=None)

with self.argument_context('containerapp revision list') as c:
c.argument('name', id_part=None)
2 changes: 1 addition & 1 deletion src/containerapp/azext_containerapp/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def _generate_log_analytics_if_not_provided(cmd, logs_customer_id, logs_key, loc


def _get_existing_secrets(cmd, resource_group_name, name, containerapp_def):
if "secrets" not in containerapp_def["properties"]["configuration"]:
if "secrets" not in containerapp_def["properties"]["configuration"] or not containerapp_def["properties"]["configuration"]["secrets"]:
containerapp_def["properties"]["configuration"]["secrets"] = []
else:
secrets = []
Expand Down
11 changes: 6 additions & 5 deletions src/containerapp/azext_containerapp/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ def _is_number(s):


def validate_memory(namespace):
memory = namespace.memory

if memory is not None:
if namespace.memory is not None:
valid = False

if memory.endswith("Gi"):
valid = _is_number(memory[:-2])
if not namespace.memory.endswith("Gi"):
namespace.memory = namespace.memory.rstrip()
namespace.memory += "Gi"

valid = _is_number(namespace.memory[:-2])

if not valid:
raise ValidationError("Usage error: --memory must be a number ending with \"Gi\"")
Expand Down
4 changes: 2 additions & 2 deletions src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def update_containerapp_logic(cmd,
if len(containerapp_def["properties"]["template"]["containers"]) == 1:
container_name = containerapp_def["properties"]["template"]["containers"][0]["name"]
else:
raise ValidationError("Usage error: --image-name is required when adding or updating a container")
raise ValidationError("Usage error: --container-name is required when adding or updating a container")

# Check if updating existing container
updating_existing_container = False
Expand Down Expand Up @@ -1731,7 +1731,7 @@ def set_secrets(cmd, name, resource_group_name, secrets,
try:
r = ContainerAppClient.create_or_update(
cmd=cmd, resource_group_name=resource_group_name, name=name, container_app_envelope=containerapp_def, no_wait=no_wait)
logger.warning("Containerapp must be restarted in order for secret changes to take effect.")
logger.warning("Containerapp '{}' must be restarted in order for secret changes to take effect.".format(name))
return r["properties"]["configuration"]["secrets"]
except Exception as e:
handle_raw_exception(e)
Expand Down

0 comments on commit 83d89cc

Please sign in to comment.