[lxc] implement interface, add validation
This commit is contained in:
parent
f4f0ab9f50
commit
341ebdd7e8
|
@ -104,6 +104,10 @@ func (c *LxcAttachCommunicator) Download(src string, w io.Writer) error {
|
||||||
return nil
|
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) {
|
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)
|
log.Printf("Executing with lxc-attach in container: %s %s %s", c.ContainerName, c.RootFs, commandString)
|
||||||
command, err := c.CmdWrapper(
|
command, err := c.CmdWrapper(
|
||||||
|
@ -144,4 +148,4 @@ func (c *LxcAttachCommunicator) CheckInit() (string, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return strings.TrimSpace(string(output)), nil
|
return strings.TrimSpace(string(output)), nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/mitchellh/packer/packer"
|
"github.com/mitchellh/packer/packer"
|
||||||
"github.com/mitchellh/packer/template/interpolate"
|
"github.com/mitchellh/packer/template/interpolate"
|
||||||
"time"
|
"time"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
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))
|
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 {
|
if errs != nil && len(errs.Errors) > 0 {
|
||||||
return nil, errs
|
return nil, errs
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue