Skip to content

Commit aafd7fa

Browse files
committed
remove increment flag on imageContexts.new()
Rename the methods to match my understanding of the behaviour. Signed-off-by: Daniel Nephin <[email protected]>
1 parent 4d62f67 commit aafd7fa

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

builder/dockerfile/dispatchers.go

+2-6
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ func from(b *Builder, args []string, attributes map[string]bool, original string
189189
return err
190190
}
191191
b.resetImageCache()
192-
if _, err := b.imageContexts.new(ctxName, true); err != nil {
192+
if _, err := b.imageContexts.add(ctxName); err != nil {
193193
return err
194194
}
195195

@@ -846,11 +846,7 @@ func mountByRef(b *Builder, name string) (*imageMount, error) {
846846
if err != nil {
847847
return nil, err
848848
}
849-
im, err := b.imageContexts.new("", false)
850-
if err != nil {
851-
return nil, err
852-
}
853-
im.id = image.ImageID()
849+
im := b.imageContexts.newImageMount(image.ImageID())
854850
return im, nil
855851
}
856852

builder/dockerfile/imagecontext.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,11 @@ type imageContexts struct {
2222
currentName string
2323
}
2424

25-
func (ic *imageContexts) new(name string, increment bool) (*imageMount, error) {
25+
func (ic *imageContexts) newImageMount(id string) *imageMount {
26+
return &imageMount{ic: ic, id: id}
27+
}
28+
29+
func (ic *imageContexts) add(name string) (*imageMount, error) {
2630
im := &imageMount{ic: ic}
2731
if len(name) > 0 {
2832
if ic.byName == nil {
@@ -33,10 +37,8 @@ func (ic *imageContexts) new(name string, increment bool) (*imageMount, error) {
3337
}
3438
ic.byName[name] = im
3539
}
36-
if increment {
37-
ic.list = append(ic.list, im)
38-
}
3940
ic.currentName = name
41+
ic.list = append(ic.list, im)
4042
return im, nil
4143
}
4244

0 commit comments

Comments
 (0)