Rename variables and snapshotter option to resolve lint warnings

Signed-off-by: Austin Vazquez <macedonv@amazon.com>
This commit is contained in:
Austin Vazquez 2024-02-10 13:45:04 -08:00
parent b87d78f456
commit f44d90be4a
No known key found for this signature in database
GPG Key ID: 5F5F4008442CADB8
4 changed files with 18 additions and 18 deletions

View File

@ -27,7 +27,7 @@ import (
const ( const (
capaRemapIDs = "remap-ids" capaRemapIDs = "remap-ids"
capaOnlyRemapIds = "only-remap-ids" capaOnlyRemapIDs = "only-remap-ids"
) )
// WithRemapperLabels creates the labels used by any supporting snapshotter // WithRemapperLabels creates the labels used by any supporting snapshotter
@ -75,7 +75,7 @@ func resolveSnapshotOptions(ctx context.Context, client *Client, snapshotterName
capaOnlyRemap := false capaOnlyRemap := false
for _, capa := range capabs { for _, capa := range capabs {
if capa == capaOnlyRemapIds { if capa == capaOnlyRemapIDs {
capaOnlyRemap = true capaOnlyRemap = true
} }
} }

View File

@ -45,7 +45,7 @@ type SnapshotterConfig struct {
upperdirLabel bool upperdirLabel bool
ms MetaStore ms MetaStore
mountOptions []string mountOptions []string
remapIds bool remapIDs bool
slowChown bool slowChown bool
} }
@ -94,8 +94,8 @@ func WithMetaStore(ms MetaStore) Opt {
} }
} }
func WithRemapIds(config *SnapshotterConfig) error { func WithRemapIDs(config *SnapshotterConfig) error {
config.remapIds = true config.remapIDs = true
return nil return nil
} }
@ -110,7 +110,7 @@ type snapshotter struct {
asyncRemove bool asyncRemove bool
upperdirLabel bool upperdirLabel bool
options []string options []string
remapIds bool remapIDs bool
slowChown bool slowChown bool
} }
@ -167,7 +167,7 @@ func NewSnapshotter(root string, opts ...Opt) (snapshots.Snapshotter, error) {
asyncRemove: config.asyncRemove, asyncRemove: config.asyncRemove,
upperdirLabel: config.upperdirLabel, upperdirLabel: config.upperdirLabel,
options: config.mountOptions, options: config.mountOptions,
remapIds: config.remapIds, remapIDs: config.remapIDs,
slowChown: config.slowChown, slowChown: config.slowChown,
}, nil }, nil
} }
@ -573,7 +573,7 @@ func (o *snapshotter) prepareDirectory(ctx context.Context, snapshotDir string,
func (o *snapshotter) mounts(s storage.Snapshot, info snapshots.Info) []mount.Mount { func (o *snapshotter) mounts(s storage.Snapshot, info snapshots.Info) []mount.Mount {
var options []string var options []string
if o.remapIds { if o.remapIDs {
if v, ok := info.Labels[snapshots.LabelSnapshotUIDMapping]; ok { if v, ok := info.Labels[snapshots.LabelSnapshotUIDMapping]; ok {
options = append(options, fmt.Sprintf("uidmap=%s", v)) options = append(options, fmt.Sprintf("uidmap=%s", v))
} }

View File

@ -54,7 +54,7 @@ func TestOverlay(t *testing.T) {
// default in init() // default in init()
"AsynchronousRemove": {AsynchronousRemove}, "AsynchronousRemove": {AsynchronousRemove},
// idmapped mounts enabled // idmapped mounts enabled
"WithRemapIds": {WithRemapIds}, "WithRemapIDs": {WithRemapIDs},
} }
for optsName, opts := range optTestCases { for optsName, opts := range optTestCases {
@ -211,7 +211,7 @@ func testOverlayRemappedBind(t *testing.T, newSnapshotter testsuite.SnapshotterF
t.Fatal(err) t.Fatal(err)
} }
if sn, ok := o.(*snapshotter); !ok || !sn.remapIds { if sn, ok := o.(*snapshotter); !ok || !sn.remapIDs {
t.Skip("overlayfs doesn't support idmapped mounts") t.Skip("overlayfs doesn't support idmapped mounts")
} }
@ -316,7 +316,7 @@ func testOverlayRemappedActive(t *testing.T, newSnapshotter testsuite.Snapshotte
t.Fatal(err) t.Fatal(err)
} }
if sn, ok := o.(*snapshotter); !ok || !sn.remapIds { if sn, ok := o.(*snapshotter); !ok || !sn.remapIDs {
t.Skip("overlayfs doesn't support idmapped mounts") t.Skip("overlayfs doesn't support idmapped mounts")
} }
@ -390,7 +390,7 @@ func testOverlayRemappedInvalidMapping(t *testing.T, newSnapshotter testsuite.Sn
t.Fatal(err) t.Fatal(err)
} }
if sn, ok := o.(*snapshotter); !ok || !sn.remapIds { if sn, ok := o.(*snapshotter); !ok || !sn.remapIDs {
t.Skip("overlayfs doesn't support idmapped mounts") t.Skip("overlayfs doesn't support idmapped mounts")
} }

View File

@ -30,8 +30,8 @@ import (
) )
const ( const (
capaRemapIds = "remap-ids" capaRemapIDs = "remap-ids"
capaOnlyRemapIds = "only-remap-ids" capaOnlyRemapIDs = "only-remap-ids"
) )
// Config represents configuration for the overlay plugin. // Config represents configuration for the overlay plugin.
@ -80,16 +80,16 @@ func init() {
oOpts = append(oOpts, overlay.WithMountOptions(config.MountOptions)) oOpts = append(oOpts, overlay.WithMountOptions(config.MountOptions))
} }
if ok, err := overlayutils.SupportsIDMappedMounts(); err == nil && ok { if ok, err := overlayutils.SupportsIDMappedMounts(); err == nil && ok {
oOpts = append(oOpts, overlay.WithRemapIds) oOpts = append(oOpts, overlay.WithRemapIDs)
ic.Meta.Capabilities = append(ic.Meta.Capabilities, capaRemapIds) ic.Meta.Capabilities = append(ic.Meta.Capabilities, capaRemapIDs)
} }
if config.SlowChown { if config.SlowChown {
oOpts = append(oOpts, overlay.WithSlowChown) oOpts = append(oOpts, overlay.WithSlowChown)
} else { } else {
// If slowChown is false, we use capaOnlyRemapIds to signal we only // If slowChown is false, we use capaOnlyRemapIDs to signal we only
// allow idmap mounts. // allow idmap mounts.
ic.Meta.Capabilities = append(ic.Meta.Capabilities, capaOnlyRemapIds) ic.Meta.Capabilities = append(ic.Meta.Capabilities, capaOnlyRemapIDs)
} }
ic.Meta.Exports["root"] = root ic.Meta.Exports["root"] = root