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

{Core} Add . in prefix for operation handler #12702

Merged
merged 1 commit into from
Mar 29, 2020
Merged
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/azure-cli-core/azure/cli/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ def get_op_handler(self, operation, operation_group=None):
from azure.cli.core.profiles._shared import get_versioned_sdk_path

for rt in AZURE_API_PROFILES[self.cli_ctx.cloud.profile]:
if operation.startswith(rt.import_prefix):
if operation.startswith(rt.import_prefix + '.'):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this does handles some scenarios (please provide some real use cases in the PR description), this still can't handle the keyvault track 1 and 2 SDKs' compatibility:

Track 1 SDK:

  • azure.keyvault

Track 2 SDK:

  • azure.keyvault.secrets
  • azure.keyvault.keys

azure.keyvault.secrets.SecretClient.xxx and azure.keyvault.keys.KeyClient.xxx will be matched as Track 1 SDK azure.keyvault..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the change itself looks resolving the issue mentioned in description, same question on is there multiple namespaces containing dot after first dot? such as azure.multipleapi.storage.blob, azure.multipleapi.storage.file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jiasli If azure.keyvault is totally replaced with submodules such as azure.keyvault.secrets and azure.keyvault.keys, there will be no problem.
But if the resource type for azure.keyvault still exists with new resource types with azure.keyvault.secrets and azure.keyvault.keys, it will have some problem.

@yungezz There are packages as you mentioned, e.g. azure.mgmt.resource in https://github.com/Azure/azure-cli/blob/dev/src/azure-cli-core/azure/cli/core/profiles/_shared.py#L44-L49 .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MGMT_RESOURCE_FEATURES = ('azure.mgmt.resource.features', 'FeatureClient')
MGMT_RESOURCE_LINKS = ('azure.mgmt.resource.links', 'ManagementLinkClient')
MGMT_RESOURCE_LOCKS = ('azure.mgmt.resource.locks', 'ManagementLockClient')
MGMT_RESOURCE_POLICY = ('azure.mgmt.resource.policy', 'PolicyClient')
MGMT_RESOURCE_RESOURCES = ('azure.mgmt.resource.resources', 'ResourceManagementClient')
MGMT_RESOURCE_SUBSCRIPTIONS = ('azure.mgmt.resource.subscriptions', 'SubscriptionClient')

This doesn't have problem because there is no azure.mgmt.resource that can cause the same conflict as azure.keyvault.

I am ok with this for now, but still we need to figure out a better solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. If you want to using submodules for keyvault, you cannot use azure.keyvault any more.

operation = operation.replace(rt.import_prefix,
get_versioned_sdk_path(self.cli_ctx.cloud.profile, rt,
operation_group=operation_group))
Expand Down