Skip to content

Add ACR Image Import Commands#6375

Merged
troydai merged 47 commits into
Azure:devfrom
AzureCR:natalie-release
May 31, 2018
Merged

Add ACR Image Import Commands#6375
troydai merged 47 commits into
Azure:devfrom
AzureCR:natalie-release

Conversation

@NatalieGong
Copy link
Copy Markdown


This checklist is used to make sure that common guidelines for a pull request are followed.

  • The PR has modified HISTORY.rst describing any customer-facing, functional changes. Note that this does not include changes only to help content. (see Modifying change log).

  • I adhere to the Command Guidelines.

@promptws
Copy link
Copy Markdown

View a preview at https://prompt.ws/r/Azure/azure-cli/6375
This is an experimental preview for @microsoft users.

@codecov-io
Copy link
Copy Markdown

codecov-io commented May 17, 2018

Codecov Report

Merging #6375 into dev will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@         Coverage Diff         @@
##           dev   #6375   +/-   ##
===================================
  Coverage    0%      0%           
===================================
  Files       11      11           
  Lines      133     133           
  Branches     9       9           
===================================
  Misses     133     133

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2cd0ed3...fbd1a60. Read the comment docs.

Copy link
Copy Markdown
Member

@djyou djyou left a comment

Choose a reason for hiding this comment

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

Just some minor comments.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

NIT: command

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you also add this Case 3 to help -> examples?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These two lines can be combined to elif not resource_id?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Combined

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Check if this API works with Classic registry, remove this validation if so.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Will there be additional commands within the acr image group? If not, this should be acr import-image or potentially acr import. If there will be additional commands in this group (even if its a future PR) then an image group is appropriate.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How is this different from the repository group which says "Manage repositories (image names) for Azure Container Registries"?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this basically copying from one registry to another or is it from any source to an ACR? It sounds like "copy" might be the more appropriate verb than "import". Import usually implies converting a file into resource, so there's a transformation. This sounds like just copying an image into the registry. But I could be misinterpreting.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Import images from registries is the start. I guess we will add import from other places as docker hub etc.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm a little confused by this argument. Why --image and not --tags?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Changed to target-tags

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

"manifest-only"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yes

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is the container registry referred to here always another ACR resource? If so, this could just be called 'registry' or 'source_registry'. It should also support names or IDs. https://github.com/Azure/azure-cli/blob/dev/doc/authoring_command_modules/authoring_commands.md#supporting-name-or-id-parameters

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The resource id is used for talking with ARM when doing cross subscription importing. I believe customers have access to it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It still needs to support the name-or-id paradigm of the CLI. If it's a generic resource it's a bit more annoying than a strongly-typed resource like another ACR.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It needs to enable our client side CLI to lookup resources cross subscription.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To summarize the discussion we had with @djyou
The goal is to make --source a required parameter which can be a partial image name and have -r as a parameter which will be used to derive the source which can be a name or dns or fully fully qualified resource id.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this? Are there ever more than 1? If so, why return nothing in that case?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch. Fixed it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I believe prompt already handles the "no TTY" case.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Nope it does not.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It does in that it throws the NoTTYException, which you handle here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The CLI will already wrap this in a LRO. You can just return client.import_image(....)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Ok

Copy link
Copy Markdown
Member

@tjprescott tjprescott May 18, 2018

Choose a reason for hiding this comment

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

Since you are adding the first relevant item for this release, you can remove "Minor fix" above. Also, recommend:

* Added `acr image import` command. 

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks

Copy link
Copy Markdown
Contributor

@troydai troydai left a comment

Choose a reason for hiding this comment

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

Aside from minor comments, looks good to me.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

2.0.25
++++++
* Minor Fix
* Add 'acr import' command.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unnecessary variable.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Removed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should this be a warning instead of a debug? Debug level logging is usually buried deeply. If this is a message impacting customer's decision process, it should be more visible.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unnecessary else since the raise will terminate the function.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed

@NatalieGong NatalieGong force-pushed the natalie-release branch 2 times, most recently from 7e8a2d3 to 2fb84f0 Compare May 23, 2018 16:50
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can you just make it consistent to -n registry for all examples

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@djyou why are we using _ for parameter name seperators shouldn't this be --target-tags
Either way does not align with --image which is what build uses and I think we need to have the same convention here.

