Skip to content

Commit 163961d

Browse files
fix(build): TOOMANYREQUESTS error occurs for the built images
Signed-off-by: Aleksei Igrychev <aleksei.igrychev@palark.com>
1 parent b9032ba commit 163961d

File tree

1 file changed

+33
-31
lines changed

1 file changed

+33
-31
lines changed

pkg/build/image/image.go

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -236,48 +236,50 @@ func (i *Image) SetupBaseImage(ctx context.Context, storageManager manager.Stora
236236

237237
i.baseStageImage = i.Conveyor.GetOrCreateStageImage(i.baseImageReference, nil, nil, i)
238238

239-
var info *image.Info
240-
var err error
241-
242-
info, err = storageManager.GetImageInfo(ctx, i.baseImageReference, storageOpts)
243-
if isUnsupportedMediaTypeError(err) {
244-
if err := logboek.Context(ctx).Default().LogProcess("Pulling base image %s", i.baseStageImage.Image.Name()).
245-
Options(func(options types.LogProcessOptionsInterface) {
246-
options.Style(style.Highlight())
247-
}).
248-
DoError(func() error {
249-
return i.ContainerBackend.PullImageFromRegistry(ctx, i.baseStageImage.Image)
250-
}); err != nil {
251-
return err
252-
}
253-
239+
if i.IsDockerfileImage && i.DockerfileImageConfig.Staged {
240+
var info *image.Info
241+
var err error
254242
info, err = storageManager.GetImageInfo(ctx, i.baseImageReference, storageOpts)
255-
if err != nil {
243+
if isUnsupportedMediaTypeError(err) {
244+
if err := logboek.Context(ctx).Default().LogProcess("Pulling base image %s", i.baseStageImage.Image.Name()).
245+
Options(func(options types.LogProcessOptionsInterface) {
246+
options.Style(style.Highlight())
247+
}).
248+
DoError(func() error {
249+
return i.ContainerBackend.PullImageFromRegistry(ctx, i.baseStageImage.Image)
250+
}); err != nil {
251+
return err
252+
}
253+
254+
info, err = storageManager.GetImageInfo(ctx, i.baseImageReference, storageOpts)
255+
if err != nil {
256+
return fmt.Errorf("unable to get base image %q manifest: %w", i.baseImageReference, err)
257+
}
258+
} else if err != nil {
256259
return fmt.Errorf("unable to get base image %q manifest: %w", i.baseImageReference, err)
257260
}
258-
} else if err != nil {
259-
return fmt.Errorf("unable to get base image %q manifest: %w", i.baseImageReference, err)
260-
}
261261

262-
i.baseStageImage.Image.SetStageDescription(&image.StageDescription{
263-
StageID: nil, // this is not a stage actually, TODO
264-
Info: info,
265-
})
266-
267-
// for _, expression := range info.OnBuild {
268-
// fmt.Printf(">> %q\n", expression)
269-
// }
262+
i.baseStageImage.Image.SetStageDescription(&image.StageDescription{
263+
StageID: nil, // this is not a stage actually, TODO
264+
Info: info,
265+
})
270266

267+
// for _, expression := range info.OnBuild {
268+
// fmt.Printf(">> %q\n", expression)
269+
// }
270+
}
271271
case NoBaseImage:
272272

273273
default:
274274
panic(fmt.Sprintf("unknown base image type %q", i.baseImageType))
275275
}
276276

277-
switch i.baseImageType {
278-
case StageAsBaseImage, ImageFromRegistryAsBaseImage:
279-
if err := i.ExpandDependencies(ctx, EnvToMap(i.baseStageImage.Image.GetStageDescription().Info.Env)); err != nil {
280-
return err
277+
if i.IsDockerfileImage && i.DockerfileImageConfig.Staged {
278+
switch i.baseImageType {
279+
case StageAsBaseImage, ImageFromRegistryAsBaseImage:
280+
if err := i.ExpandDependencies(ctx, EnvToMap(i.baseStageImage.Image.GetStageDescription().Info.Env)); err != nil {
281+
return err
282+
}
281283
}
282284
}
283285

0 commit comments

Comments
 (0)