Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various bugfixes before release #38

Merged
merged 4 commits into from
Mar 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/containerapp/azext_containerapp/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def load_arguments(self, _):
with self.argument_context('containerapp env dapr-component') as c:
c.argument('dapr_app_id', help="The Dapr app ID.")
c.argument('dapr_app_port', help="The port of your app.")
c.argument('dapr_app_protocol', help="Tells Dapr which protocol your application is using. Allowed values: grpc, http.")
c.argument('dapr_app_protocol', help="Tell Dapr which protocol your application is using. Allowed values: grpc, http.")
c.argument('dapr_component_name', help="The Dapr component name.")
c.argument('environment_name', options_list=['--name', '-n'], help="The environment name.")

Expand Down
2 changes: 1 addition & 1 deletion src/containerapp/azext_containerapp/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def transform_revision_list_output(revs):


def load_command_table(self, _):
with self.command_group('containerapp') as g:
with self.command_group('containerapp', is_preview=True) as g:
g.custom_show_command('show', 'show_containerapp', table_transformer=transform_containerapp_output)
g.custom_command('list', 'list_containerapp', table_transformer=transform_containerapp_list_output)
g.custom_command('create', 'create_containerapp', supports_no_wait=True, exception_handler=ex_handler_factory())
Expand Down
64 changes: 3 additions & 61 deletions src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from ._client_factory import handle_raw_exception
from ._clients import ManagedEnvironmentClient, ContainerAppClient, GitHubActionClient, DaprComponentClient
# from ._sdk_models import * # pylint: disable=wildcard-import, unused-wildcard-import
from ._sdk_models import * # pylint: disable=wildcard-import, unused-wildcard-import
from ._github_oauth import get_github_access_token
from ._models import (
ManagedEnvironment as ManagedEnvironmentModel,
Expand Down Expand Up @@ -455,16 +455,12 @@ def update_containerapp(cmd,
min_replicas=None,
max_replicas=None,
revisions_mode=None,
secrets=None,
set_env_vars=None,
remove_env_vars=None,
replace_env_vars=None,
remove_all_env_vars=False,
cpu=None,
memory=None,
registry_server=None,
registry_user=None,
registry_pass=None,
revision_suffix=None,
startup_command=None,
args=None,
Expand All @@ -474,8 +470,7 @@ def update_containerapp(cmd,

if yaml:
if image or min_replicas or max_replicas or\
revisions_mode or secrets or set_env_vars or remove_env_vars or replace_env_vars or remove_all_env_vars or cpu or memory or registry_server or\
registry_user or registry_pass or\
revisions_mode or set_env_vars or remove_env_vars or replace_env_vars or remove_all_env_vars or cpu or memory or\
startup_command or args or tags:
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 update_containerapp_yaml(cmd=cmd, name=name, resource_group_name=resource_group_name, file_name=yaml, no_wait=no_wait)
Expand All @@ -498,11 +493,9 @@ def update_containerapp(cmd,
e["value"] = ""

update_map = {}
update_map['secrets'] = secrets is not None
update_map['registries'] = registry_server or registry_user or registry_pass
update_map['scale'] = min_replicas or max_replicas
update_map['container'] = image or container_name or set_env_vars is not None or remove_env_vars is not None or replace_env_vars is not None or remove_all_env_vars or cpu or memory or startup_command is not None or args is not None
update_map['configuration'] = update_map['secrets'] or update_map['registries'] or revisions_mode is not None
update_map['configuration'] = revisions_mode is not None

if tags:
_add_or_update_tags(containerapp_def, tags)
Expand Down Expand Up @@ -631,57 +624,6 @@ def update_containerapp(cmd,

_get_existing_secrets(cmd, resource_group_name, name, containerapp_def)

if secrets is not None:
_add_or_update_secrets(containerapp_def, parse_secret_flags(secrets))

if update_map["registries"]:
registries_def = None
registry = None

if "registries" not in containerapp_def["properties"]["configuration"]:
containerapp_def["properties"]["configuration"]["registries"] = []

registries_def = containerapp_def["properties"]["configuration"]["registries"]

if not registry_server:
raise ValidationError("Usage error: --registry-server is required when adding or updating a registry")

# Infer credentials if not supplied and its azurecr
if (registry_user is None or registry_pass is None) and not _registry_exists(containerapp_def, registry_server):
registry_user, registry_pass = _infer_acr_credentials(cmd, registry_server)

# Check if updating existing registry
updating_existing_registry = False
for r in registries_def:
if r['server'].lower() == registry_server.lower():
updating_existing_registry = True

if registry_user:
r["username"] = registry_user
if registry_pass:
r["passwordSecretRef"] = store_as_secret_and_return_secret_ref(
containerapp_def["properties"]["configuration"]["secrets"],
r["username"],
r["server"],
registry_pass,
update_existing_secret=True)

# 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-server, --registry-password and --registry-username are required when adding a registry")

registry = RegistryCredentialsModel
registry["server"] = registry_server
registry["username"] = registry_user
registry["passwordSecretRef"] = store_as_secret_and_return_secret_ref(
containerapp_def["properties"]["configuration"]["secrets"],
registry_user,
registry_server,
registry_pass,
update_existing_secret=True)

registries_def.append(registry)
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)
Expand Down
2 changes: 2 additions & 0 deletions src/containerapp/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'License :: OSI Approved :: MIT License',
]

Expand Down