Use consts defined in api instead of defining another ones.

This commit is contained in:
xiangpengzhao
2018-01-05 11:32:23 +08:00
parent e99ec24595
commit 22ea748809
5 changed files with 23 additions and 28 deletions

View File

@@ -155,20 +155,12 @@ func (plugin *emptyDirPlugin) ConstructVolumeSpec(volName, mountPath string) (*v
type mountDetector interface {
// GetMountMedium determines what type of medium a given path is backed
// by and whether that path is a mount point. For example, if this
// returns (mediumMemory, false, nil), the caller knows that the path is
// returns (v1.StorageMediumMemory, false, nil), the caller knows that the path is
// on a memory FS (tmpfs on Linux) but is not the root mountpoint of
// that tmpfs.
GetMountMedium(path string) (storageMedium, bool, error)
GetMountMedium(path string) (v1.StorageMedium, bool, error)
}
type storageMedium int
const (
mediumUnknown storageMedium = 0 // assume anything we don't explicitly handle is this
mediumMemory storageMedium = 1 // memory (e.g. tmpfs on linux)
mediumHugepages storageMedium = 2 // hugepages
)
// EmptyDir volumes are temporary directories exposed to the pod.
// These do not persist beyond the lifetime of a pod.
type emptyDir struct {
@@ -257,7 +249,7 @@ func (ed *emptyDir) setupTmpfs(dir string) error {
}
// If the directory is a mountpoint with medium memory, there is no
// work to do since we are already in the desired state.
if isMnt && medium == mediumMemory {
if isMnt && medium == v1.StorageMediumMemory {
return nil
}
@@ -280,7 +272,7 @@ func (ed *emptyDir) setupHugepages(dir string) error {
}
// If the directory is a mountpoint with medium hugepages, there is no
// work to do since we are already in the desired state.
if isMnt && medium == mediumHugepages {
if isMnt && medium == v1.StorageMediumHugePages {
return nil
}
@@ -388,10 +380,10 @@ func (ed *emptyDir) TearDownAt(dir string) error {
return err
}
if isMnt {
if medium == mediumMemory {
if medium == v1.StorageMediumMemory {
ed.medium = v1.StorageMediumMemory
return ed.teardownTmpfsOrHugetlbfs(dir)
} else if medium == mediumHugepages {
} else if medium == v1.StorageMediumHugePages {
ed.medium = v1.StorageMediumHugePages
return ed.teardownTmpfsOrHugetlbfs(dir)
}