Skip to content

Commit

Permalink
az containerapp up: Fix InvalidResourceType error when cloud is not…
Browse files Browse the repository at this point in the history
… AzureCloud (Azure#7551)
  • Loading branch information
Greedygre authored Apr 28, 2024
1 parent 8834aab commit 8e7fe30
Show file tree
Hide file tree
Showing 6 changed files with 3,769 additions and 26 deletions.
1 change: 1 addition & 0 deletions src/containerapp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ upcoming
* 'az containerapp up/create/update': Wait longer time for logstream of Cloud Build to make sure the container start
* 'az containerapp env java-component config-server-for-spring': Support create/update/show/delete Spring Cloud Config; deprecation of 'az containerapp env java-component spring-cloud-config'
* 'az containerapp env java-component eureka-server-for-spring': Support create/update/show/delete Spring Cloud Eureka; deprecation of 'az containerapp env java-component spring-cloud-eureka'
* 'az containerapp up': Fix InvalidResourceType error when cloud is not AzureCloud

0.3.50
++++++
Expand Down
7 changes: 4 additions & 3 deletions src/containerapp/azext_containerapp/_up_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
get_pack_exec_path, _validate_custom_loc_and_location, _validate_connected_k8s_exists, get_custom_location,
create_extension, create_custom_location, get_cluster_extension, validate_environment_location,
list_environment_locations, get_randomized_name_with_dash, get_randomized_name, get_connected_k8s,
list_cluster_extensions, list_custom_location
list_cluster_extensions, list_custom_location, is_cloud_supported_by_connected_env
)

from ._constants import (MAXIMUM_SECRET_LENGTH,
Expand Down Expand Up @@ -1381,9 +1381,10 @@ def _set_up_defaults(
"Please specify which resource group your Containerapp environment is in."
) # get ACR details from --image, if possible

_infer_existing_connected_env(cmd, location, resource_group, env, custom_location)
if is_cloud_supported_by_connected_env(cmd.cli_ctx):
_infer_existing_connected_env(cmd, location, resource_group, env, custom_location)

_infer_existing_custom_location_or_extension(cmd, name, location, resource_group, env, custom_location, extension)
_infer_existing_custom_location_or_extension(cmd, name, location, resource_group, env, custom_location, extension)

if not is_registry_server_params_set:
_get_acr_from_image(cmd, app)
Expand Down
8 changes: 8 additions & 0 deletions src/containerapp/azext_containerapp/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,3 +726,11 @@ def parse_build_env_vars(env_list):
})

return env_var_def


def is_cloud_supported_by_connected_env(cli_ctx):
from azure.cli.core.cloud import CloudNameEnum
if cli_ctx.cloud.name == CloudNameEnum.AzureCloud:
return True

return False
48 changes: 25 additions & 23 deletions src/containerapp/azext_containerapp/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
transform_telemetry_app_insights_values,
transform_telemetry_otlp_values,
transform_telemetry_otlp_values_by_name_wrapper)
from ._utils import is_cloud_supported_by_connected_env


def load_command_table(self, args):
Expand Down Expand Up @@ -151,32 +152,33 @@ def load_command_table(self, args):
g.custom_command('apply', 'patch_apply')
g.custom_command('interactive', 'patch_interactive')

with self.command_group('containerapp connected-env', is_preview=True) as g:
g.custom_show_command('show', 'show_connected_environment')
g.custom_command('list', 'list_connected_environments')
g.custom_command('create', 'create_connected_environment', supports_no_wait=True, exception_handler=ex_handler_factory())
g.custom_command('delete', 'delete_connected_environment', supports_no_wait=True, confirmation=True, exception_handler=ex_handler_factory())

with self.command_group('containerapp connected-env dapr-component', is_preview=True) as g:
g.custom_command('list', 'connected_env_list_dapr_components')
g.custom_show_command('show', 'connected_env_show_dapr_component')
g.custom_command('set', 'connected_env_create_or_update_dapr_component')
g.custom_command('remove', 'connected_env_remove_dapr_component')

with self.command_group('containerapp connected-env certificate', is_preview=True) as g:
g.custom_command('list', 'connected_env_list_certificates')
g.custom_command('upload', 'connected_env_upload_certificate')
g.custom_command('delete', 'connected_env_delete_certificate', confirmation=True, exception_handler=ex_handler_factory())

with self.command_group('containerapp connected-env storage', is_preview=True) as g:
g.custom_show_command('show', 'connected_env_show_storage')
g.custom_command('list', 'connected_env_list_storages')
g.custom_command('set', 'connected_env_create_or_update_storage', supports_no_wait=True, exception_handler=ex_handler_factory())
g.custom_command('remove', 'connected_env_remove_storage', supports_no_wait=True, confirmation=True, exception_handler=ex_handler_factory())
if is_cloud_supported_by_connected_env(self.cli_ctx):
with self.command_group('containerapp connected-env', is_preview=True) as g:
g.custom_show_command('show', 'show_connected_environment')
g.custom_command('list', 'list_connected_environments')
g.custom_command('create', 'create_connected_environment', supports_no_wait=True, exception_handler=ex_handler_factory())
g.custom_command('delete', 'delete_connected_environment', supports_no_wait=True, confirmation=True, exception_handler=ex_handler_factory())

with self.command_group('containerapp connected-env dapr-component', is_preview=True) as g:
g.custom_command('list', 'connected_env_list_dapr_components')
g.custom_show_command('show', 'connected_env_show_dapr_component')
g.custom_command('set', 'connected_env_create_or_update_dapr_component')
g.custom_command('remove', 'connected_env_remove_dapr_component')

with self.command_group('containerapp connected-env certificate', is_preview=True) as g:
g.custom_command('list', 'connected_env_list_certificates')
g.custom_command('upload', 'connected_env_upload_certificate')
g.custom_command('delete', 'connected_env_delete_certificate', confirmation=True, exception_handler=ex_handler_factory())

with self.command_group('containerapp connected-env storage', is_preview=True) as g:
g.custom_show_command('show', 'connected_env_show_storage')
g.custom_command('list', 'connected_env_list_storages')
g.custom_command('set', 'connected_env_create_or_update_storage', supports_no_wait=True, exception_handler=ex_handler_factory())
g.custom_command('remove', 'connected_env_remove_storage', supports_no_wait=True, confirmation=True, exception_handler=ex_handler_factory())

with self.command_group('containerapp env java-component', is_preview=True) as g:
g.custom_command('list', 'list_java_components')

with self.command_group('containerapp env java-component spring-cloud-config',
deprecate_info=self.deprecate(redirect='containerapp env java-component config-server-for-spring', hide=True)) as g:
g.custom_command('create', 'create_config_server_for_spring', supports_no_wait=True)
Expand Down
Loading

0 comments on commit 8e7fe30

Please sign in to comment.