Skip to content

Commit

Permalink
[Containerapp] Handle drop msrestazure dependency, migrate `parse_res…
Browse files Browse the repository at this point in the history
…ource_id`, `is_valid_resource_id`, `resource_id` (#7990)
  • Loading branch information
Greedygre authored Sep 19, 2024
1 parent 0780adb commit 30c2e17
Show file tree
Hide file tree
Showing 25 changed files with 30 additions and 32 deletions.
4 changes: 2 additions & 2 deletions src/containerapp/azext_containerapp/_archive_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
from io import open
import requests
from knack.log import get_logger
from msrestazure.azure_exceptions import CloudError
from azure.cli.core.azclierror import (CLIInternalError)
from azure.cli.core.profiles import ResourceType, get_sdk
from azure.cli.command_modules.acr._constants import TASK_VALID_VSTS_URLS
from azure.core.exceptions import HttpResponseError

logger = get_logger(__name__)

Expand Down Expand Up @@ -47,7 +47,7 @@ def upload_source_code(cmd, client,
resource_group_name, registry_name)
upload_url = source_upload_location.upload_url
relative_path = source_upload_location.relative_path
except (AttributeError, CloudError) as e:
except (AttributeError, HttpResponseError) as e:
raise CLIInternalError("Failed to get a SAS URL to upload context. Error: {}".format(e.message)) from e

if not upload_url:
Expand Down
3 changes: 1 addition & 2 deletions src/containerapp/azext_containerapp/_up_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@
)
from azure.core.exceptions import HttpResponseError
from azure.mgmt.containerregistry import ContainerRegistryManagementClient
from azure.mgmt.core.tools import parse_resource_id, is_valid_resource_id, resource_id
from knack.log import get_logger

from msrestazure.tools import parse_resource_id, is_valid_resource_id, resource_id

from ._client_factory import handle_non_404_status_code_exception
from ._clients import ContainerAppPreviewClient, GitHubActionClient, ContainerAppsJobClient, \
ConnectedEnvironmentClient, ManagedEnvironmentPreviewClient
Expand Down
3 changes: 1 addition & 2 deletions src/containerapp/azext_containerapp/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@
from azure.cli.core.azclierror import (ValidationError, ResourceNotFoundError, CLIError, InvalidArgumentValueError)
from azure.cli.core.commands.client_factory import get_mgmt_service_client, get_subscription_id
from azure.cli.command_modules.containerapp._utils import is_registry_msi_system
from azure.mgmt.core.tools import parse_resource_id, is_valid_resource_id

from azure.mgmt.resource import ResourceManagementClient
from azure.mgmt.servicelinker import ServiceLinkerManagementClient

from knack.log import get_logger
from msrestazure.tools import parse_resource_id, is_valid_resource_id

from ._managed_service_utils import ManagedRedisUtils, ManagedCosmosDBUtils, ManagedPostgreSQLFlexibleUtils, ManagedMySQLFlexibleUtils
from ._clients import ConnectedEnvCertificateClient, ContainerAppPreviewClient, JavaComponentPreviewClient, ManagedEnvironmentPreviewClient
from ._client_factory import custom_location_client_factory, k8s_extension_client_factory, providers_client_factory, \
Expand Down
9 changes: 5 additions & 4 deletions src/containerapp/azext_containerapp/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
# --------------------------------------------------------------------------------------------
# pylint: disable=line-too-long, unused-argument

from msrestazure.tools import is_valid_resource_id
from knack.log import get_logger
from urllib.parse import urlparse

from azure.cli.core.azclierror import (ValidationError, InvalidArgumentValueError,
MutuallyExclusiveArgumentError, RequiredArgumentMissingError)
from azure.cli.command_modules.containerapp._utils import is_registry_msi_system
from azure.mgmt.core.tools import is_valid_resource_id

from ._utils import is_registry_msi_system_environment

from ._constants import ACR_IMAGE_SUFFIX, \
Expand Down Expand Up @@ -63,7 +64,7 @@ def is_java_enhancement_enabled():

