2018-03-06 15:02:19 -05:00
|
|
|
package vagrant
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
"github.com/hashicorp/packer/packer"
|
2020-11-19 14:54:31 -05:00
|
|
|
packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer"
|
2018-03-06 15:02:19 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
type LXCProvider struct{}
|
|
|
|
|
|
|
|
func (p *LXCProvider) KeepInputArtifact() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2020-11-19 14:54:31 -05:00
|
|
|
func (p *LXCProvider) Process(ui packersdk.Ui, artifact packer.Artifact, dir string) (vagrantfile string, metadata map[string]interface{}, err error) {
|
2018-03-06 15:02:19 -05:00
|
|
|
// 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
|
|
|
|
}
|