Run gofmt 1.19
Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
@@ -353,7 +353,8 @@ func BlockDeviceSize(path string) (int64, error) {
|
||||
}
|
||||
|
||||
// DiscardBlocks discards all blocks for the given thin device
|
||||
// ported from https://github.com/moby/moby/blob/7b9275c0da707b030e62c96b679a976f31f929d3/pkg/devicemapper/devmapper.go#L416
|
||||
//
|
||||
// ported from https://github.com/moby/moby/blob/7b9275c0da707b030e62c96b679a976f31f929d3/pkg/devicemapper/devmapper.go#L416
|
||||
func DiscardBlocks(deviceName string) error {
|
||||
inUse, err := isInUse(deviceName)
|
||||
if err != nil {
|
||||
@@ -402,8 +403,10 @@ func tryGetUnixError(output string) (unix.Errno, bool) {
|
||||
}
|
||||
|
||||
// dmsetup returns error messages in format:
|
||||
// device-mapper: message ioctl on <name> failed: File exists\n
|
||||
// Command failed\n
|
||||
//
|
||||
// device-mapper: message ioctl on <name> failed: File exists\n
|
||||
// Command failed\n
|
||||
//
|
||||
// parseDmsetupError extracts text between "failed: " and "\n"
|
||||
func parseDmsetupError(output string) string {
|
||||
lines := strings.SplitN(output, "\n", 2)
|
||||
|
||||
@@ -484,7 +484,9 @@ func (p *PoolDevice) IsLoaded(deviceName string) bool {
|
||||
// GetUsage reports total size in bytes consumed by a thin-device.
|
||||
// It relies on the number of used blocks reported by 'dmsetup status'.
|
||||
// The output looks like:
|
||||
// device2: 0 204800 thin 17280 204799
|
||||
//
|
||||
// device2: 0 204800 thin 17280 204799
|
||||
//
|
||||
// Where 17280 is the number of used sectors
|
||||
func (p *PoolDevice) GetUsage(deviceName string) (int64, error) {
|
||||
status, err := dmsetup.Status(deviceName)
|
||||
|
||||
@@ -153,10 +153,10 @@ type WalkFunc func(context.Context, Info) error
|
||||
// For consistency, we define the following terms to be used throughout this
|
||||
// interface for snapshotter implementations:
|
||||
//
|
||||
// `ctx` - refers to a context.Context
|
||||
// `key` - refers to an active snapshot
|
||||
// `name` - refers to a committed snapshot
|
||||
// `parent` - refers to the parent in relation
|
||||
// `ctx` - refers to a context.Context
|
||||
// `key` - refers to an active snapshot
|
||||
// `name` - refers to a committed snapshot
|
||||
// `parent` - refers to the parent in relation
|
||||
//
|
||||
// Most methods take various combinations of these identifiers. Typically,
|
||||
// `name` and `parent` will be used in cases where a method *only* takes
|
||||
@@ -167,7 +167,7 @@ type WalkFunc func(context.Context, Info) error
|
||||
//
|
||||
// We cover several examples below to demonstrate the utility of the snapshotter.
|
||||
//
|
||||
// Importing a Layer
|
||||
// # Importing a Layer
|
||||
//
|
||||
// To import a layer, we simply have the snapshotter provide a list of
|
||||
// mounts to be applied such that our dst will capture a changeset. We start
|
||||
@@ -184,7 +184,7 @@ type WalkFunc func(context.Context, Info) error
|
||||
// "containerd.io/gc.root": time.Now().UTC().Format(time.RFC3339),
|
||||
// })
|
||||
// mounts, err := snapshotter.Prepare(ctx, key, "", noGcOpt)
|
||||
// if err != nil { ... }
|
||||
// if err != nil { ... }
|
||||
//
|
||||
// We get back a list of mounts from snapshotter.Prepare(), with the key identifying
|
||||
// the active snapshot. Mount this to the temporary location with the
|
||||
@@ -201,8 +201,8 @@ type WalkFunc func(context.Context, Info) error
|
||||
//
|
||||
// layer, err := os.Open(layerPath)
|
||||
// if err != nil { ... }
|
||||
// digest, err := unpackLayer(tmpLocation, layer) // unpack into layer location
|
||||
// if err != nil { ... }
|
||||
// digest, err := unpackLayer(tmpLocation, layer) // unpack into layer location
|
||||
// if err != nil { ... }
|
||||
//
|
||||
// When the above completes, we should have a filesystem that represents the
|
||||
// contents of the layer. Careful implementations should verify that digest
|
||||
@@ -220,30 +220,30 @@ type WalkFunc func(context.Context, Info) error
|
||||
// Now, we have a layer in the snapshotter that can be accessed with the digest
|
||||
// provided during commit.
|
||||
//
|
||||
// Importing the Next Layer
|
||||
// # Importing the Next Layer
|
||||
//
|
||||
// Making a layer depend on the above is identical to the process described
|
||||
// above except that the parent is provided as parent when calling
|
||||
// snapshotter.Prepare(), assuming a clean, unique key identifier:
|
||||
//
|
||||
// mounts, err := snapshotter.Prepare(ctx, key, parentDigest, noGcOpt)
|
||||
// mounts, err := snapshotter.Prepare(ctx, key, parentDigest, noGcOpt)
|
||||
//
|
||||
// We then mount, apply and commit, as we did above. The new snapshot will be
|
||||
// based on the content of the previous one.
|
||||
//
|
||||
// Running a Container
|
||||
// # Running a Container
|
||||
//
|
||||
// To run a container, we simply provide snapshotter.Prepare() the committed image
|
||||
// snapshot as the parent. After mounting, the prepared path can
|
||||
// be used directly as the container's filesystem:
|
||||
//
|
||||
// mounts, err := snapshotter.Prepare(ctx, containerKey, imageRootFSChainID)
|
||||
// mounts, err := snapshotter.Prepare(ctx, containerKey, imageRootFSChainID)
|
||||
//
|
||||
// The returned mounts can then be passed directly to the container runtime. If
|
||||
// one would like to create a new image from the filesystem, snapshotter.Commit() is
|
||||
// called:
|
||||
//
|
||||
// if err := snapshotter.Commit(ctx, newImageSnapshot, containerKey); err != nil { ... }
|
||||
// if err := snapshotter.Commit(ctx, newImageSnapshot, containerKey); err != nil { ... }
|
||||
//
|
||||
// Alternatively, for most container runs, snapshotter.Remove() will be called to
|
||||
// signal the snapshotter to abandon the changes.
|
||||
|
||||
@@ -505,7 +505,7 @@ func checkDeletedFilesInChildSnapshot(ctx context.Context, t *testing.T, snapsho
|
||||
|
||||
}
|
||||
|
||||
//Create three layers. Deleting intermediate layer must fail.
|
||||
// Create three layers. Deleting intermediate layer must fail.
|
||||
func checkRemoveIntermediateSnapshot(ctx context.Context, t *testing.T, snapshotter snapshots.Snapshotter, work string) {
|
||||
|
||||
base, err := snapshotterPrepareMount(ctx, snapshotter, "base", "", work)
|
||||
@@ -559,12 +559,13 @@ func checkRemoveIntermediateSnapshot(ctx context.Context, t *testing.T, snapshot
|
||||
|
||||
// baseTestSnapshots creates a base set of snapshots for tests, each snapshot is empty
|
||||
// Tests snapshots:
|
||||
// c1 - committed snapshot, no parent
|
||||
// c2 - committed snapshot, c1 is parent
|
||||
// a1 - active snapshot, c2 is parent
|
||||
// a1 - active snapshot, no parent
|
||||
// v1 - view snapshot, v1 is parent
|
||||
// v2 - view snapshot, no parent
|
||||
//
|
||||
// c1 - committed snapshot, no parent
|
||||
// c2 - committed snapshot, c1 is parent
|
||||
// a1 - active snapshot, c2 is parent
|
||||
// a1 - active snapshot, no parent
|
||||
// v1 - view snapshot, v1 is parent
|
||||
// v2 - view snapshot, no parent
|
||||
func baseTestSnapshots(ctx context.Context, snapshotter snapshots.Snapshotter) error {
|
||||
if _, err := snapshotter.Prepare(ctx, "c1-a", "", opt); err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user