def validate_env_name_or_id(cmd, namespace):
from azure.cli.core.commands.client_factory import get_subscription_id
from msrestazure.tools import resource_id, parse_resource_id
from azure.mgmt.core.tools import resource_id, parse_resource_id

if not namespace.managed_env:
return
Expand Down Expand Up @@ -106,7 +107,7 @@ def validate_env_name_or_id(cmd, namespace):

def validate_env_name_or_id_for_up(cmd, namespace):
from azure.cli.core.commands.client_factory import get_subscription_id
from msrestazure.tools import resource_id, parse_resource_id
from azure.mgmt.core.tools import resource_id, parse_resource_id

if not namespace.environment:
return
Expand Down Expand Up @@ -149,7 +150,7 @@ def validate_env_name_or_id_for_up(cmd, namespace):

def validate_custom_location_name_or_id(cmd, namespace):
from azure.cli.core.commands.client_factory import get_subscription_id
from msrestazure.tools import resource_id
from azure.mgmt.core.tools import resource_id

if not namespace.custom_location or not namespace.resource_group_name:
return
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 @@ -5,7 +5,7 @@

# pylint: disable=line-too-long, too-many-statements, bare-except
# from azure.cli.core.commands import CliCommandType
# from msrestazure.tools import is_valid_resource_id, parse_resource_id
# from azure.mgmt.core.tools import is_valid_resource_id, parse_resource_id
from azure.cli.command_modules.containerapp._transformers import (transform_containerapp_output, transform_containerapp_list_output)
from azext_containerapp._client_factory import ex_handler_factory
from ._transformers import (transform_sensitive_values,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
)

from azure.cli.core.commands.client_factory import get_subscription_id
from azure.mgmt.core.tools import parse_resource_id, is_valid_resource_id

from knack.log import get_logger
from knack.util import CLIError

from msrestazure.tools import parse_resource_id, is_valid_resource_id
from msrest.exceptions import DeserializationError

from ._clients import ManagedEnvironmentClient, ConnectedEnvironmentClient, ManagedEnvironmentPreviewClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from knack.log import get_logger
from knack.prompting import prompt_y_n
from knack.util import CLIError
from msrestazure.tools import is_valid_resource_id, parse_resource_id
from azure.mgmt.core.tools import is_valid_resource_id, parse_resource_id

from azure.cli.command_modules.containerapp._utils import certificate_matches, certificate_location_matches, \
load_cert_file, generate_randomized_cert_name, _ensure_identity_resource_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@
from azure.cli.core.commands.client_factory import get_subscription_id
from azure.cli.core.commands import AzCliCommand
from azure.core.exceptions import DeserializationError, ResourceNotFoundError
from azure.mgmt.core.tools import parse_resource_id, is_valid_resource_id

from knack.log import get_logger

from msrestazure.tools import parse_resource_id, is_valid_resource_id

from ._client_factory import handle_raw_exception, handle_non_404_status_code_exception
from ._constants import CONNECTED_ENVIRONMENT_RESOURCE_TYPE, \
MANAGED_ENVIRONMENT_TYPE, CONNECTED_ENVIRONMENT_TYPE, ACR_IMAGE_SUFFIX
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from azure.cli.command_modules.containerapp._utils import safe_get, _get_acr_cred, store_as_secret_and_return_secret_ref, safe_set, \
is_registry_msi_system, set_managed_identity

from msrestazure.tools import parse_resource_id, is_valid_resource_id
from azure.mgmt.core.tools import parse_resource_id, is_valid_resource_id
from knack.log import get_logger

from ._constants import ACR_IMAGE_SUFFIX
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from knack.log import get_logger
from enum import Enum
from typing import Any, Dict
from msrestazure.tools import parse_resource_id
from azure.mgmt.core.tools import parse_resource_id
from azure.cli.core.util import send_raw_request
from azure.cli.core.azclierror import HTTPError
import json
Expand Down
2 changes: 1 addition & 1 deletion src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@
from azure.cli.command_modules.containerapp._models import (
RegistryCredentials as RegistryCredentialsModel,
)
from azure.mgmt.core.tools import parse_resource_id, is_valid_resource_id

from knack.log import get_logger
from knack.prompting import prompt_y_n

from msrestazure.tools import parse_resource_id, is_valid_resource_id
from msrest.exceptions import DeserializationError

from .containerapp_env_certificate_decorator import ContainerappPreviewEnvCertificateListDecorator, \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from copy import deepcopy
from knack.log import get_logger
from msrestazure.tools import resource_id
from azure.mgmt.core.tools import resource_id
from typing import Any, Dict

from azure.cli.core.commands import AzCliCommand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from azure.cli.testsdk.scenario_tests import AllowLargeResponse, live_only
from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer, JMESPathCheck, JMESPathCheckNotExists, JMESPathCheckExists)
from msrestazure.tools import parse_resource_id
from azure.mgmt.core.tools import parse_resource_id

from azext_containerapp.tests.latest.common import (write_test_file, clean_up_test_file)
from .common import TEST_LOCATION, STAGE_LOCATION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from azure.cli.testsdk.scenario_tests import AllowLargeResponse, live_only
from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer, JMESPathCheck)
from msrestazure.tools import parse_resource_id
from azure.mgmt.core.tools import parse_resource_id

from .common import (write_test_file, clean_up_test_file)
from .common import TEST_LOCATION, STAGE_LOCATION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import os

from msrestazure.tools import parse_resource_id
from azure.mgmt.core.tools import parse_resource_id

from azure.cli.testsdk.scenario_tests import AllowLargeResponse
from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer, JMESPathCheck, live_only)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import time
from time import sleep

from msrestazure.tools import parse_resource_id
from azure.mgmt.core.tools import parse_resource_id

from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer, JMESPathCheck, live_only)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import unittest

from azure.cli.command_modules.containerapp._utils import format_location
from msrestazure.tools import parse_resource_id
from azure.mgmt.core.tools import parse_resource_id

from azure.cli.testsdk.reverse_dependency import get_dummy_cli
from azure.cli.testsdk.scenario_tests import AllowLargeResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os

from azure.cli.command_modules.containerapp._utils import format_location
from msrestazure.tools import parse_resource_id
from azure.mgmt.core.tools import parse_resource_id

from azure.cli.testsdk.scenario_tests import AllowLargeResponse
from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer, JMESPathCheck)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import os

from msrestazure.tools import parse_resource_id
from azure.mgmt.core.tools import parse_resource_id

from azure.cli.testsdk.scenario_tests import AllowLargeResponse
from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer, JMESPathCheck)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
import time

from msrestazure.tools import parse_resource_id
from azure.mgmt.core.tools import parse_resource_id

from azure.cli.testsdk.scenario_tests import AllowLargeResponse
from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer, JMESPathCheck)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import os

from msrestazure.tools import parse_resource_id
from azure.mgmt.core.tools import parse_resource_id

from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer, JMESPathCheck)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os

from azure.cli.command_modules.containerapp._utils import format_location
from msrestazure.tools import parse_resource_id
from azure.mgmt.core.tools import parse_resource_id
from azure.cli.testsdk.scenario_tests import AllowLargeResponse
from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer, JMESPathCheck, JMESPathCheckExists, JMESPathCheckNotExists)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import os
import time

from msrestazure.tools import parse_resource_id
from azure.mgmt.core.tools import parse_resource_id

from azure.cli.testsdk.scenario_tests import AllowLargeResponse
from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer, JMESPathCheck)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import time

from azure.cli.command_modules.containerapp._utils import format_location
from msrestazure.tools import parse_resource_id
from azure.mgmt.core.tools import parse_resource_id

from azure.cli.testsdk.scenario_tests import AllowLargeResponse
from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer, JMESPathCheck)
Expand Down
2 changes: 1 addition & 1 deletion src/containerapp/azext_containerapp/tests/latest/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from .common import TEST_LOCATION, STAGE_LOCATION
from azure.cli.core.azclierror import MutuallyExclusiveArgumentError, RequiredArgumentMissingError, InvalidArgumentValueError
from msrestazure.tools import parse_resource_id
from azure.mgmt.core.tools import parse_resource_id

from azure.cli.testsdk import (JMESPathCheck)

Expand Down

0 comments on commit 30c2e17

Please sign in to comment.