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

manifest add: check for local images last #1919

Merged
merged 2 commits into from
Apr 2, 2024

Conversation

nalind
Copy link
Member

@nalind nalind commented Mar 18, 2024

When adding a reference to a manifest list or image index, if we are guessing that it's a reference to an image in a registry, check if we can read something from that location instead of assuming it's correct, and if we can't, check for a local image. This will let use use local image IDs to refer to items that we want to add to a list or index.

This would at least provide more of a workaround for #1896, in that specifying the desired image using only its ID would start working.

if err == nil {
src.Close()
}
}
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

did you mean for this conditional to handle the alltransports.parseimagename from earlier ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I expect alltransports.ParseImageName() to fail when given a string that consists of "docker:https://" followed by exactly 64 hex digits.

@@ -325,8 +325,19 @@ func (m *ManifestList) Add(ctx context.Context, name string, options *ManifestLi
if err != nil {
withDocker := fmt.Sprintf("%s:https://%s", docker.Transport.Name(), name)
ref, err = alltransports.ParseImageName(withDocker)
if err == nil {
Copy link
Member

Choose a reason for hiding this comment

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

looks like this whole block up until the LookupImage part is the same in all the places where you touched this so I think it would make sense to move this into a helper function to avoid the duplication

Copy link
Member Author

Choose a reason for hiding this comment

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

Factored out.

When adding a reference to a manifest list or image index, if we are
guessing that it's a reference to an image in a registry, check if we
can read something from that location instead of assuming it's correct,
and if we can't, check for a local image.  This will let use use local
image IDs to refer to items that we want to add to a list or index.

Signed-off-by: Nalin Dahyabhai <[email protected]>
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

LGTM

@rhatdan
Copy link
Member

rhatdan commented Apr 2, 2024

@vrothberg PTAL

@vrothberg
Copy link
Member

No time to review, please don't block on me.

@rhatdan
Copy link
Member

rhatdan commented Apr 2, 2024

/approve
/lgtm

Copy link
Contributor

openshift-ci bot commented Apr 2, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nalind, rhatdan

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved label Apr 2, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit e4c2a97 into containers:main Apr 2, 2024
7 checks passed
@nalind nalind deleted the index-resolve-images branch April 2, 2024 18:54
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.

None yet

5 participants