[lxc] implement interface, add validation

This commit is contained in:
Chris Lundquist 2016-05-11 00:37:01 +00:00 committed by Megan Marsh
parent f4f0ab9f50
commit 341ebdd7e8
2 changed files with 10 additions and 1 deletions

View File

@ -104,6 +104,10 @@ func (c *LxcAttachCommunicator) Download(src string, w io.Writer) error {
return nil
}
func (c *LxcAttachCommunicator) DownloadDir(src string, dst string, exclude []string) error {
return fmt.Errorf("DownloadDir is not implemented for lxc")
}
func (c *LxcAttachCommunicator) Execute(commandString string) (*exec.Cmd, error) {
log.Printf("Executing with lxc-attach in container: %s %s %s", c.ContainerName, c.RootFs, commandString)
command, err := c.CmdWrapper(
@ -144,4 +148,4 @@ func (c *LxcAttachCommunicator) CheckInit() (string, error) {
}
return strings.TrimSpace(string(output)), nil
}
}

View File

@ -8,6 +8,7 @@ import (
"github.com/mitchellh/packer/packer"
"github.com/mitchellh/packer/template/interpolate"
"time"
"os"
)
type Config struct {
@ -62,6 +63,10 @@ func NewConfig(raws ...interface{}) (*Config, error) {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("Failed parsing init_timeout: %s", err))
}
if _, err := os.Stat(c.ConfigFile); os.IsNotExist(err) {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("LXC Config file appears to be missing: %s", c.ConfigFile))
}
if errs != nil && len(errs.Errors) > 0 {
return nil, errs
}