Modifies directory walker to use a regex

Now a regex is used to determine active volume properties from
their directory paths.
This commit is contained in:
Danny Jones
2014-07-29 10:20:50 -07:00
parent 47bca30edc
commit 6191ffc0de
3 changed files with 64 additions and 28 deletions

View File

@@ -44,7 +44,6 @@ type Builder interface {
// The Cleaner interface provides the method to cleanup/unmount the volumes.
type Cleaner interface {
Interface
// TearDown unmounts the volume and removes traces of the SetUp procedure.
TearDown() error
}
@@ -98,11 +97,7 @@ type EmptyDirectoryCleaner struct {
// Simply delete everything in the directory.
func (emptyDir *EmptyDirectoryCleaner) TearDown() error {
return os.RemoveAll(emptyDir.GetPath())
}
func (emptyDir *EmptyDirectoryCleaner) GetPath() string {
return emptyDir.Path
return os.RemoveAll(emptyDir.Path)
}
// Interprets API volume as a HostDirectory
@@ -115,6 +110,10 @@ func CreateEmptyDirectoryBuilder(volume *api.Volume, podID string, rootDir strin
return &EmptyDirectoryBuilder{volume.Name, podID, rootDir}
}
func CreateEmptyDirectoryCleaner(path string) *EmptyDirectoryCleaner {
return &EmptyDirectoryCleaner{path}
}
// CreateVolumeBuilder returns a Builder capable of mounting a volume described by an
// *api.Volume, or an error.
func CreateVolumeBuilder(volume *api.Volume, podID string, rootDir string) (Builder, error) {
@@ -136,3 +135,12 @@ func CreateVolumeBuilder(volume *api.Volume, podID string, rootDir string) (Buil
}
return vol, nil
}
func CreateVolumeCleaner(kind string, path string) (Cleaner, error) {
switch kind {
case "empty":
return CreateEmptyDirectoryCleaner(path), nil
default:
return nil, ErrUnsupportedVolumeType
}
}