storage.go 1.4 KB
Newer Older
W
wangkang101 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*
 * Copyright (c) 2020 Huawei Technologies Co., Ltd.
 * isula-transform is licensed under the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *     http://license.coscl.org.cn/MulanPSL2
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
 * PURPOSE.
 * See the Mulan PSL v2 for more details.
 * Create: 2020-04-24
 */

package transform

import (
	"isula.org/isula-transform/types"
)

// StorageType define graph storage driver
type StorageType string

// support storage driver
const (
W
wangkang101 已提交
24 25
	Overlay2     StorageType = "overlay2"
	DeviceMapper StorageType = "devicemapper"
W
wangkang101 已提交
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
)

// StorageDriver defines methods for creating and rolling storage resources
type StorageDriver interface {
	// GenerateRootFs returns a new rootfs path used by container
	GenerateRootFs(id, image string) (string, error)
	// TransformRWLayer migrates container read-write layer data
	TransformRWLayer(ctr *types.IsuladV2Config, oldRootFs string) error
	// Cleanup olls back the image operation when the transformation fails
	Cleanup(id string)
}

// BaseStorageDriver contains the common functions used by StorageDriver
type BaseStorageDriver interface {
	GenerateRootFs(id, image string) (string, error)
	CleanupRootFs(id string)
W
wangkang101 已提交
42 43
	MountRootFs(id, image string) error
	UmountRootFs(id, image string) error
W
wangkang101 已提交
44
}