Skip to content

Commit 5c5c168

Browse files
authored
Add comments explaining usage of reference in call to Resolver (#36)
1 parent 10e1847 commit 5c5c168

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/build/frontend.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,13 @@ func resolveStates(ctx context.Context, bopts *BOpts, platform ocispecs.Platform
165165
resolverOpts.ImageOpt = &sourceresolver.ResolveImageOpt{
166166
ResolveMode: llb.ResolveModePreferLocal.String(),
167167
}
168+
169+
// `resolvedBaseStageName.Result` is the image name as it was specified in the Dockerfile
170+
// with the build args applied
171+
// NOTE: DO NOT USE `ref.String()` in the call to ResolveImageConfig
172+
// `ref`` is the qualified reference, with a default domain
173+
// In case of local images, where there is no registry, resolution will fail
174+
// due to the addition of the default domain.
168175
_, digest, img, err := bopts.Resolver.ResolveImageConfig(ctx, resolvedBaseStageName.Result, resolverOpts)
169176
if err != nil {
170177
if err == reference.ErrObjectRequired {
@@ -188,6 +195,7 @@ func resolveStates(ctx context.Context, bopts *BOpts, platform ocispecs.Platform
188195
}
189196
name := strings.TrimSuffix(dref.FamiliarString(named), ":latest")
190197

198+
// pname constructs a platform-qualified image reference in the format buildkit requires for digest resolution
191199
pname := name + "::" + platforms.FormatAll(platforms.Normalize(platform))
192200
imgMetaMap := map[string][]byte{
193201
exptypes.ExporterImageConfigKey: img,

0 commit comments

Comments
 (0)