distrobuilder/generators/remove.go
Thomas Hipp 7ad2f482cd
generators: Simplify code
Signed-off-by: Thomas Hipp <thomas.hipp@canonical.com>
2018-03-08 17:13:25 +01:00

31 lines
787 B
Go

package generators
import (
"os"
"path/filepath"
"github.com/lxc/distrobuilder/image"
"github.com/lxc/distrobuilder/shared"
)
// RemoveGenerator represents the Remove generator.
type RemoveGenerator struct{}
// RunLXC removes a path.
func (g RemoveGenerator) RunLXC(cacheDir, sourceDir string, img *image.LXCImage,
defFile shared.DefinitionFile) error {
return g.Run(cacheDir, sourceDir, defFile)
}
// RunLXD removes a path.
func (g RemoveGenerator) RunLXD(cacheDir, sourceDir string, img *image.LXDImage,
defFile shared.DefinitionFile) error {
return g.Run(cacheDir, sourceDir, defFile)
}
// Run removes a path.
func (g RemoveGenerator) Run(cacheDir, sourceDir string,
defFile shared.DefinitionFile) error {
return os.RemoveAll(filepath.Join(sourceDir, defFile.Path))
}