@NatalieGong NatalieGong requested a review from yugangw-msft May 30, 2018 01:08
Natalie and others added 13 commits May 29, 2018 18:57
* Add support for image import

* Enable image import commands

* Enable Image Import Commands

* Error handling

* Rewrite acr_image_import + Help messages

* Image import without support of docker hub and cross-subscription registires

* Listify tags and repository arguments for image import

* Support import image cross subscription

* Help message for arguments
* Enable Image Import Commands (#148)

* Add support for image import

* Enable image import commands

* Enable Image Import Commands

* Error handling

* Rewrite acr_image_import + Help messages

* Image import without support of docker hub and cross-subscription registires

* Listify tags and repository arguments for image import

* Support import image cross subscription

* Help message for arguments

* Enable Image Import Commands with Prompt for resource_id

* Add help message

* .

* Move tty to _utils

* Enable Image Import Commands with Prompt for resource_id

* Add help message

* .

* Move tty to _utils

* Move prompt out of _util

* .

* Validate using login server

* .

* .
* Make util method more generic, update help

* Improve examples
* Enable Image Import Commands (#148)

* Add support for image import

* Enable image import commands

* Enable Image Import Commands

* Error handling

* Rewrite acr_image_import + Help messages

* Image import without support of docker hub and cross-subscription registires

* Listify tags and repository arguments for image import

* Support import image cross subscription

* Help message for arguments

* Test cases for image import

* Test cases for image import

* Naming
Copy link
Copy Markdown
Member

@djyou djyou left a comment

Choose a reason for hiding this comment

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

Just a few minor comments.

examples:
- name: Import an image to the target registry and inherits repository:tag from source.
text: >
az acr import -n MyRegistry --source SourceRegistry.azurecr.io/SourceRepository:SourceTag
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

At least lower case repository name as it can only be lower case. I would recommend lower case login server and tag also. Tag is case sensitive.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Lower-cased

with self.argument_context('acr import') as c:
c.argument('source', help="A source identifier, either fully qualified (e.g. 'registry.azurecr.io/repository:tag') or partially qualified (e.g. 'repository@sha').")
c.argument('source_registry', options_list=['--registry', '-r'], help='The container registry of the source. It can be name, canonical name (login server) or resource ID of the source registry.')
c.argument('target_tags', options_list=['--target-tags', '-t'], help="The repository and optionally a tag in the 'repository:tag' format for target images.", action='append')
Copy link
Copy Markdown
Member

@djyou djyou May 30, 2018

Choose a reason for hiding this comment

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

--image?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

  1. It is shortened as '-t'
  2. As the variable itself implies "target_tags"

c.argument('no_logs', help="Do not show logs after successfully queuing the build.", action='store_true')

with self.argument_context('acr import') as c:
c.argument('source', help="A source identifier, either fully qualified (e.g. 'registry.azurecr.io/repository:tag') or partially qualified (e.g. 'repository@sha').")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

NIT: add a comma after e.g.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added

)

SOURCE_REGISTRY_MISING = "Please specify the source container registry: "
IMPORT_NOT_SUPPORTED = "Imports are only supported for managed registries."
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

NIT: Import is ...

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The word "Imports" is paired with "Managed registries"


SOURCE_REGISTRY_MISING = "Please specify the source container registry: "
IMPORT_NOT_SUPPORTED = "Imports are only supported for managed registries."
INVALID_SOURCE_IMAGE = "Please specify source image in the form of '[registry.azurecr.io/]repository:tag' or 'repository@sha'."
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[registry.azurecr.io/]repository[:tag] or [registry.azurecr.io/]repository@sha?

Copy link
Copy Markdown
Author

@NatalieGong NatalieGong May 31, 2018

Choose a reason for hiding this comment

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

Lines too long and also I have included the example for import-by-sha in the az acr import -h

except NoTTYException:
raise CLIError(NO_TTY_ERROR)
registry_by_registry_name = get_registry_from_name(cmd.cli_ctx, source_registry)
registry_by_login_server = get_registry_from_name(cmd.cli_ctx, source_registry)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you not call get_registry_from_name twice?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Combined

except NoTTYException:
raise CLIError(NO_TTY_ERROR)

source_image = source[slash + 1:]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also move this validation earlier.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Moved

@NatalieGong
Copy link
Copy Markdown
Author

@NatalieGong NatalieGong reopened this May 31, 2018

with self.argument_context('acr import') as c:
c.argument('source', help="A source identifier, either fully qualified (e.g., 'registry.azurecr.io/repository:tag') or partially qualified (e.g., 'repository@sha').")
c.argument('source_registry', options_list=['--registry', '-r'], help='The container registry of the source. It can be name, canonical name (login server) or resource ID of the source registry.')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are we introducing canonical name to CLI now? /cc @sajayantony

@troydai
Copy link
Copy Markdown
Contributor

troydai commented May 31, 2018

@tjprescott this is for this sprint, please take another look.

c.argument('no_logs', help="Do not show logs after successfully queuing the build.", action='store_true')

with self.argument_context('acr import') as c:
c.argument('source', help="The source identifier in the format '[registry.azurecr.io/]repository:tag' or '[registry.azurecr.io/]repository@digest'.")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

'[registry.azurecr.io/]repository[:tag]'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I do not think tag is optional for source...unless you want to import a collection of images rather than a single one, do you?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could you please validate? Think doesn't help here ...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Cool

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

What if somebody is so unlucky that there is no latest tag in that repository he/she specifies?

Copy link
Copy Markdown
Author

@NatalieGong NatalieGong May 31, 2018

Choose a reason for hiding this comment

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

It is possible right? Like all the images either built or imported into the repository were not defaulted to latest when they were born in that repository.

Copy link
Copy Markdown
Author

@NatalieGong NatalieGong May 31, 2018

Choose a reason for hiding this comment

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

How do you think users might expect under such situation?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Optionalized the tag


helps['acr import'] = """
type: command
short-summary: Imports to the container registry from source.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

NIT: Imports an image ...?


with self.argument_context('acr import') as c:
c.argument('source', help="The source identifier in the format '[registry.azurecr.io/]repository:tag' or '[registry.azurecr.io/]repository@digest'.")
c.argument('source_registry', options_list=['--registry', '-r'], help='The container registry of the source. It can be name, login server or resource ID of the source registry.')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

NIT: The source container registry.


if registry_name:
elements = [item for item in registry_list if
item.login_server.lower() == login_server.lower() or item.name.lower() == registry_name.lower()]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What if login_server is None?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

login_server will not be None guaranteed by the caller

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How does the caller even know from the method signature without reading its implementation?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Line 53:
It promises a none empty value for source_registry because the value will be either from the command directly or from the interactivity by prompt. Again, as the client side, we cannot validate it however we can guarantee a nonempty value.

Similar for line 61 but the reason differs a little. If the source_registry_login_server is empty or none, an CLIError has already be thrown before reaching the call.

Copy link
Copy Markdown
Member

@djyou djyou May 31, 2018

Choose a reason for hiding this comment

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

But you are shipping an open source project with a util method that can possibly be used by anyone and it's clearly broken if called otherwise.

Does caller have to handle the exception if login_server is None?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I have done validation on the parameter for registry_name

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

For the login server, yes, caller is the layer to handle exceptions before the actual call.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this method should be generic enough to accept either name or login_server (i.e., both should be default to None). Just use the non-empty ones to compare and filter the results.

I am hoping this method can further be reused to support scenarios such as acr login -n registry.azurecr.io.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For the login server, yes, caller is the layer to handle exceptions before the actual call.

It makes no sense to me that your method takes a None value and doesn't handle it but throws a null reference exception out and wishes the caller can handle it.

Copy link
Copy Markdown
Author

@NatalieGong NatalieGong May 31, 2018

Choose a reason for hiding this comment

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

I mean the caller throws an exception when the login server is empty before the method actually gets called. Please see Line 59 for now. Btw I will combine the two errors together as you suggested :-)

if not elements:
return None
elif len(elements) > 1:
logger.warning("More than one registry is found by %s.", login_server)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

What if login_server is None?


SOURCE_REGISTRY_MISING = "Please specify the source container registry name, login server or resource ID: "
IMPORT_NOT_SUPPORTED = "Imports are only supported for managed registries."
INVALID_SOURCE_IMAGE = "Please specify source image in the form of '[registry.azurecr.io/]repository:tag' or " \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

'[registry.azurecr.io/]repository[:tag]', also the source image?
Could you check if tag is optional or not?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Tag for the target image is optional. For the source, I do not think so.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I recall the server side attaches a latest if tag is empty, could you validate?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is IMPORT_NOT_SUPPORTED a client side check. I think we should move this to the server and throw if called on a classic registry. - @nathana1

Copy link
Copy Markdown
Author

@NatalieGong NatalieGong May 31, 2018

Choose a reason for hiding this comment

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

Wow really? I am so curious. Can you explain more on what you meant by moving to the server? As I have checked all the modules in the commands including build-task, custom, repository and web hook. All of them seem to use the validate_managed_registries and have defined a static constant to be XXX_NOT_SUPPORTED

raise CLIError(INVALID_SOURCE_IMAGE)
source_registry_login_server = source[:slash]
if not source_registry_login_server:
raise CLIError(INVALID_SOURCE_IMAGE)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

source_registry_login_server = source[:slash]
source_image = source[slash + 1:]
if not source_registry_login_server or not source_image:
  raise CLIError(INVALID_SOURCE_IMAGE)

source_registry = prompt(SOURCE_REGISTRY_MISING)
except NoTTYException:
raise CLIError(NO_TTY_ERROR)
registry_from_name = get_registry_from_name(cmd.cli_ctx, source_registry, source_registry)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

NIT: I think you can just call this registry since it's an registry object and isn't necessarily obtained from name (can be login server too).

registry_from_name = get_registry_from_name(cmd.cli_ctx, source_registry_login_server)

if registry_from_name:
if source_registry and registry_from_name.id != source_registry:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

source_registry can be specified as a name and this validation will fail. I think you need to use the is_valid_resource_id method to differentiate the two cases anyway.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

No. I do not think so.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

But thanks for pointing this out as you helped me recall the reason why I need the two lines:
if registry_from_name:
source_registry = registry_from_name.id

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

They are necessary because it ensures that when the control flow reaches Line 64, source_registry can only be none or resource id

Copy link
Copy Markdown
Member

@tjprescott tjprescott left a comment

Choose a reason for hiding this comment

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

LGTM. I still don't get the --image/-t pairing, but I'll leave that up to you.

with self.argument_context('acr import') as c:
c.argument('source', help="The source identifier in the format '[registry.azurecr.io/]repository[:tag]' or '[registry.azurecr.io/]repository@digest'.")
c.argument('source_registry', options_list=['--registry', '-r'], help='The source container registry can be name, login server or resource ID of the source registry.')
c.argument('target_tags', options_list=['--image', '-t'], help="The repository and optionally a tag in the 'repository:tag' format for target images.", action='append')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm still confused by this aliasing. Why --image and -t? Why not -i?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is to align with docker's convention as well as build-task.

get_registry_from_name
)

SOURCE_REGISTRY_MISING = "Please specify the source container registry name, login server or resource ID: "
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

SOURCE_REGISTRY_MISSING

raise CLIError(INVALID_SOURCE_IMAGE)
registry = get_registry_from_name(cmd.cli_ctx, source_registry_login_server)
if source_registry:
registry_from_source = get_registry_from_name(cmd.cli_ctx, source_registry, source_registry)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please avoid calling this list operation again, it's an expensive operation that fans out to all regions. You can call it once but filter twice.

source_registry = prompt(SOURCE_REGISTRY_MISING)
except NoTTYException:
raise CLIError(NO_TTY_ERROR)
registry_from_source = get_registry_from_name(cmd.cli_ctx, source_registry, source_registry)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

If source_registry is already a resource ID, this request would be a waste since it must return None, or you need to support get registry from resource ID.

@troydai
Copy link
Copy Markdown
Contributor

troydai commented May 31, 2018

Please fix the CI before the end of the day so we can merge this in time for this release.

nataliegong added 2 commits May 31, 2018 14:31
Copy link
Copy Markdown
Member

@djyou djyou left a comment

Choose a reason for hiding this comment

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

LGTM with one minor comment.

raise CLIError(NO_TTY_ERROR)
registry_from_source = get_registry_from_name_or_login_server(cmd.cli_ctx, source_registry, source_registry)
if registry_from_source:
source_registry = registry_from_source.id
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Add a condition to execute the above 3 lines only if source_registry is not a valid resource id.

@troydai troydai merged commit dbe2440 into Azure:dev May 31, 2018
@NatalieGong NatalieGong deleted the natalie-release branch June 13, 2018 20:46
@ghost ghost added Container Registry az acr and removed ACR labels Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants