Add LXC to vagrant post-processor

This commit is contained in:
Graham Hayes 2018-03-06 20:02:19 +00:00
parent d3f1b501c6
commit 91d60d6b81
No known key found for this signature in database
GPG Key ID: 1B263DC59F4AEFD5
4 changed files with 59 additions and 2 deletions

View File

@ -0,0 +1,34 @@
package vagrant
import (
"fmt"
"path/filepath"
"github.com/hashicorp/packer/packer"
)
type LXCProvider struct{}
func (p *LXCProvider) KeepInputArtifact() bool {
return false
}
func (p *LXCProvider) Process(ui packer.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) {
// Create the metadata
metadata = map[string]interface{}{
"provider": "lxc",
"version": "1.0.0",
}
// Copy all of the original contents into the temporary directory
for _, path := range artifact.Files() {
ui.Message(fmt.Sprintf("Copying: %s", path))
dstPath := filepath.Join(dir, filepath.Base(path))
if err = CopyContents(dstPath, path); err != nil {
return
}
}
return
}

View File

@ -0,0 +1,9 @@
package vagrant
import (
"testing"
)
func TestLXCProvider_impl(t *testing.T) {
var _ Provider = new(LXCProvider)
}

View File

@ -30,6 +30,7 @@ var builtins = map[string]string{
"packer.parallels": "parallels",
"MSOpenTech.hyperv": "hyperv",
"transcend.qemu": "libvirt",
"ustream.lxc": "lxc",
}
type Config struct {
@ -238,6 +239,8 @@ func providerForName(name string) Provider {
return new(LibVirtProvider)
case "google":
return new(GoogleProvider)
case "lxc":
return new(LXCProvider)
default:
return nil
}

View File

@ -34,6 +34,7 @@ providers.
- DigitalOcean
- Google
- Hyper-V
- LXC
- Parallels
- QEMU
- VirtualBox
@ -101,8 +102,18 @@ Specify overrides within the `override` configuration by provider name:
In the example above, the compression level will be set to 1 except for VMware,
where it will be set to 0.
The available provider names are: `aws`, `digitalocean`, `google`, `virtualbox`,
`vmware`, and `parallels`.
The available provider names are:
- `aws`
- `digitalocean`
- `google`
- `hyperv`
- `parallels`
- `libvirt`
- `lxc`
- `scaleway`
- `virtualbox`
- `vmware`
## Input Artifacts