-
Notifications
You must be signed in to change notification settings - Fork 175
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
cmd/cp: Fix --from-oci-layout when using full reference #1507
base: main
Are you sure you want to change the base?
cmd/cp: Fix --from-oci-layout when using full reference #1507
Conversation
Copying an image from an OCI layout with a value like "foo/bar:latest" for "org.opencontainers.image.ref.name" was failing with: ``` $ oras cp --from-oci-layout ./myimage:foo/bar:latest localhost:5000/foo:latest Error: invalid argument "./myimage:foo/bar:latest": failed to find path "./myimage:foo/bar:": stat /myimage:foo/bar: no such file or directory ``` According to [0], foo/bar:latest if a valid value for "org.opencontainers.image.ref.name", so the command should work. This commit fixes that by using strings.Index() instead of strings.LastIndex(). [0]: https://github.com/opencontainers/image-spec/blob/v1.1.0-rc5/annotations.md Signed-off-by: Mauricio Vásquez <[email protected]>
{"Empty digest", "path@", "path", "", false}, | ||
{"Empty tag", "path:", "path", "", false}, | ||
{"path and digest", "path@digest", "path", "digest", false}, | ||
{"path and tag", "path:tag", "path", "tag", false}, | ||
{"path with full reference", "path:repo:tag", "path", "repo:tag", false}, |
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.
Shouldn't the path be path:repo
?
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.
path:repo
fails, but the included content passes
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.
LGTM
{"Empty digest", "path@", "path", "", false}, | ||
{"Empty tag", "path:", "path", "", false}, | ||
{"path and digest", "path@digest", "path", "digest", false}, | ||
{"path and tag", "path:tag", "path", "tag", false}, | ||
{"path with full reference", "path:repo:tag", "path", "repo:tag", false}, |
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.
path:repo
fails, but the included content passes
if err != nil { | ||
return errors.Join(err, errdef.ErrInvalidReference) | ||
} | ||
} else if idx := strings.Index(raw, ":"); idx != -1 { |
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.
} else if idx := strings.Index(raw, ":"); idx != -1 { | |
} else if idx := strings.LastIndex(raw, ":"); idx != -1 { |
What this PR does / why we need it:
Copying an image from an OCI layout with a value like "foo/bar:latest" for "org.opencontainers.image.ref.name" was failing with:
According to 0, foo/bar:latest if a valid value for "org.opencontainers.image.ref.name", so the command should work.
This commit fixes that by using strings.Index() instead of strings.LastIndex().
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #1505
Please check the following list: