Skip to content

Commit

Permalink
containerapp-preview fix validate and register provider (#6525)
Browse files Browse the repository at this point in the history
  • Loading branch information
Greedygre authored Jul 18, 2023
1 parent b98d889 commit 22ec9b8
Show file tree
Hide file tree
Showing 5 changed files with 2,455 additions and 879 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
CONNECTED_ENVIRONMENT_RESOURCE_TYPE = "connectedEnvironments"
GA_CONTAINERAPP_EXTENSION_NAME = 'containerapp'
MIN_GA_VERSION = '0.3.36'
CONTAINERAPP_NAMESPACE = 'Microsoft.App'
CONTAINER_APPS_RP = "Microsoft.App"
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
CONNECTED_ENVIRONMENT_TYPE,
MANAGED_ENVIRONMENT_RESOURCE_TYPE,
CONNECTED_ENVIRONMENT_RESOURCE_TYPE,
CONTAINERAPP_NAMESPACE)
CONTAINER_APPS_RP)


def validate_env_name_or_id(cmd, namespace):
Expand Down Expand Up @@ -37,7 +37,7 @@ def validate_env_name_or_id(cmd, namespace):
namespace.managed_env = resource_id(
subscription=get_subscription_id(cmd.cli_ctx),
resource_group=namespace.resource_group_name,
namespace=CONTAINERAPP_NAMESPACE,
namespace=CONTAINER_APPS_RP,
type=CONNECTED_ENVIRONMENT_RESOURCE_TYPE,
name=namespace.managed_env
)
Expand All @@ -46,7 +46,7 @@ def validate_env_name_or_id(cmd, namespace):
namespace.managed_env = resource_id(
subscription=get_subscription_id(cmd.cli_ctx),
resource_group=namespace.resource_group_name,
namespace=CONTAINERAPP_NAMESPACE,
namespace=CONTAINER_APPS_RP,
type=MANAGED_ENVIRONMENT_RESOURCE_TYPE,
name=namespace.managed_env
)
9 changes: 5 additions & 4 deletions src/containerapp-preview/azext_containerapp_preview/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from knack.log import get_logger

from ._clients import ContainerAppClient
from ._constants import CONTAINER_APPS_RP
from .containerapp_decorator import ContainerAppPreviewCreateDecorator, get_containerapp_base_decorator

logger = get_logger(__name__)
Expand All @@ -13,21 +14,21 @@
def show_containerapp(cmd, name, resource_group_name, show_secrets=False):
raw_parameters = locals()
containerapp_base_decorator = get_containerapp_base_decorator(cmd, raw_parameters)
containerapp_base_decorator.validate_subscription_registered()
containerapp_base_decorator.validate_subscription_registered(CONTAINER_APPS_RP)
return containerapp_base_decorator.show_containerapp()


def list_containerapp(cmd, resource_group_name=None, managed_env=None):
raw_parameters = locals()
containerapp_base_decorator = get_containerapp_base_decorator(cmd, raw_parameters)
containerapp_base_decorator.validate_subscription_registered()
containerapp_base_decorator.validate_subscription_registered(CONTAINER_APPS_RP)
return containerapp_base_decorator.list_containerapp()


def delete_containerapp(cmd, name, resource_group_name, no_wait=False):
raw_parameters = locals()
containerapp_base_decorator = get_containerapp_base_decorator(cmd, raw_parameters)
containerapp_base_decorator.validate_subscription_registered()
containerapp_base_decorator.validate_subscription_registered(CONTAINER_APPS_RP)
return containerapp_base_decorator.delete_containerapp()


Expand Down Expand Up @@ -87,7 +88,7 @@ def create_containerapp(cmd,
raw_parameters=raw_parameters,
models="azext_containerapp_preview._sdk_models"
)
containerapp_preview_create_decorator.register_provider()
containerapp_preview_create_decorator.register_provider(CONTAINER_APPS_RP)
containerapp_preview_create_decorator.validate_arguments()
containerapp_preview_create_decorator.construct_containerapp()
r = containerapp_preview_create_decorator.create_containerapp()
Expand Down
Loading

0 comments on commit 22ec9b8

Please sign in to comment.