-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix ResolveImageConfig to evaluate source policy #3956
Conversation
b9f72e4
to
283ccb3
Compare
Looks like panic in CI:
|
4466473
to
ca5b0c0
Compare
All green here now. |
frontend/dockerui/namedcontext.go
Outdated
Platform: opt.Platform, | ||
ResolveMode: opt.ResolveMode, | ||
LogName: fmt.Sprintf("[context %s] load metadata for %s", nameWithPlatform, ref), | ||
ResolverType: llb.ResolverTypeRegistry, | ||
}) | ||
if err != nil { | ||
var e imageutil.ResolveToNonImageError |
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 think this needs to be a pointer because it looks like &ResolveToNonImageError{}
is returned when this error happens.
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.
^
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.
Its passed into errors.As
as a pointer. We don't ever propagate this error beyond this point, though.
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.
https://go.dev/play/p/BQwN9fEeWHl
I don't quite understand how the current one even builds though. I get a build error if I don't remove pointer from func (e ResolveToNonImageError) Error() string {
in that example.
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 see the error in the playground but it makes very little sense to me why it would be failing or why the test suite is passing.
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.
Oh it is passing because that's a panic not a compile error.
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.
It still doesn't look correct to me in the latest version. Now it doesn't error but the As()
check never matches. It's the case1 vs case2 example in the playground example.
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.
Ideally, we could have a test for this as seems to be quite easy to break this behavior.
ca5b0c0
to
04b2bf6
Compare
frontend/dockerui/namedcontext.go
Outdated
Platform: opt.Platform, | ||
ResolveMode: opt.ResolveMode, | ||
LogName: fmt.Sprintf("[context %s] load metadata for %s", nameWithPlatform, ref), | ||
ResolverType: llb.ResolverTypeRegistry, | ||
}) | ||
if err != nil { | ||
var e imageutil.ResolveToNonImageError |
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.
^
1145f69
to
a118f4e
Compare
Before this change, ResolveImageConfig was unaware of source policies. This means that: 1. Images for denied sources may be resolved 2. Image configs may get pulled for sources that are later converted to a different image The update makes it so the image resolver first runs a given ref through the source policy and uses any mutated ref for the actual resolve (instead of the original ref). It also returns the mutated ref so it can be used correctly by the frontend (e.g. don't want to do llb.Image(oldRef@resolvedDigest)). Signed-off-by: Brian Goff <cpuguy83@gmail.com>
a118f4e
to
330cf7a
Compare
Before this change, ResolveImageConfig was unaware of source policies. This means that:
The update makes it so the image resolver first runs a given ref through the source policy and uses any mutated ref for the actual resolve (instead of the original ref).
It also returns the mutated ref so it can be used correctly by the frontend (e.g. don't want to do llb.Image(oldRef@resolvedDigest)).
Fixes #3911