forked from Azure/azure-cli
-
Notifications
You must be signed in to change notification settings - Fork 5
Updated registry creation experience #16
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,8 +6,6 @@ | |
| import re | ||
| import uuid | ||
|
|
||
| from azure.mgmt.resource.resources.models.resource_group import ResourceGroup | ||
|
|
||
| from azure.cli.command_modules.acr.mgmt_acr.models import RegistryNameCheckRequest | ||
|
|
||
| from azure.cli.core._util import CLIError | ||
|
|
@@ -21,6 +19,10 @@ | |
| get_acr_service_client, | ||
| get_arm_service_client | ||
| ) | ||
| from ._arm_utils import arm_get_storage_account_by_name | ||
|
|
||
| import azure.cli.core._logging as _logging | ||
| logger = _logging.get_az_logger(__name__) | ||
|
|
||
| def validate_registry_name(namespace): | ||
| if namespace.registry_name: | ||
|
|
@@ -50,20 +52,39 @@ def validate_registry_name_create(namespace): | |
| def validate_storage_account_name(namespace): | ||
| client = storage_client_factory().storage_accounts | ||
|
|
||
| if namespace.storage_account_name is None: | ||
| if namespace.storage_account_name: | ||
| storage_account_name = namespace.storage_account_name | ||
| if arm_get_storage_account_by_name(storage_account_name) is None: | ||
| logger.warning('Command to create a storage account:') | ||
| logger.warning( | ||
| ' az storage account create ' +\ | ||
| '-n <name> -g <resource-group> -l <location> --sku Standard_LRS') | ||
| logger.warning( | ||
| 'The container registry must be at the same location as the storage account.') | ||
| raise CLIError( | ||
| 'The storage account {} does not exist in the current subscription.'\ | ||
| .format(storage_account_name)) | ||
| else: | ||
| while True: | ||
| storage_account_name = str(uuid.uuid4()).replace('-', '')[:24] | ||
| if client.check_name_availability(storage_account_name).name_available is True: #pylint: disable=E1101 | ||
| namespace.storage_account_name = storage_account_name | ||
| break | ||
| logger.warning( | ||
| 'New storage account with name %s will be created and used.', | ||
| storage_account_name) | ||
| return | ||
|
|
||
| def validate_resource_group_name(namespace): | ||
| client = get_arm_service_client() | ||
|
|
||
| if namespace.resource_group_name: | ||
| if not client.resource_groups.check_existence(namespace.resource_group_name): | ||
| parameters = ResourceGroup(location=namespace.location) | ||
| client.resource_groups.create_or_update(namespace.resource_group_name, parameters) | ||
| client = get_arm_service_client() | ||
| resource_group_name = namespace.resource_group_name | ||
|
|
||
| if not client.resource_groups.check_existence(resource_group_name): | ||
|
||
| logger.warning('Command to create a resource group:') | ||
| logger.warning(' az resource group create -n <name> -l <location>') | ||
| raise CLIError( | ||
| 'The resource group {} does not exist in the current subscription.'\ | ||
| .format(resource_group_name)) | ||
|
|
||
| def validate_password(namespace): | ||
| if namespace.password and not namespace.new_sp: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why delete --dosable-admin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I guess that's the create command sorry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, admin user is by default disabled, so you can only enable it here.