-
Notifications
You must be signed in to change notification settings - Fork 1k
Parse hostname from image name #11036
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
Open
gpanders
wants to merge
1
commit into
main
Choose a base branch
from
push-moslvqrsrvrt
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| "@cloudflare/containers-shared": minor | ||
| "wrangler": minor | ||
| --- | ||
|
|
||
| Move parseImageName function from wrangler into containers-shared and parse the hostname from the image name | ||
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 |
|---|---|---|
|
|
@@ -361,3 +361,49 @@ export async function cleanupDuplicateImageTags( | |
| } | ||
| } catch {} | ||
| } | ||
|
|
||
| /** | ||
| * Regular expression for matching an image name. | ||
| * | ||
| * See: https://github.com/opencontainers/distribution-spec/blob/v1.1.0/spec.md#pulling-manifests | ||
| */ | ||
| const imageRe = (() => { | ||
| const alphaNumeric = "[a-z0-9]+"; | ||
| const separator = "(?:\\.|_|__|-+)"; | ||
| const port = ":[0-9]+"; | ||
| const host = `${alphaNumeric}(?:(?:${separator}${alphaNumeric})+|(?:${separator}${alphaNumeric})*${port})`; | ||
| const name = `(?:${alphaNumeric}(?:${separator}${alphaNumeric})*/)*${alphaNumeric}(?:${separator}${alphaNumeric})*`; | ||
| const tag = ":([a-zA-Z0-9_][a-zA-Z0-9._-]{0,127})"; | ||
| const digest = "@(sha256:[A-Fa-f0-9]+)"; | ||
| const reference = `(?:${tag}(?:${digest})?|${digest})`; | ||
| return new RegExp(`^(${host}/)?(${name})${reference}$`); | ||
| })(); | ||
|
|
||
| /** | ||
| * Parse a container image name. | ||
| */ | ||
| export function parseImageName(value: string): { | ||
| host?: string; | ||
| name?: string; | ||
| tag?: string; | ||
| digest?: string; | ||
| } { | ||
| const matches = value.match(imageRe); | ||
| if (matches === null) { | ||
| throw new Error( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think we added a UserError to containers shared (prevents the error showing up in wrangler's sentry) |
||
| "Invalid image format: expected NAME:TAG[@DIGEST] or NAME@DIGEST" | ||
| ); | ||
| } | ||
|
|
||
| // Trim trailing slash | ||
| const host = matches[1]?.slice(0, -1); | ||
| const name = matches[2]; | ||
| const tag = matches[3]; | ||
| const digest = matches[4] ?? matches[5]; | ||
|
|
||
| if (tag === "latest") { | ||
| throw new Error('"latest" tag is not allowed'); | ||
| } | ||
|
|
||
| return { host, name, tag, digest }; | ||
| } | ||
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
62 changes: 0 additions & 62 deletions
62
packages/wrangler/src/__tests__/cloudchamber/common.test.ts
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Since this deletes an exported function from
wranglershouldn't it be a new minor version?Or perhaps we should keep a stub for
parseImageNamein Wrangler that just calls the one incontainers-sharedto avoid any breaking changes.Uh oh!
There was an error while loading. Please reload this page.
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.
I thought we were keeping containers changes as patches since it's still beta, but I'm not certain. @emily-shen might know?
I don't see any reason to keep the stub, I like the way it's structured currently, it feels like this belongs in
containers-sharedThere 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.
its only importable from within wrangler, it was never exposed as part of wranglers public api. so no breaking changes :)