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

replace resolveimageconfig with generic sourcemetaresolver #4563

Merged
merged 2 commits into from
Feb 13, 2024

Conversation

tonistiigi
Copy link
Member

follow-up for #4209

This is more versatile function that works for any source,
not just images.

It can be used together with a policy that switches
between input and output source as well as for adding
additional metadata for other sources in the future.

@cpuguy83

@tonistiigi tonistiigi force-pushed the sourceresolver branch 2 times, most recently from c76c772 to 6a13c1f Compare January 17, 2024 07:30
This was unfortuantely just wrong.
The reference for a named context is is fetched using
`nameWithPlatform`.
When a source policy mutated the ref this was recursively trying to
resolve the reference again, however it was using the mutated ref as the
new context name (and even that was not correct because `name` was made
the new `nameWithPlatform` which is what is actually used as the key
rather than `name`).

This shouldn't be mutating the context key but rather the ref the
context is pointing to.

This change updates the build opts such the value pointed at by
`nameWithPlatform` in the build opts map points to the updated ref
instead of the original.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
@tonistiigi tonistiigi force-pushed the sourceresolver branch 8 times, most recently from 76c8b86 to aaf5d86 Compare February 9, 2024 06:18
@tonistiigi tonistiigi self-assigned this Feb 9, 2024
@tonistiigi tonistiigi marked this pull request as ready for review February 9, 2024 19:48
@tonistiigi
Copy link
Member Author

@cpuguy83 This is green now. I have follow-ups coming that change the Dockerfile to use new method and add the possibility for sourcepolicy to switch from non-image to image but would be good to get the base in on its own so it doesn't grow too large.

@tonistiigi tonistiigi added this to the v0.13.0 milestone Feb 9, 2024
Copy link
Member

@cpuguy83 cpuguy83 left a comment

Choose a reason for hiding this comment

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

Much cleaner.
Overal looks good, just a couple of things that stood out.

frontend/gateway/grpcclient/client.go Show resolved Hide resolved
@@ -74,15 +74,13 @@ func (e *Engine) Evaluate(ctx context.Context, op *pb.Op) (bool, error) {
return mutated, errors.Wrapf(ErrTooManyOps, "too many mutations on a single source")
}

srcOp := op.GetSource()
if srcOp == nil {
Copy link
Member

Choose a reason for hiding this comment

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

I noticed we are passing op.GetSoruce() directly into Evaluate.
Do we need a nil check?

Copy link
Member Author

Choose a reason for hiding this comment

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

There is a nil check in line 65

This is more versatile function that works for any source,
not just images.

It can be used together with a policy that switches
between input and output source as well as for adding
additional metadata for other sources in the future.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
@AkihiroSuda AkihiroSuda merged commit 47d6583 into moby:master Feb 13, 2024
66 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants