From 341ebdd7e8002df6eb4e43ed7aef890355a2933c Mon Sep 17 00:00:00 2001 From: Chris Lundquist Date: Wed, 11 May 2016 00:37:01 +0000 Subject: [PATCH] [lxc] implement interface, add validation --- builder/lxc/communicator.go | 6 +++++- builder/lxc/config.go | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/builder/lxc/communicator.go b/builder/lxc/communicator.go index a1eb50fdb..4d6fab911 100644 --- a/builder/lxc/communicator.go +++ b/builder/lxc/communicator.go @@ -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 -} \ No newline at end of file +} diff --git a/builder/lxc/config.go b/builder/lxc/config.go index 6c32eeb95..2e05b00f5 100644 --- a/builder/lxc/config.go +++ b/builder/lxc/config.go @@ -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 }