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

containerapp add containerapp-preview extension #6419

Merged
merged 54 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
d0c524e
init containerapp-preview
Greedygre Jun 1, 2023
f7be550
add GA extension dependency
Greedygre Jun 6, 2023
d6d8f7c
add --environment-type
Greedygre Jun 6, 2023
93c8960
fix bug for prompt
Greedygre Jun 7, 2023
62debc5
warning for update extension
Greedygre Jun 7, 2023
a98d7d3
remove useless code
Greedygre Jun 7, 2023
12820f4
fix
Greedygre Jun 7, 2023
d948cdf
remove
Greedygre Jun 8, 2023
1bb1cea
remove setup
Greedygre Jun 8, 2023
2afbe83
fix
Greedygre Jun 8, 2023
42ab370
fix lint
Greedygre Jun 8, 2023
d6beff8
fix test
Greedygre Jun 8, 2023
0cf803f
test tbd
Greedygre Jun 8, 2023
9b9b237
test 0.0.0
Greedygre Jun 8, 2023
7c34333
add create containerapp
Greedygre Jun 13, 2023
1e81de8
fix
Greedygre Jun 13, 2023
ec88eb3
add env and environment type
Greedygre Jun 13, 2023
ac2c33c
set is preview
Greedygre Jun 13, 2023
bd96ab5
fix
Greedygre Jun 14, 2023
724a381
support --yaml with extended-location
Greedygre Jun 14, 2023
88eaa6a
fix extend
Greedygre Jun 15, 2023
94eebe4
add show/delete/list containerapp in preview
Greedygre Jun 16, 2023
6a4fb88
fix preview
Greedygre Jun 19, 2023
2a4a168
fix error
Greedygre Jun 19, 2023
8b17806
fix error
Greedygre Jun 19, 2023
c7410b7
rebase main
Greedygre Jun 19, 2023
4c9f52e
fix delete
Greedygre Jun 19, 2023
8cf2fc8
refactor client and make constants
Greedygre Jun 29, 2023
368fae6
add test for environment type on arc
Greedygre Jul 3, 2023
2618e94
set version
Greedygre Jul 3, 2023
22bb79a
add test yaml
Greedygre Jul 3, 2023
0f0ffb4
fix error
Greedygre Jul 3, 2023
958e075
fix containerapp preview test
Greedygre Jul 3, 2023
c8662e2
add rely GA extension in test
Greedygre Jul 3, 2023
5cd3762
fix test
Greedygre Jul 3, 2023
44e6078
remove useless code
Greedygre Jul 4, 2023
94be4f6
fix install for loading
Greedygre Jul 5, 2023
8cf778f
Update verify_linter.py
wangzelin007 Jul 4, 2023
5446f32
fix recording and set version to 1.0.0b1
Greedygre Jul 5, 2023
52533f7
fix static analysis: blank line at the end
Greedygre Jul 5, 2023
eb2b6e6
Update verify_linter.py
wangzelin007 Jul 5, 2023
fd55f66
fix comments
Greedygre Jul 6, 2023
2e799d9
remove blank line
Greedygre Jul 6, 2023
5faa2ca
remove python 3.6 support in setup and add more comments for command …
Greedygre Jul 6, 2023
37147a9
add test for managed, add helps, parse resource type and compare
Greedygre Jul 7, 2023
8ae8319
add blank line
Greedygre Jul 7, 2023
18f613d
remove prompt logic
Greedygre Jul 10, 2023
fd90a41
fix
Greedygre Jul 10, 2023
c592553
fix
Greedygre Jul 10, 2023
99e67f9
fix help
Greedygre Jul 10, 2023
03aa729
raise error in _get_azext_module
Greedygre Jul 11, 2023
26cf02c
fix comments
Greedygre Jul 11, 2023
a6d4f0d
add a blank line
Greedygre Jul 11, 2023
acecec6
rename _get_azext_containerapp_module
Greedygre Jul 11, 2023
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
Prev Previous commit
Next Next commit
fix preview
  • Loading branch information
Greedygre committed Jul 10, 2023
commit 6a4fb88295daccfdba775091e3c36626cced7129
10 changes: 5 additions & 5 deletions src/containerapp-preview/azext_containerapp_preview/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def load_command_table(self, _):
azext_commands = _get_azext_module(
GA_CONTAINERAPP_EXTENSION_NAME, "azext_containerapp.commands")

with self.command_group('containerapp', is_preview=True) as g:
g.custom_show_command('show', 'show_containerapp', table_transformer=azext_commands.transform_containerapp_output)
g.custom_command('list', 'list_containerapp', table_transformer=azext_commands.transform_containerapp_list_output)
g.custom_command('create', 'create_containerapp', supports_no_wait=True, exception_handler=ex_handler_factory(), table_transformer=azext_commands.transform_containerapp_output)
with self.command_group('containerapp') as g:
Greedygre marked this conversation as resolved.
Show resolved Hide resolved
g.custom_show_command('show', 'show_containerapp', table_transformer=azext_commands.transform_containerapp_output, is_preview=True)
g.custom_command('list', 'list_containerapp', table_transformer=azext_commands.transform_containerapp_list_output, is_preview=True)
g.custom_command('create', 'create_containerapp', supports_no_wait=True, exception_handler=ex_handler_factory(), table_transformer=azext_commands.transform_containerapp_output, is_preview=True)
# g.custom_command('update', 'update_containerapp', supports_no_wait=True, exception_handler=ex_handler_factory(), table_transformer=azext_commands.transform_containerapp_output)
g.custom_command('create', 'create_containerapp', supports_no_wait=True, exception_handler=ex_handler_factory(), table_transformer=azext_commands.transform_containerapp_output)
g.custom_command('create', 'create_containerapp', supports_no_wait=True, exception_handler=ex_handler_factory(), table_transformer=azext_commands.transform_containerapp_output, is_preview=True)
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,24 @@
from azure.cli.core.azclierror import ValidationError, RequiredArgumentMissingError
from msrestazure.tools import parse_resource_id

from ._clients import ManagedEnvironmentClient, ConnectedEnvironmentClient
from ._clients import ManagedEnvironmentClient, ConnectedEnvironmentClient, ContainerAppClient
from ._utils import (_get_azext_module, GA_CONTAINERAPP_EXTENSION_NAME)

logger = get_logger(__name__)


def get_containerapp_base_decorator(cmd, raw_parameters):
azext_decorator = _get_azext_module(GA_CONTAINERAPP_EXTENSION_NAME, "azext_containerapp.containerapp_decorator")

containerapp_base_decorator = azext_decorator.BaseContainerAppDecorator(
cmd=cmd,
client=ContainerAppClient,
raw_parameters=raw_parameters,
models="azext_containerapp._sdk_models"
)
return containerapp_base_decorator


class ContainerAppPreviewCreateDecorator(_get_azext_module(GA_CONTAINERAPP_EXTENSION_NAME, "azext_containerapp.containerapp_decorator").ContainerAppCreateDecorator):
def __init__(
self, cmd: AzCliCommand, client: Any, raw_parameters: Dict, models: str
Expand Down Expand Up @@ -47,8 +59,7 @@ def get_environment_client(self):
if self.get_argument_yaml():
Greedygre marked this conversation as resolved.
Show resolved Hide resolved
yaml_containerapp = self.get_yaml_containerapp()
if type(yaml_containerapp) != dict: # pylint: disable=unidiomatic-typecheck
raise ValidationError(
'Invalid YAML provided. Please see https://aka.ms/azure-container-apps-yaml for a valid containerapps YAML spec.')
raise ValidationError('Invalid YAML provided. Please see https://aka.ms/azure-container-apps-yaml for a valid containerapps YAML spec.')
env = self.azext_default_utils.safe_get(yaml_containerapp, "properties", "environmentId")
if not env:
raise RequiredArgumentMissingError(
Expand All @@ -63,15 +74,13 @@ def get_environment_client(self):
parsed_env = parse_resource_id(env)

# Validate environment type
if parsed_env['resource_type'] == "connectedEnvironments":
if parsed_env.get('resource_type') == "connectedEnvironments":
if environment_type == "managed":
logger.warning(
"User passed a connectedEnvironment resource id but did not specify --environment-type connected. Using environment type connected.")
logger.warning("User passed a connectedEnvironment resource id but did not specify --environment-type connected. Using environment type connected.")
environment_type = "connected"
else:
if environment_type == "connected":
logger.warning(
"User passed a managedEnvironment resource id but specified --environment-type connected. Using environment type managed.")
logger.warning("User passed a managedEnvironment resource id but specified --environment-type connected. Using environment type managed.")

self.set_argument_environment_type(environment_type)
self.set_argument_managed_env(env)
Expand Down
32 changes: 4 additions & 28 deletions src/containerapp-preview/azext_containerapp_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,52 +5,28 @@
from knack.log import get_logger

from ._clients import ContainerAppClient
from .containerapp_decorator import ContainerAppPreviewCreateDecorator
from ._utils import (_get_azext_module, GA_CONTAINERAPP_EXTENSION_NAME)
from .containerapp_decorator import ContainerAppPreviewCreateDecorator, get_containerapp_base_decorator

logger = get_logger(__name__)


def show_containerapp(cmd, name, resource_group_name, show_secrets=False):
raw_parameters = locals()
azext_decorator = _get_azext_module(GA_CONTAINERAPP_EXTENSION_NAME, "azext_containerapp.containerapp_decorator")

containerapp_base_decorator = azext_decorator.BaseContainerAppDecorator(
cmd=cmd,
client=ContainerAppClient,
raw_parameters=raw_parameters,
models="azext_containerapp._sdk_models"
)
containerapp_base_decorator = get_containerapp_base_decorator(cmd, raw_parameters)
containerapp_base_decorator.validate_subscription_registered()

return containerapp_base_decorator.show_containerapp()


def list_containerapp(cmd, resource_group_name=None, managed_env=None):
raw_parameters = locals()
azext_decorator = _get_azext_module(GA_CONTAINERAPP_EXTENSION_NAME, "azext_containerapp.containerapp_decorator")

containerapp_base_decorator = azext_decorator.BaseContainerAppDecorator(
cmd=cmd,
client=ContainerAppClient,
raw_parameters=raw_parameters,
models="azext_containerapp._sdk_models"
)
containerapp_base_decorator = get_containerapp_base_decorator(cmd, raw_parameters)
containerapp_base_decorator.validate_subscription_registered()

return containerapp_base_decorator.list_containerapp()


def delete_containerapp(cmd, name, resource_group_name, no_wait=False):
raw_parameters = locals()
azext_decorator = _get_azext_module(GA_CONTAINERAPP_EXTENSION_NAME, "azext_containerapp.containerapp_decorator")

containerapp_base_decorator = azext_decorator.BaseContainerAppDecorator(
cmd=cmd,
client=ContainerAppClient,
raw_parameters=raw_parameters,
models="azext_containerapp._sdk_models"
)
containerapp_base_decorator = get_containerapp_base_decorator(cmd, raw_parameters)
containerapp_base_decorator.validate_subscription_registered()
return containerapp_base_decorator.delete()

Expand Down