Skip to content

Commit f962645

Browse files
committed
storage: rename stagedLayerOptions to layerCreationContents
We use this this typo all the time now so make the naming a bit more clear. Signed-off-by: Paul Holzinger <[email protected]>
1 parent 7022fc7 commit f962645

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

storage/layers.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@ type DiffOptions struct {
196196
Compression *archive.Compression
197197
}
198198

199-
// stagedLayerOptions are the options passed to .create to populate a staged
199+
// layerCreationContents are the options passed to .create to populate a staged
200200
// layer
201-
type stagedLayerOptions struct {
201+
type layerCreationContents struct {
202202
// These are used via the zstd:chunked pull paths
203203
DiffOutput *drivers.DriverWithDifferOutput
204204
DiffOptions *drivers.ApplyDiffWithDifferOpts
@@ -331,7 +331,7 @@ type rwLayerStore interface {
331331
// underlying drivers do not themselves distinguish between writeable
332332
// and read-only layers. Returns the new layer structure and the size of the
333333
// diff which was applied to its parent to initialize its contents.
334-
create(id string, parent *Layer, names []string, mountLabel string, options map[string]string, moreOptions *LayerOptions, writeable bool, slo *stagedLayerOptions) (*Layer, int64, error)
334+
create(id string, parent *Layer, names []string, mountLabel string, options map[string]string, moreOptions *LayerOptions, writeable bool, lc *layerCreationContents) (*Layer, int64, error)
335335

336336
// checkIdOrNameConfict checks if the id or names are already in use and returns an
337337
// error in that case. As Special case if the layer already exists it returns it as
@@ -1447,7 +1447,7 @@ func (r *layerStore) checkIdOrNameConfict(id string, names []string) (*Layer, er
14471447
}
14481448

14491449
// Requires startWriting.
1450-
func (r *layerStore) create(id string, parentLayer *Layer, names []string, mountLabel string, options map[string]string, moreOptions *LayerOptions, writeable bool, slo *stagedLayerOptions) (layer *Layer, size int64, err error) {
1450+
func (r *layerStore) create(id string, parentLayer *Layer, names []string, mountLabel string, options map[string]string, moreOptions *LayerOptions, writeable bool, lc *layerCreationContents) (layer *Layer, size int64, err error) {
14511451
if moreOptions == nil {
14521452
moreOptions = &LayerOptions{}
14531453
}
@@ -1630,31 +1630,31 @@ func (r *layerStore) create(id string, parentLayer *Layer, names []string, mount
16301630
}
16311631

16321632
size = -1
1633-
if slo != nil {
1634-
if slo.stagedLayerExtraction != nil {
1635-
if slo.stagedLayerExtraction.result != nil {
1633+
if lc != nil {
1634+
if lc.stagedLayerExtraction != nil {
1635+
if lc.stagedLayerExtraction.result != nil {
16361636
// The layer is staged, just commit it and update the metadata.
1637-
if err := slo.stagedLayerExtraction.commitLayer(r, layer.ID); err != nil {
1637+
if err := lc.stagedLayerExtraction.commitLayer(r, layer.ID); err != nil {
16381638
cleanupFailureContext = "committing staged layer diff"
16391639
return nil, -1, err
16401640
}
1641-
applyDiffResultToLayer(r, layer, moreOptions, slo.stagedLayerExtraction.result)
1641+
applyDiffResultToLayer(r, layer, moreOptions, lc.stagedLayerExtraction.result)
16421642
} else {
16431643
// The diff was not staged, apply it now here instead.
1644-
if size, err = r.applyDiffWithOptions(layer.ID, moreOptions, slo.stagedLayerExtraction.diff); err != nil {
1644+
if size, err = r.applyDiffWithOptions(layer.ID, moreOptions, lc.stagedLayerExtraction.diff); err != nil {
16451645
cleanupFailureContext = "applying layer diff"
16461646
return nil, -1, err
16471647
}
16481648
}
16491649
} else {
16501650
// staging logic for the chunked pull path
1651-
if err := r.applyDiffFromStagingDirectory(layer.ID, slo.DiffOutput, slo.DiffOptions); err != nil {
1651+
if err := r.applyDiffFromStagingDirectory(layer.ID, lc.DiffOutput, lc.DiffOptions); err != nil {
16521652
cleanupFailureContext = "applying staged directory diff"
16531653
return nil, -1, err
16541654
}
16551655
}
16561656
} else {
1657-
// applyDiffWithOptions() would have updated r.bycompressedsum
1657+
// The layer creation content above would have updated r.bycompressedsum
16581658
// and r.byuncompressedsum for us, but if we used a template
16591659
// layer, we didn't call it, so add the new layer as candidates
16601660
// for searches for layers by checksum

storage/store.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,8 +1452,8 @@ func (s *store) canUseShifting(uidmap, gidmap []idtools.IDMap) bool {
14521452
// On entry:
14531453
// - rlstore must be locked for writing
14541454
// - rlstores MUST NOT be locked
1455-
func (s *store) putLayer(rlstore rwLayerStore, id string, parentLayer *Layer, names []string, mountLabel string, writeable bool, options *LayerOptions, slo *stagedLayerOptions) (*Layer, int64, error) {
1456-
return rlstore.create(id, parentLayer, names, mountLabel, nil, options, writeable, slo)
1455+
func (s *store) putLayer(rlstore rwLayerStore, id string, parentLayer *Layer, names []string, mountLabel string, writeable bool, options *LayerOptions, lc *layerCreationContents) (*Layer, int64, error) {
1456+
return rlstore.create(id, parentLayer, names, mountLabel, nil, options, writeable, lc)
14571457
}
14581458

14591459
// On entry:
@@ -1564,7 +1564,7 @@ func (s *store) PutLayer(id, parent string, names []string, mountLabel string, w
15641564
}
15651565

15661566
var (
1567-
slo *stagedLayerOptions
1567+
lc *layerCreationContents
15681568
options *LayerOptions
15691569
parentLayer *Layer
15701570
)
@@ -1608,7 +1608,7 @@ func (s *store) PutLayer(id, parent string, names []string, mountLabel string, w
16081608
}
16091609
}
16101610

1611-
slo = &stagedLayerOptions{
1611+
lc = &layerCreationContents{
16121612
stagedLayerExtraction: m,
16131613
}
16141614
}
@@ -1642,7 +1642,7 @@ func (s *store) PutLayer(id, parent string, names []string, mountLabel string, w
16421642
return nil, -1, fmt.Errorf("error during staged layer apply, parent layer %q changed id mappings while the content was extracted, must retry layer creation", parent)
16431643
}
16441644
}
1645-
return s.putLayer(rlstore, id, parentLayer, names, mountLabel, writeable, options, slo)
1645+
return s.putLayer(rlstore, id, parentLayer, names, mountLabel, writeable, options, lc)
16461646
}
16471647

16481648
func (s *store) CreateLayer(id, parent string, names []string, mountLabel string, writeable bool, options *LayerOptions) (*Layer, error) {
@@ -3279,7 +3279,7 @@ func (s *store) ApplyStagedLayer(args ApplyStagedLayerOptions) (*Layer, error) {
32793279

32803280
// if the layer doesn't exist yet, try to create it.
32813281

3282-
slo := stagedLayerOptions{
3282+
lc := layerCreationContents{
32833283
DiffOutput: args.DiffOutput,
32843284
DiffOptions: args.DiffOptions,
32853285
}
@@ -3288,7 +3288,7 @@ func (s *store) ApplyStagedLayer(args ApplyStagedLayerOptions) (*Layer, error) {
32883288
if err != nil {
32893289
return nil, err
32903290
}
3291-
layer, _, err = s.putLayer(rlstore, args.ID, parentLayer, args.Names, args.MountLabel, args.Writeable, options, &slo)
3291+
layer, _, err = s.putLayer(rlstore, args.ID, parentLayer, args.Names, args.MountLabel, args.Writeable, options, &lc)
32923292
return layer, err
32933293
}
32943294

0 commit comments

Comments
 (0)