Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix(staged-dockerfile): fix panic which occurs when using dependencie…
…s between images with multistages

Fix images tree merging procedure in the case when merging multistaged dockerfile images sets.

Signed-off-by: Timofey Kirillov <timofey.kirillov@flant.com>
  • Loading branch information
distorhead committed Feb 22, 2023
1 parent b309073 commit 4f6b10e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkg/build/image/images_sets.go
Expand Up @@ -3,13 +3,17 @@ package image
type ImagesSets [][]*Image

func NewImagesSetsBuilder() *ImagesSetsBuilder {
return &ImagesSetsBuilder{}
return &ImagesSetsBuilder{
curSetInd: 0,
nextSetInd: 1,
}
}

type ImagesSetsBuilder struct {
allImages []*Image
imagesSets ImagesSets
curSetInd int
nextSetInd int
}

func (is *ImagesSetsBuilder) GetImagesSets() ImagesSets {
Expand All @@ -30,10 +34,15 @@ func (is *ImagesSetsBuilder) MergeImagesSets(newImagesSets [][]*Image) {
is.allImages = append(is.allImages, img)
}
}

nextSetInd := is.curSetInd + len(newImagesSets)
if nextSetInd > is.nextSetInd {
is.nextSetInd = nextSetInd
}
}

func (is *ImagesSetsBuilder) Next() {
is.curSetInd++
is.curSetInd = is.nextSetInd
}

func (is *ImagesSetsBuilder) getImagesByInd(ind int) []*Image {
Expand Down

0 comments on commit 4f6b10e

Please sign in to comment.