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

deployImageApi implementation #229

Merged
merged 19 commits into from
Feb 1, 2023
Merged

Conversation

MicroFish91
Copy link
Contributor

@MicroFish91 MicroFish91 commented Dec 12, 2022

Edit: Ready for review.

@MicroFish91 MicroFish91 changed the title deployImageApi command implementation deployImageApi implementation Dec 12, 2022
@bwateratmsft
Copy link
Contributor

I wasn't sure how much string validation was necessary on the passed imageName. Right now it's pretty minimal - I just check to make sure there a matching number of args after we split up the imageName using .split('/'). I could definitely add some more robust validation, but wasn't sure how deep to go on it.

We can break up the image name in the Docker extension to pretty much any degree required, so if a slightly different format for the passed-in data is easier, feel free to change it.

@MicroFish91 MicroFish91 marked this pull request as ready for review January 9, 2023 17:19
@MicroFish91 MicroFish91 requested a review from a team as a code owner January 9, 2023 17:19
@MicroFish91 MicroFish91 marked this pull request as draft January 9, 2023 21:30
import { localize } from "./localize";

export namespace imageNameUtils {
export function detectRegistryDomain(imageName: string): SupportedRegistries | undefined {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a little leery of the regex approach here, since there's potential for mistakes. For example, if I supply an image with the name "azurecr.io.foo/bar:baz", it would be incorrectly detected as belonging to ACR. True, this example is contrived, but my gut is telling me something else could happen.

We can supply the registry domain specifically, as part of the contract. The Docker extension already has some fairly sophisticated image name parsers that we trust. Given the domain, a more exact regex could be applied, such as /\.azurecr\.io$/i (which demands "azurecr.io" be the end of the domain, and that it start with a dot, e.g. "myfoo.azurecr.io" passes, but "myfoo.azurecr.iot" does not). For Docker Hub, I think /^docker\.io$/i is sufficient.

Copy link
Contributor Author

@MicroFish91 MicroFish91 Jan 20, 2023

Choose a reason for hiding this comment

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

Let me know if you think something like this would be ok!

image

Instead of amending the contract, just parsing the registryName off of the imageName and doing those regex searches on that value.

Copy link
Contributor

@bwateratmsft bwateratmsft Jan 24, 2023

Choose a reason for hiding this comment

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

Instead of loginServer, could we just send registry (the domain), and for Docker Hub's case just map loginServer to the other value it wants? IIRC, for ACR and others the login server === registry domain right? Generally speaking I'd prefer to keep all the parsing/splitting in the Docker extension, but having a straightforward mapping of registry -> login server seems safe.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. I have a couple things I want to clarify with you offline before making the changes

@MicroFish91 MicroFish91 marked this pull request as ready for review January 20, 2023 22:43
@MicroFish91
Copy link
Contributor Author

MicroFish91 commented Jan 30, 2023

Ready for review. Latest work contingent on the changes from this PR

@MicroFish91 MicroFish91 merged commit b6ed3d6 into bmw/deployImageApi Feb 1, 2023
@MicroFish91 MicroFish91 deleted the mwf/deployImageApi branch February 1, 2023 01:08
bwateratmsft added a commit that referenced this pull request Feb 7, 2023
* Add command for deploying to ACA from Docker extension

* Explicitly make node undefined

* `deployImageApi` implementation (#229)

* Fix bad merge

* Alex's feedback

* Export not needed

---------

Co-authored-by: Matthew Fisher <[email protected]>
@microsoft microsoft locked and limited conversation to collaborators Mar 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants