Extract virtualbox plugin (#10910)
This commit is contained in:
parent
ceb96d061a
commit
16658a9f47
|
@ -1,47 +0,0 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
||||
)
|
||||
|
||||
func TestArtifact_impl(t *testing.T) {
|
||||
var _ packersdk.Artifact = new(artifact)
|
||||
}
|
||||
|
||||
func TestNewArtifact(t *testing.T) {
|
||||
td, err := ioutil.TempDir("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
defer os.RemoveAll(td)
|
||||
|
||||
err = ioutil.WriteFile(filepath.Join(td, "a"), []byte("foo"), 0644)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
if err := os.Mkdir(filepath.Join(td, "b"), 0755); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
generatedData := map[string]interface{}{"generated_data": "data"}
|
||||
a, err := NewArtifact(td, generatedData)
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
if a.BuilderId() != BuilderId {
|
||||
t.Fatalf("bad: %#v", a.BuilderId())
|
||||
}
|
||||
if len(a.Files()) != 1 {
|
||||
t.Fatalf("should length 1: %d", len(a.Files()))
|
||||
}
|
||||
if a.State("generated_data") != "data" {
|
||||
t.Fatalf("bad: should length have generated_data: %s", a.State("generated_data"))
|
||||
}
|
||||
}
|
|
@ -1,178 +0,0 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/packer-plugin-sdk/communicator"
|
||||
"github.com/hashicorp/packer-plugin-sdk/template/interpolate"
|
||||
)
|
||||
|
||||
func testCommConfig() *CommConfig {
|
||||
return &CommConfig{
|
||||
Comm: communicator.Config{
|
||||
SSH: communicator.SSH{
|
||||
SSHUsername: "foo",
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func TestCommConfigPrepare(t *testing.T) {
|
||||
c := testCommConfig()
|
||||
errs := c.Prepare(interpolate.NewContext())
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("err: %#v", errs)
|
||||
}
|
||||
|
||||
if c.HostPortMin != 2222 {
|
||||
t.Errorf("bad min communicator host port: %d", c.HostPortMin)
|
||||
}
|
||||
|
||||
if c.HostPortMax != 4444 {
|
||||
t.Errorf("bad max communicator host port: %d", c.HostPortMax)
|
||||
}
|
||||
|
||||
if c.Comm.SSHPort != 22 {
|
||||
t.Errorf("bad communicator port: %d", c.Comm.SSHPort)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCommConfigPrepare_SSHHostPort(t *testing.T) {
|
||||
var c *CommConfig
|
||||
var errs []error
|
||||
|
||||
// Bad
|
||||
c = testCommConfig()
|
||||
c.HostPortMin = 1000
|
||||
c.HostPortMax = 500
|
||||
errs = c.Prepare(interpolate.NewContext())
|
||||
if len(errs) == 0 {
|
||||
t.Fatalf("bad: %#v", errs)
|
||||
}
|
||||
|
||||
// Good
|
||||
c = testCommConfig()
|
||||
c.HostPortMin = 50
|
||||
c.HostPortMax = 500
|
||||
errs = c.Prepare(interpolate.NewContext())
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("should not have error: %s", errs)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCommConfigPrepare_SSHPrivateKey(t *testing.T) {
|
||||
var c *CommConfig
|
||||
var errs []error
|
||||
|
||||
c = testCommConfig()
|
||||
c.Comm.SSHPrivateKeyFile = ""
|
||||
errs = c.Prepare(interpolate.NewContext())
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("should not have error: %#v", errs)
|
||||
}
|
||||
|
||||
c = testCommConfig()
|
||||
c.Comm.SSHPrivateKeyFile = "/i/dont/exist"
|
||||
errs = c.Prepare(interpolate.NewContext())
|
||||
if len(errs) == 0 {
|
||||
t.Fatal("should have error")
|
||||
}
|
||||
|
||||
// Test bad contents
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
defer os.Remove(tf.Name())
|
||||
defer tf.Close()
|
||||
|
||||
if _, err := tf.Write([]byte("HELLO!")); err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
c = testCommConfig()
|
||||
c.Comm.SSHPrivateKeyFile = tf.Name()
|
||||
errs = c.Prepare(interpolate.NewContext())
|
||||
if len(errs) == 0 {
|
||||
t.Fatal("should have error")
|
||||
}
|
||||
|
||||
// Test good contents
|
||||
tf.Seek(0, 0)
|
||||
tf.Truncate(0)
|
||||
tf.Write([]byte(testPem))
|
||||
c = testCommConfig()
|
||||
c.Comm.SSHPrivateKeyFile = tf.Name()
|
||||
errs = c.Prepare(interpolate.NewContext())
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("should not have error: %#v", errs)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCommConfigPrepare_BackwardsCompatibility(t *testing.T) {
|
||||
var c *CommConfig
|
||||
hostPortMin := 1234
|
||||
hostPortMax := 4321
|
||||
skipNatMapping := true
|
||||
sshTimeout := 2 * time.Minute
|
||||
|
||||
c = testCommConfig()
|
||||
c.SSHHostPortMin = hostPortMin
|
||||
c.SSHHostPortMax = hostPortMax
|
||||
c.SSHSkipNatMapping = skipNatMapping
|
||||
c.Comm.SSHWaitTimeout = sshTimeout
|
||||
|
||||
err := c.Prepare(interpolate.NewContext())
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
if c.HostPortMin != hostPortMin {
|
||||
t.Fatalf("HostPortMin should be %d for backwards compatibility, but it was %d", hostPortMin, c.HostPortMin)
|
||||
}
|
||||
|
||||
if c.HostPortMax != hostPortMax {
|
||||
t.Fatalf("HostPortMax should be %d for backwards compatibility, but it was %d", hostPortMax, c.HostPortMax)
|
||||
}
|
||||
|
||||
if c.SkipNatMapping != skipNatMapping {
|
||||
t.Fatalf("SkipNatMapping should be %t for backwards compatibility, but it was %t", skipNatMapping, c.SkipNatMapping)
|
||||
}
|
||||
|
||||
if c.Comm.SSHTimeout != sshTimeout {
|
||||
t.Fatalf("SSHTimeout should be %s for backwards compatibility, but it was %s", sshTimeout.String(), c.Comm.SSHTimeout.String())
|
||||
}
|
||||
}
|
||||
|
||||
const testPem = `
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEpQIBAAKCAQEAxd4iamvrwRJvtNDGQSIbNvvIQN8imXTRWlRY62EvKov60vqu
|
||||
hh+rDzFYAIIzlmrJopvOe0clqmi3mIP9dtkjPFrYflq52a2CF5q+BdwsJXuRHbJW
|
||||
LmStZUwW1khSz93DhvhmK50nIaczW63u4EO/jJb3xj+wxR1Nkk9bxi3DDsYFt8SN
|
||||
AzYx9kjlEYQ/+sI4/ATfmdV9h78SVotjScupd9KFzzi76gWq9gwyCBLRynTUWlyD
|
||||
2UOfJRkOvhN6/jKzvYfVVwjPSfA9IMuooHdScmC4F6KBKJl/zf/zETM0XyzIDNmH
|
||||
uOPbCiljq2WoRM+rY6ET84EO0kVXbfx8uxUsqQIDAQABAoIBAQCkPj9TF0IagbM3
|
||||
5BSs/CKbAWS4dH/D4bPlxx4IRCNirc8GUg+MRb04Xz0tLuajdQDqeWpr6iLZ0RKV
|
||||
BvreLF+TOdV7DNQ4XE4gSdJyCtCaTHeort/aordL3l0WgfI7mVk0L/yfN1PEG4YG
|
||||
E9q1TYcyrB3/8d5JwIkjabxERLglCcP+geOEJp+QijbvFIaZR/n2irlKW4gSy6ko
|
||||
9B0fgUnhkHysSg49ChHQBPQ+o5BbpuLrPDFMiTPTPhdfsvGGcyCGeqfBA56oHcSF
|
||||
K02Fg8OM+Bd1lb48LAN9nWWY4WbwV+9bkN3Ym8hO4c3a/Dxf2N7LtAQqWZzFjvM3
|
||||
/AaDvAgBAoGBAPLD+Xn1IYQPMB2XXCXfOuJewRY7RzoVWvMffJPDfm16O7wOiW5+
|
||||
2FmvxUDayk4PZy6wQMzGeGKnhcMMZTyaq2g/QtGfrvy7q1Lw2fB1VFlVblvqhoJa
|
||||
nMJojjC4zgjBkXMHsRLeTmgUKyGs+fdFbfI6uejBnnf+eMVUMIdJ+6I9AoGBANCn
|
||||
kWO9640dttyXURxNJ3lBr2H3dJOkmD6XS+u+LWqCSKQe691Y/fZ/ZL0Oc4Mhy7I6
|
||||
hsy3kDQ5k2V0fkaNODQIFJvUqXw2pMewUk8hHc9403f4fe9cPrL12rQ8WlQw4yoC
|
||||
v2B61vNczCCUDtGxlAaw8jzSRaSI5s6ax3K7enbdAoGBAJB1WYDfA2CoAQO6y9Sl
|
||||
b07A/7kQ8SN5DbPaqrDrBdJziBQxukoMJQXJeGFNUFD/DXFU5Fp2R7C86vXT7HIR
|
||||
v6m66zH+CYzOx/YE6EsUJms6UP9VIVF0Rg/RU7teXQwM01ZV32LQ8mswhTH20o/3
|
||||
uqMHmxUMEhZpUMhrfq0isyApAoGAe1UxGTXfj9AqkIVYylPIq2HqGww7+jFmVEj1
|
||||
9Wi6S6Sq72ffnzzFEPkIQL/UA4TsdHMnzsYKFPSbbXLIWUeMGyVTmTDA5c0e5XIR
|
||||
lPhMOKCAzv8w4VUzMnEkTzkFY5JqFCD/ojW57KvDdNZPVB+VEcdxyAW6aKELXMAc
|
||||
eHLc1nkCgYEApm/motCTPN32nINZ+Vvywbv64ZD+gtpeMNP3CLrbe1X9O+H52AXa
|
||||
1jCoOldWR8i2bs2NVPcKZgdo6fFULqE4dBX7Te/uYEIuuZhYLNzRO1IKU/YaqsXG
|
||||
3bfQ8hKYcSnTfE0gPtLDnqCIxTocaGLSHeG3TH9fTw+dA8FvWpUztI4=
|
||||
-----END RSA PRIVATE KEY-----
|
||||
`
|
|
@ -1,9 +0,0 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestVBox42Driver_impl(t *testing.T) {
|
||||
var _ Driver = new(VBox42Driver)
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/packer-plugin-sdk/template/interpolate"
|
||||
)
|
||||
|
||||
func TestExportConfigPrepare_BootWait(t *testing.T) {
|
||||
var c *ExportConfig
|
||||
var errs []error
|
||||
|
||||
// Bad
|
||||
c = new(ExportConfig)
|
||||
c.Format = "illegal"
|
||||
errs = c.Prepare(interpolate.NewContext())
|
||||
if len(errs) == 0 {
|
||||
t.Fatalf("bad: %#v", errs)
|
||||
}
|
||||
|
||||
// Good
|
||||
c = new(ExportConfig)
|
||||
c.Format = "ova"
|
||||
errs = c.Prepare(interpolate.NewContext())
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("should not have error: %s", errs)
|
||||
}
|
||||
|
||||
// Good
|
||||
c = new(ExportConfig)
|
||||
c.Format = "ovf"
|
||||
errs = c.Prepare(interpolate.NewContext())
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("should not have error: %s", errs)
|
||||
}
|
||||
}
|
||||
|
||||
func TestExportConfigPrepare_Opts(t *testing.T) {
|
||||
var c *ExportConfig
|
||||
var errs []error
|
||||
|
||||
// Good
|
||||
c = new(ExportConfig)
|
||||
c.ExportOpts = []string{
|
||||
"--options",
|
||||
}
|
||||
errs = c.Prepare(interpolate.NewContext())
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("should not have error: %s", errs)
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGuestAdditionsConfigPrepare(t *testing.T) {
|
||||
c := new(GuestAdditionsConfig)
|
||||
var errs []error
|
||||
|
||||
c.GuestAdditionsMode = "disable"
|
||||
errs = c.Prepare("none")
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("should not have error: %s", errs)
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/packer-plugin-sdk/template/interpolate"
|
||||
)
|
||||
|
||||
func TestHWConfigPrepare(t *testing.T) {
|
||||
c := new(HWConfig)
|
||||
if errs := c.Prepare(interpolate.NewContext()); len(errs) > 0 {
|
||||
t.Fatalf("err: %#v", errs)
|
||||
}
|
||||
|
||||
if c.CpuCount < 1 {
|
||||
t.Errorf("bad cpu count: %d", c.CpuCount)
|
||||
}
|
||||
|
||||
if c.MemorySize < 64 {
|
||||
t.Errorf("bad memory size: %d", c.MemorySize)
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/packer-plugin-sdk/common"
|
||||
"github.com/hashicorp/packer-plugin-sdk/template/interpolate"
|
||||
)
|
||||
|
||||
func TestOutputConfigPrepare(t *testing.T) {
|
||||
c := new(OutputConfig)
|
||||
if c.OutputDir != "" {
|
||||
t.Fatalf("what: %s", c.OutputDir)
|
||||
}
|
||||
|
||||
pc := &common.PackerConfig{PackerBuildName: "foo"}
|
||||
errs := c.Prepare(interpolate.NewContext(), pc)
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("err: %#v", errs)
|
||||
}
|
||||
|
||||
if c.OutputDir == "" {
|
||||
t.Fatal("should have output dir")
|
||||
}
|
||||
}
|
||||
|
||||
func TestOutputConfigPrepare_exists(t *testing.T) {
|
||||
td, err := ioutil.TempDir("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
defer os.RemoveAll(td)
|
||||
|
||||
c := new(OutputConfig)
|
||||
c.OutputDir = td
|
||||
|
||||
pc := &common.PackerConfig{
|
||||
PackerBuildName: "foo",
|
||||
PackerForce: false,
|
||||
}
|
||||
errs := c.Prepare(interpolate.NewContext(), pc)
|
||||
if len(errs) != 0 {
|
||||
t.Fatal("should not have errors")
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/packer-plugin-sdk/template/interpolate"
|
||||
)
|
||||
|
||||
func TestRunConfigPrepare_VRDPBindAddress(t *testing.T) {
|
||||
var c *RunConfig
|
||||
var errs []error
|
||||
|
||||
// Test a default VRDPBindAddress
|
||||
c = new(RunConfig)
|
||||
errs = c.Prepare(interpolate.NewContext())
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("should not have error: %s", errs)
|
||||
}
|
||||
|
||||
if c.VRDPBindAddress != "127.0.0.1" {
|
||||
t.Fatalf("bad value: %s", c.VRDPBindAddress)
|
||||
}
|
||||
|
||||
// Test with a good one
|
||||
c = new(RunConfig)
|
||||
c.VRDPBindAddress = "192.168.0.1"
|
||||
errs = c.Prepare(interpolate.NewContext())
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("should not have error: %s", errs)
|
||||
}
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/packer-plugin-sdk/template/interpolate"
|
||||
)
|
||||
|
||||
func testShutdownConfig() *ShutdownConfig {
|
||||
return &ShutdownConfig{}
|
||||
}
|
||||
|
||||
func TestShutdownConfigPrepare_ShutdownCommand(t *testing.T) {
|
||||
var c *ShutdownConfig
|
||||
var errs []error
|
||||
|
||||
c = testShutdownConfig()
|
||||
errs = c.Prepare(interpolate.NewContext())
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("err: %#v", errs)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShutdownConfigPrepare_ShutdownTimeout(t *testing.T) {
|
||||
var c *ShutdownConfig
|
||||
var errs []error
|
||||
|
||||
// Test with a good one
|
||||
c = testShutdownConfig()
|
||||
c.ShutdownTimeout = 5 * time.Second
|
||||
errs = c.Prepare(interpolate.NewContext())
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("err: %#v", errs)
|
||||
}
|
||||
if c.ShutdownTimeout != 5*time.Second {
|
||||
t.Fatalf("bad: %s", c.ShutdownTimeout)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShutdownConfigPrepare_PostShutdownDelay(t *testing.T) {
|
||||
var c *ShutdownConfig
|
||||
var errs []error
|
||||
|
||||
// Test with default value
|
||||
c = testShutdownConfig()
|
||||
c.PostShutdownDelay = 0
|
||||
errs = c.Prepare(interpolate.NewContext())
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("err: %#v", errs)
|
||||
}
|
||||
if c.PostShutdownDelay != 2*time.Second {
|
||||
t.Fatalf("bad: PostShutdownDelay should be 2 seconds but was %s", c.PostShutdownDelay)
|
||||
}
|
||||
|
||||
// Test with a good one
|
||||
c = testShutdownConfig()
|
||||
c.PostShutdownDelay = 5 * time.Millisecond
|
||||
errs = c.Prepare(interpolate.NewContext())
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("err: %#v", errs)
|
||||
}
|
||||
if c.PostShutdownDelay != 5*time.Millisecond {
|
||||
t.Fatalf("bad: %s", c.PostShutdownDelay)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShutdownConfigPrepare_DisableShutdown(t *testing.T) {
|
||||
var c *ShutdownConfig
|
||||
var errs []error
|
||||
|
||||
// Test with default value
|
||||
c = testShutdownConfig()
|
||||
c.DisableShutdown = false
|
||||
errs = c.Prepare(interpolate.NewContext())
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("err: %#v", errs)
|
||||
}
|
||||
|
||||
// Test with a good one
|
||||
c = testShutdownConfig()
|
||||
c.DisableShutdown = true
|
||||
errs = c.Prepare(interpolate.NewContext())
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("err: %#v", errs)
|
||||
}
|
||||
if !c.DisableShutdown {
|
||||
t.Fatalf("bad: %t", c.DisableShutdown)
|
||||
}
|
||||
}
|
|
@ -1,143 +0,0 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func getTestData() string {
|
||||
return `SnapshotName="Imported"
|
||||
SnapshotUUID="7e5b4165-91ec-4091-a74c-a5709d584530"
|
||||
SnapshotName-1="Snapshot 1"
|
||||
SnapshotUUID-1="5fc461ec-da7a-40a8-a168-03134d7cdf5c"
|
||||
SnapshotName-1-1="Snapshot 2"
|
||||
SnapshotUUID-1-1="8e12833b-c6b5-4cbd-b42b-09eff8ffc173"
|
||||
SnapshotName-1-1-1="Snapshot 3"
|
||||
SnapshotUUID-1-1-1="eb342b39-b4bd-47b0-afd8-dcd1cc5c5929"
|
||||
SnapshotName-1-1-2="Snapshot 4"
|
||||
SnapshotUUID-1-1-2="17df1668-e79a-4ed6-a86b-713913699846"
|
||||
SnapshotName-1-2="Snapshot-Export"
|
||||
SnapshotUUID-1-2="c857d1b8-4fd6-4044-9d2c-c6e465b3cdd4"
|
||||
CurrentSnapshotName="Snapshot-Export"
|
||||
CurrentSnapshotUUID="c857d1b8-4fd6-4044-9d2c-c6e465b3cdd4"
|
||||
CurrentSnapshotNode="SnapshotName-1-2"
|
||||
SnapshotName-2="Snapshot 5"
|
||||
SnapshotUUID-2="85646c6a-fb86-4112-b15e-cab090670778"
|
||||
SnapshotName-2-1="Snapshot 2"
|
||||
SnapshotUUID-2-1="7b093686-2981-4ada-8b0f-4c03ae23cd1a"
|
||||
SnapshotName-3="Snapshot 7"
|
||||
SnapshotUUID-3="0d977a1f-c9ef-412c-a08d-7c0707b3b18f"
|
||||
SnapshotName-3-1="Snapshot 8"
|
||||
SnapshotUUID-3-1="f4ed75b3-afc1-42d4-9e02-8df6f053d07e"
|
||||
SnapshotName-3-2="Snapshot 9"
|
||||
SnapshotUUID-3-2="a5903505-9261-4bd3-9972-bacd0064d667"`
|
||||
}
|
||||
|
||||
func TestSnapshot_ParseFullTree(t *testing.T) {
|
||||
rootNode, err := ParseSnapshotData(getTestData())
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, rootNode)
|
||||
assert.Equal(t, rootNode.Name, "Imported")
|
||||
assert.Equal(t, rootNode.UUID, "7e5b4165-91ec-4091-a74c-a5709d584530")
|
||||
assert.Equal(t, 3, len(rootNode.Children))
|
||||
assert.Nil(t, rootNode.Parent)
|
||||
}
|
||||
|
||||
func TestSnapshot_FindCurrent(t *testing.T) {
|
||||
rootNode, err := ParseSnapshotData(getTestData())
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, rootNode)
|
||||
|
||||
current := rootNode.GetCurrentSnapshot()
|
||||
assert.NotNil(t, current)
|
||||
assert.Equal(t, current.UUID, "c857d1b8-4fd6-4044-9d2c-c6e465b3cdd4")
|
||||
assert.Equal(t, current.Name, "Snapshot-Export")
|
||||
assert.NotNil(t, current.Parent)
|
||||
assert.Equal(t, current.Parent.UUID, "5fc461ec-da7a-40a8-a168-03134d7cdf5c")
|
||||
assert.Equal(t, current.Parent.Name, "Snapshot 1")
|
||||
}
|
||||
|
||||
func TestSnapshot_FindNodeByUUID(t *testing.T) {
|
||||
rootNode, err := ParseSnapshotData(getTestData())
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, rootNode)
|
||||
|
||||
node := rootNode.GetSnapshotByUUID("7b093686-2981-4ada-8b0f-4c03ae23cd1a")
|
||||
assert.NotNil(t, node)
|
||||
assert.Equal(t, "Snapshot 2", node.Name)
|
||||
assert.Equal(t, "7b093686-2981-4ada-8b0f-4c03ae23cd1a", node.UUID)
|
||||
assert.Equal(t, 0, len(node.Children))
|
||||
assert.Nil(t, rootNode.Parent)
|
||||
|
||||
otherNode := rootNode.GetSnapshotByUUID("f4ed75b3-afc1-42d4-9e02-8df6f053d07e")
|
||||
assert.NotNil(t, otherNode)
|
||||
assert.True(t, otherNode.IsChildOf(rootNode))
|
||||
assert.False(t, node.IsChildOf(otherNode))
|
||||
assert.False(t, otherNode.IsChildOf(node))
|
||||
}
|
||||
|
||||
func TestSnapshot_FindNodesByName(t *testing.T) {
|
||||
rootNode, err := ParseSnapshotData(getTestData())
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, rootNode)
|
||||
|
||||
nodes := rootNode.GetSnapshotsByName("Snapshot 2")
|
||||
assert.NotNil(t, nodes)
|
||||
assert.Equal(t, 2, len(nodes))
|
||||
}
|
||||
|
||||
func TestSnapshot_IsChildOf(t *testing.T) {
|
||||
rootNode, err := ParseSnapshotData(getTestData())
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, rootNode)
|
||||
|
||||
child := rootNode.GetSnapshotByUUID("c857d1b8-4fd6-4044-9d2c-c6e465b3cdd4")
|
||||
assert.NotNil(t, child)
|
||||
assert.True(t, child.IsChildOf(rootNode))
|
||||
assert.True(t, child.IsChildOf(child.Parent))
|
||||
assert.PanicsWithValue(t, "Missing parameter value: candidate", func() { child.IsChildOf(nil) })
|
||||
}
|
||||
|
||||
func TestSnapshot_SingleSnapshot(t *testing.T) {
|
||||
snapData := `SnapshotName="Imported"
|
||||
SnapshotUUID="7e5b4165-91ec-4091-a74c-a5709d584530"`
|
||||
|
||||
rootNode, err := ParseSnapshotData(snapData)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, rootNode)
|
||||
|
||||
assert.Equal(t, rootNode.Name, "Imported")
|
||||
assert.Equal(t, rootNode.UUID, "7e5b4165-91ec-4091-a74c-a5709d584530")
|
||||
assert.Equal(t, len(rootNode.Children), 0)
|
||||
assert.Nil(t, rootNode.Parent)
|
||||
}
|
||||
|
||||
func TestSnapshot_EmptySnapshotData(t *testing.T) {
|
||||
snapData := ``
|
||||
|
||||
rootNode, err := ParseSnapshotData(snapData)
|
||||
assert.NoError(t, err)
|
||||
assert.Nil(t, rootNode)
|
||||
}
|
||||
|
||||
func TestSnapshot_EnsureParents(t *testing.T) {
|
||||
rootNode, err := ParseSnapshotData(getTestData())
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, rootNode)
|
||||
|
||||
for _, snapshot := range rootNode.GetSnapshots() {
|
||||
if snapshot == rootNode {
|
||||
assert.Nil(t, snapshot.Parent)
|
||||
} else {
|
||||
assert.NotNil(t, snapshot.Parent)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestSnapshot_WrongSnapshot(t *testing.T) {
|
||||
rootNode, err := ParseSnapshotData(`Potato=
|
||||
`)
|
||||
assert.Nil(t, err)
|
||||
assert.Nil(t, rootNode)
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/packer-plugin-sdk/multistep"
|
||||
)
|
||||
|
||||
func TestStepAttachFloppy_impl(t *testing.T) {
|
||||
var _ multistep.Step = new(StepAttachFloppy)
|
||||
}
|
||||
|
||||
func TestStepAttachFloppy(t *testing.T) {
|
||||
state := testState(t)
|
||||
step := new(StepAttachFloppy)
|
||||
|
||||
// Create a temporary file for our floppy file
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
tf.Close()
|
||||
defer os.Remove(tf.Name())
|
||||
|
||||
state.Put("floppy_path", tf.Name())
|
||||
state.Put("vmName", "foo")
|
||||
|
||||
driver := state.Get("driver").(*DriverMock)
|
||||
|
||||
// Test the run
|
||||
if action := step.Run(context.Background(), state); action != multistep.ActionContinue {
|
||||
t.Fatalf("bad action: %#v", action)
|
||||
}
|
||||
if _, ok := state.GetOk("error"); ok {
|
||||
t.Fatal("should NOT have error")
|
||||
}
|
||||
|
||||
if driver.RemoveFloppyControllersVM == "" {
|
||||
t.Fatal("RemoveFloppyControllers was not called")
|
||||
}
|
||||
|
||||
if len(driver.VBoxManageCalls) != 2 {
|
||||
t.Fatal("not enough calls to VBoxManage")
|
||||
}
|
||||
if driver.VBoxManageCalls[0][0] != "storagectl" {
|
||||
t.Fatal("bad call")
|
||||
}
|
||||
if driver.VBoxManageCalls[1][0] != "storageattach" {
|
||||
t.Fatal("bad call")
|
||||
}
|
||||
|
||||
// Test the cleanup
|
||||
step.Cleanup(state)
|
||||
if driver.VBoxManageCalls[2][0] != "storageattach" {
|
||||
t.Fatal("bad call")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStepAttachFloppy_noFloppy(t *testing.T) {
|
||||
state := testState(t)
|
||||
step := new(StepAttachFloppy)
|
||||
|
||||
driver := state.Get("driver").(*DriverMock)
|
||||
|
||||
// Test the run
|
||||
if action := step.Run(context.Background(), state); action != multistep.ActionContinue {
|
||||
t.Fatalf("bad action: %#v", action)
|
||||
}
|
||||
if _, ok := state.GetOk("error"); ok {
|
||||
t.Fatal("should NOT have error")
|
||||
}
|
||||
|
||||
if len(driver.VBoxManageCalls) > 0 {
|
||||
t.Fatal("should not call vboxmanage")
|
||||
}
|
||||
}
|
|
@ -1,114 +0,0 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/packer-plugin-sdk/multistep"
|
||||
)
|
||||
|
||||
func TestStepExport_impl(t *testing.T) {
|
||||
var _ multistep.Step = new(StepExport)
|
||||
}
|
||||
|
||||
func TestStepExport(t *testing.T) {
|
||||
state := testState(t)
|
||||
step := new(StepExport)
|
||||
|
||||
state.Put("vmName", "foo")
|
||||
|
||||
driver := state.Get("driver").(*DriverMock)
|
||||
|
||||
// Test the run
|
||||
if action := step.Run(context.Background(), state); action != multistep.ActionContinue {
|
||||
t.Fatalf("bad action: %#v", action)
|
||||
}
|
||||
if _, ok := state.GetOk("error"); ok {
|
||||
t.Fatal("should NOT have error")
|
||||
}
|
||||
|
||||
// Test output state
|
||||
if _, ok := state.GetOk("exportPath"); !ok {
|
||||
t.Fatal("should set exportPath")
|
||||
}
|
||||
|
||||
// Test driver
|
||||
if len(driver.VBoxManageCalls) != 2 {
|
||||
t.Fatal("should call vboxmanage")
|
||||
}
|
||||
if driver.VBoxManageCalls[0][0] != "modifyvm" {
|
||||
t.Fatal("bad")
|
||||
}
|
||||
if driver.VBoxManageCalls[1][0] != "export" {
|
||||
t.Fatal("bad")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStepExport_OutputPath(t *testing.T) {
|
||||
type testCase struct {
|
||||
Step *StepExport
|
||||
Expected string
|
||||
Reason string
|
||||
}
|
||||
tcs := []testCase{
|
||||
{
|
||||
Step: &StepExport{
|
||||
Format: "ova",
|
||||
OutputDir: "output-dir",
|
||||
OutputFilename: "output-filename",
|
||||
},
|
||||
Expected: filepath.Join("output-dir", "output-filename.ova"),
|
||||
Reason: "output_filename should not be vmName if set.",
|
||||
},
|
||||
{
|
||||
Step: &StepExport{
|
||||
Format: "ovf",
|
||||
OutputDir: "output-dir",
|
||||
OutputFilename: "",
|
||||
},
|
||||
Expected: filepath.Join("output-dir", "foo.ovf"),
|
||||
Reason: "output_filename should default to vmName.",
|
||||
},
|
||||
}
|
||||
for _, tc := range tcs {
|
||||
state := testState(t)
|
||||
state.Put("vmName", "foo")
|
||||
|
||||
// Test the run
|
||||
if action := tc.Step.Run(context.Background(), state); action != multistep.ActionContinue {
|
||||
t.Fatalf("bad action: %#v", action)
|
||||
}
|
||||
|
||||
// Test output state
|
||||
path, ok := state.GetOk("exportPath")
|
||||
if !ok {
|
||||
t.Fatal("should set exportPath")
|
||||
}
|
||||
if path != tc.Expected {
|
||||
t.Fatalf("Expected %s didn't match received %s: %s", tc.Expected, path, tc.Reason)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestStepExport_SkipExport(t *testing.T) {
|
||||
state := testState(t)
|
||||
step := StepExport{SkipExport: true}
|
||||
|
||||
state.Put("vmName", "foo")
|
||||
|
||||
driver := state.Get("driver").(*DriverMock)
|
||||
|
||||
// Test the run
|
||||
if action := step.Run(context.Background(), state); action != multistep.ActionContinue {
|
||||
t.Fatalf("bad action: %#v", action)
|
||||
}
|
||||
if _, ok := state.GetOk("error"); ok {
|
||||
t.Fatal("should NOT have error")
|
||||
}
|
||||
// Test driver
|
||||
if len(driver.VBoxManageCalls) != 0 {
|
||||
t.Fatal("shouldn't have called vboxmanage; skip_export was set.")
|
||||
}
|
||||
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/packer-plugin-sdk/multistep"
|
||||
)
|
||||
|
||||
func TestStepHTTPIPDiscover_Run(t *testing.T) {
|
||||
state := new(multistep.BasicStateBag)
|
||||
step := new(StepHTTPIPDiscover)
|
||||
hostIp := "10.0.2.2"
|
||||
|
||||
// Test the run
|
||||
if action := step.Run(context.Background(), state); action != multistep.ActionContinue {
|
||||
t.Fatalf("bad action: %#v", action)
|
||||
}
|
||||
if _, ok := state.GetOk("error"); ok {
|
||||
t.Fatal("should NOT have error")
|
||||
}
|
||||
httpIp := state.Get("http_ip").(string)
|
||||
if httpIp != hostIp {
|
||||
t.Fatalf("bad: Http ip is %s but was supposed to be %s", httpIp, hostIp)
|
||||
}
|
||||
}
|
|
@ -1,135 +0,0 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/packer-plugin-sdk/multistep"
|
||||
)
|
||||
|
||||
func TestStepRemoveDevices_impl(t *testing.T) {
|
||||
var _ multistep.Step = new(StepRemoveDevices)
|
||||
}
|
||||
|
||||
func TestStepRemoveDevices(t *testing.T) {
|
||||
state := testState(t)
|
||||
step := new(StepRemoveDevices)
|
||||
|
||||
state.Put("vmName", "foo")
|
||||
|
||||
driver := state.Get("driver").(*DriverMock)
|
||||
|
||||
// Test the run
|
||||
if action := step.Run(context.Background(), state); action != multistep.ActionContinue {
|
||||
t.Fatalf("bad action: %#v", action)
|
||||
}
|
||||
if _, ok := state.GetOk("error"); ok {
|
||||
t.Fatal("should NOT have error")
|
||||
}
|
||||
|
||||
// Test that ISO was removed
|
||||
if len(driver.VBoxManageCalls) != 0 {
|
||||
t.Fatalf("bad: %#v", driver.VBoxManageCalls)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStepRemoveDevices_attachedIso(t *testing.T) {
|
||||
state := testState(t)
|
||||
step := new(StepRemoveDevices)
|
||||
|
||||
diskUnmountCommands := map[string][]string{
|
||||
"boot_iso": []string{
|
||||
"storageattach", "myvm",
|
||||
"--storagectl", "IDE Controller",
|
||||
"--port", "0",
|
||||
"--device", "1",
|
||||
"--type", "dvddrive",
|
||||
"--medium", "none",
|
||||
},
|
||||
}
|
||||
state.Put("disk_unmount_commands", diskUnmountCommands)
|
||||
state.Put("vmName", "foo")
|
||||
|
||||
driver := state.Get("driver").(*DriverMock)
|
||||
|
||||
// Test the run
|
||||
if action := step.Run(context.Background(), state); action != multistep.ActionContinue {
|
||||
t.Fatalf("bad action: %#v", action)
|
||||
}
|
||||
if _, ok := state.GetOk("error"); ok {
|
||||
t.Fatal("should NOT have error")
|
||||
}
|
||||
|
||||
// Test that ISO was removed
|
||||
if len(driver.VBoxManageCalls) != 1 {
|
||||
t.Fatalf("bad: %#v", driver.VBoxManageCalls)
|
||||
}
|
||||
if driver.VBoxManageCalls[0][3] != "IDE Controller" {
|
||||
t.Fatalf("bad: %#v", driver.VBoxManageCalls)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStepRemoveDevices_attachedIsoOnSata(t *testing.T) {
|
||||
state := testState(t)
|
||||
step := new(StepRemoveDevices)
|
||||
|
||||
diskUnmountCommands := map[string][]string{
|
||||
"boot_iso": []string{
|
||||
"storageattach", "myvm",
|
||||
"--storagectl", "SATA Controller",
|
||||
"--port", "0",
|
||||
"--device", "1",
|
||||
"--type", "dvddrive",
|
||||
"--medium", "none",
|
||||
},
|
||||
}
|
||||
state.Put("disk_unmount_commands", diskUnmountCommands)
|
||||
state.Put("vmName", "foo")
|
||||
|
||||
driver := state.Get("driver").(*DriverMock)
|
||||
|
||||
// Test the run
|
||||
if action := step.Run(context.Background(), state); action != multistep.ActionContinue {
|
||||
t.Fatalf("bad action: %#v", action)
|
||||
}
|
||||
if _, ok := state.GetOk("error"); ok {
|
||||
t.Fatal("should NOT have error")
|
||||
}
|
||||
|
||||
// Test that ISO was removed
|
||||
if len(driver.VBoxManageCalls) != 1 {
|
||||
t.Fatalf("bad: %#v", driver.VBoxManageCalls)
|
||||
}
|
||||
if driver.VBoxManageCalls[0][3] != "SATA Controller" {
|
||||
t.Fatalf("bad: %#v", driver.VBoxManageCalls)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStepRemoveDevices_floppyPath(t *testing.T) {
|
||||
state := testState(t)
|
||||
step := new(StepRemoveDevices)
|
||||
|
||||
state.Put("floppy_path", "foo")
|
||||
state.Put("vmName", "foo")
|
||||
|
||||
driver := state.Get("driver").(*DriverMock)
|
||||
|
||||
// Test the run
|
||||
if action := step.Run(context.Background(), state); action != multistep.ActionContinue {
|
||||
t.Fatalf("bad action: %#v", action)
|
||||
}
|
||||
if _, ok := state.GetOk("error"); ok {
|
||||
t.Fatal("should NOT have error")
|
||||
}
|
||||
|
||||
// Test that both were removed
|
||||
if len(driver.VBoxManageCalls) != 2 {
|
||||
t.Fatalf("bad: %#v", driver.VBoxManageCalls)
|
||||
}
|
||||
if driver.VBoxManageCalls[0][3] != "Floppy Controller" {
|
||||
t.Fatalf("bad: %#v", driver.VBoxManageCalls)
|
||||
}
|
||||
if driver.VBoxManageCalls[1][3] != "Floppy Controller" {
|
||||
t.Fatalf("bad: %#v", driver.VBoxManageCalls)
|
||||
}
|
||||
}
|
|
@ -1,172 +0,0 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/packer-plugin-sdk/multistep"
|
||||
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
||||
)
|
||||
|
||||
func TestStepShutdown_impl(t *testing.T) {
|
||||
var _ multistep.Step = new(StepShutdown)
|
||||
}
|
||||
|
||||
func TestStepShutdown_noShutdownCommand(t *testing.T) {
|
||||
state := testState(t)
|
||||
step := new(StepShutdown)
|
||||
step.DisableShutdown = false
|
||||
step.ACPIShutdown = false
|
||||
|
||||
comm := new(packersdk.MockCommunicator)
|
||||
state.Put("communicator", comm)
|
||||
state.Put("vmName", "foo")
|
||||
|
||||
driver := state.Get("driver").(*DriverMock)
|
||||
|
||||
// Test the run
|
||||
if action := step.Run(context.Background(), state); action != multistep.ActionContinue {
|
||||
t.Fatalf("bad action: %#v", action)
|
||||
}
|
||||
if _, ok := state.GetOk("error"); ok {
|
||||
t.Fatal("should NOT have error")
|
||||
}
|
||||
|
||||
// Test that Stop was just called
|
||||
if driver.StopName != "foo" {
|
||||
t.Fatal("should call stop")
|
||||
}
|
||||
if comm.StartCalled {
|
||||
t.Fatal("comm start should not be called")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStepShutdown_shutdownCommand(t *testing.T) {
|
||||
state := testState(t)
|
||||
step := new(StepShutdown)
|
||||
step.Command = "poweroff"
|
||||
step.Timeout = 1 * time.Second
|
||||
step.DisableShutdown = false
|
||||
step.ACPIShutdown = false
|
||||
|
||||
comm := new(packersdk.MockCommunicator)
|
||||
state.Put("communicator", comm)
|
||||
state.Put("vmName", "foo")
|
||||
|
||||
driver := state.Get("driver").(*DriverMock)
|
||||
driver.IsRunningReturn = true
|
||||
|
||||
go func() {
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
driver.Lock()
|
||||
defer driver.Unlock()
|
||||
driver.IsRunningReturn = false
|
||||
}()
|
||||
|
||||
// Test the run
|
||||
if action := step.Run(context.Background(), state); action != multistep.ActionContinue {
|
||||
t.Fatalf("bad action: %#v", action)
|
||||
}
|
||||
if _, ok := state.GetOk("error"); ok {
|
||||
t.Fatal("should NOT have error")
|
||||
}
|
||||
|
||||
// Test that Stop was just called
|
||||
if driver.StopName != "" {
|
||||
t.Fatal("should not call stop")
|
||||
}
|
||||
if comm.StartCmd.Command != step.Command {
|
||||
t.Fatal("comm start should be called")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStepShutdown_shutdownTimeout(t *testing.T) {
|
||||
state := testState(t)
|
||||
step := new(StepShutdown)
|
||||
step.Command = "poweroff"
|
||||
step.Timeout = 1 * time.Second
|
||||
step.DisableShutdown = false
|
||||
step.ACPIShutdown = false
|
||||
|
||||
comm := new(packersdk.MockCommunicator)
|
||||
state.Put("communicator", comm)
|
||||
state.Put("vmName", "foo")
|
||||
|
||||
driver := state.Get("driver").(*DriverMock)
|
||||
driver.IsRunningReturn = true
|
||||
|
||||
go func() {
|
||||
time.Sleep(2 * time.Second)
|
||||
driver.Lock()
|
||||
defer driver.Unlock()
|
||||
driver.IsRunningReturn = false
|
||||
}()
|
||||
|
||||
// Test the run
|
||||
if action := step.Run(context.Background(), state); action != multistep.ActionHalt {
|
||||
t.Fatalf("bad action: %#v", action)
|
||||
}
|
||||
if _, ok := state.GetOk("error"); !ok {
|
||||
t.Fatal("should have error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStepShutdown_DisableShutdown(t *testing.T) {
|
||||
state := testState(t)
|
||||
step := new(StepShutdown)
|
||||
step.DisableShutdown = true
|
||||
step.ACPIShutdown = false
|
||||
step.Timeout = 2 * time.Second
|
||||
|
||||
comm := new(packersdk.MockCommunicator)
|
||||
state.Put("communicator", comm)
|
||||
state.Put("vmName", "foo")
|
||||
|
||||
driver := state.Get("driver").(*DriverMock)
|
||||
driver.IsRunningReturn = true
|
||||
|
||||
go func() {
|
||||
time.Sleep(1 * time.Second)
|
||||
driver.Lock()
|
||||
defer driver.Unlock()
|
||||
driver.IsRunningReturn = false
|
||||
}()
|
||||
|
||||
// Test the run
|
||||
if action := step.Run(context.Background(), state); action != multistep.ActionContinue {
|
||||
t.Fatalf("bad action: %#v", action)
|
||||
}
|
||||
if _, ok := state.GetOk("error"); ok {
|
||||
t.Fatal("should NOT have error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStepShutdown_ACPIShutdown(t *testing.T) {
|
||||
state := testState(t)
|
||||
step := new(StepShutdown)
|
||||
step.ACPIShutdown = true
|
||||
step.Timeout = 2 * time.Second
|
||||
|
||||
comm := new(packersdk.MockCommunicator)
|
||||
state.Put("communicator", comm)
|
||||
state.Put("vmName", "foo")
|
||||
|
||||
driver := state.Get("driver").(*DriverMock)
|
||||
|
||||
// Test the run
|
||||
if action := step.Run(context.Background(), state); action != multistep.ActionContinue {
|
||||
t.Fatalf("bad action: %#v", action)
|
||||
}
|
||||
if _, ok := state.GetOk("error"); ok {
|
||||
t.Fatal("should NOT have error")
|
||||
}
|
||||
|
||||
// Test that Stop was just called
|
||||
if driver.StopViaACPIName != "foo" {
|
||||
t.Fatal("should call stop via ACPI")
|
||||
}
|
||||
if comm.StartCalled {
|
||||
t.Fatal("comm start should not be called")
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/packer-plugin-sdk/multistep"
|
||||
)
|
||||
|
||||
func TestStepSuppressMessages_impl(t *testing.T) {
|
||||
var _ multistep.Step = new(StepSuppressMessages)
|
||||
}
|
||||
|
||||
func TestStepSuppressMessages(t *testing.T) {
|
||||
state := testState(t)
|
||||
step := new(StepSuppressMessages)
|
||||
|
||||
driver := state.Get("driver").(*DriverMock)
|
||||
|
||||
// Test the run
|
||||
if action := step.Run(context.Background(), state); action != multistep.ActionContinue {
|
||||
t.Fatalf("bad action: %#v", action)
|
||||
}
|
||||
if _, ok := state.GetOk("error"); ok {
|
||||
t.Fatal("should NOT have error")
|
||||
}
|
||||
|
||||
if !driver.SuppressMessagesCalled {
|
||||
t.Fatal("should call suppressmessages")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStepSuppressMessages_error(t *testing.T) {
|
||||
state := testState(t)
|
||||
step := new(StepSuppressMessages)
|
||||
|
||||
driver := state.Get("driver").(*DriverMock)
|
||||
driver.SuppressMessagesErr = errors.New("foo")
|
||||
|
||||
// Test the run
|
||||
if action := step.Run(context.Background(), state); action != multistep.ActionHalt {
|
||||
t.Fatalf("bad action: %#v", action)
|
||||
}
|
||||
if _, ok := state.GetOk("error"); !ok {
|
||||
t.Fatal("should have error")
|
||||
}
|
||||
|
||||
if !driver.SuppressMessagesCalled {
|
||||
t.Fatal("should call suppressmessages")
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/packer-plugin-sdk/multistep"
|
||||
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
||||
)
|
||||
|
||||
func testState(t *testing.T) multistep.StateBag {
|
||||
state := new(multistep.BasicStateBag)
|
||||
state.Put("driver", new(DriverMock))
|
||||
state.Put("ui", &packersdk.BasicUi{
|
||||
Reader: new(bytes.Buffer),
|
||||
Writer: new(bytes.Buffer),
|
||||
})
|
||||
return state
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/packer-plugin-sdk/multistep"
|
||||
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
||||
)
|
||||
|
||||
func TestStepUploadVersion_impl(t *testing.T) {
|
||||
var _ multistep.Step = new(StepUploadVersion)
|
||||
}
|
||||
|
||||
func TestStepUploadVersion(t *testing.T) {
|
||||
state := testState(t)
|
||||
step := new(StepUploadVersion)
|
||||
step.Path = "foopath"
|
||||
|
||||
comm := new(packersdk.MockCommunicator)
|
||||
state.Put("communicator", comm)
|
||||
|
||||
driver := state.Get("driver").(*DriverMock)
|
||||
driver.VersionResult = "foo"
|
||||
|
||||
// Test the run
|
||||
if action := step.Run(context.Background(), state); action != multistep.ActionContinue {
|
||||
t.Fatalf("bad action: %#v", action)
|
||||
}
|
||||
if _, ok := state.GetOk("error"); ok {
|
||||
t.Fatal("should NOT have error")
|
||||
}
|
||||
|
||||
// Verify
|
||||
if comm.UploadPath != "foopath" {
|
||||
t.Fatalf("bad: %#v", comm.UploadPath)
|
||||
}
|
||||
if comm.UploadData != "foo" {
|
||||
t.Fatalf("upload data bad: %#v", comm.UploadData)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStepUploadVersion_noPath(t *testing.T) {
|
||||
state := testState(t)
|
||||
step := new(StepUploadVersion)
|
||||
step.Path = ""
|
||||
|
||||
comm := new(packersdk.MockCommunicator)
|
||||
state.Put("communicator", comm)
|
||||
|
||||
// Test the run
|
||||
if action := step.Run(context.Background(), state); action != multistep.ActionContinue {
|
||||
t.Fatalf("bad action: %#v", action)
|
||||
}
|
||||
if _, ok := state.GetOk("error"); ok {
|
||||
t.Fatal("should NOT have error")
|
||||
}
|
||||
|
||||
// Verify
|
||||
if comm.UploadCalled {
|
||||
t.Fatal("bad")
|
||||
}
|
||||
}
|
|
@ -1,78 +0,0 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestVBoxVersionConfigPrepare_BootWait(t *testing.T) {
|
||||
var c *VBoxVersionConfig
|
||||
var errs []error
|
||||
|
||||
// Test empty
|
||||
c = new(VBoxVersionConfig)
|
||||
errs = c.Prepare("ssh")
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("should not have error: %s", errs)
|
||||
}
|
||||
|
||||
if *c.VBoxVersionFile != ".vbox_version" {
|
||||
t.Fatalf("bad value: %s", *c.VBoxVersionFile)
|
||||
}
|
||||
|
||||
// Test with a good one
|
||||
c = new(VBoxVersionConfig)
|
||||
filename := "foo"
|
||||
c.VBoxVersionFile = &filename
|
||||
errs = c.Prepare("ssh")
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("should not have error: %s", errs)
|
||||
}
|
||||
|
||||
if *c.VBoxVersionFile != "foo" {
|
||||
t.Fatalf("bad value: %s", *c.VBoxVersionFile)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVBoxVersionConfigPrepare_empty(t *testing.T) {
|
||||
var c *VBoxVersionConfig
|
||||
var errs []error
|
||||
|
||||
// Test with nil value
|
||||
c = new(VBoxVersionConfig)
|
||||
c.VBoxVersionFile = nil
|
||||
errs = c.Prepare("ssh")
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("should not have error: %s", errs)
|
||||
}
|
||||
|
||||
if *c.VBoxVersionFile != ".vbox_version" {
|
||||
t.Fatalf("bad value: %s", *c.VBoxVersionFile)
|
||||
}
|
||||
|
||||
// Test with empty name
|
||||
c = new(VBoxVersionConfig)
|
||||
filename := ""
|
||||
c.VBoxVersionFile = &filename
|
||||
errs = c.Prepare("ssh")
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("should not have error: %s", errs)
|
||||
}
|
||||
|
||||
if *c.VBoxVersionFile != "" {
|
||||
t.Fatalf("bad value: %s", *c.VBoxVersionFile)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVBoxVersionConfigPrepare_communicator(t *testing.T) {
|
||||
var c *VBoxVersionConfig
|
||||
var errs []error
|
||||
|
||||
// Test with 'none' communicator and non-empty virtualbox_version_file
|
||||
c = new(VBoxVersionConfig)
|
||||
filename := "test"
|
||||
c.VBoxVersionFile = &filename
|
||||
errs = c.Prepare("none")
|
||||
if len(errs) == 0 {
|
||||
t.Fatalf("should have an error")
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/packer-plugin-sdk/template/interpolate"
|
||||
)
|
||||
|
||||
func TestVBoxBundleConfigPrepare_VBoxBundle(t *testing.T) {
|
||||
// Test with empty
|
||||
c := new(VBoxBundleConfig)
|
||||
errs := c.Prepare(interpolate.NewContext())
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("err: %#v", errs)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(*c, VBoxBundleConfig{BundleISO: false}) {
|
||||
t.Fatalf("bad: %#v", c)
|
||||
}
|
||||
|
||||
// Test with a good one
|
||||
c = new(VBoxBundleConfig)
|
||||
c.BundleISO = true
|
||||
errs = c.Prepare(interpolate.NewContext())
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("err: %#v", errs)
|
||||
}
|
||||
|
||||
expected := VBoxBundleConfig{
|
||||
BundleISO: true,
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(*c, expected) {
|
||||
t.Fatalf("bad: %#v", c)
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/packer-plugin-sdk/template/interpolate"
|
||||
)
|
||||
|
||||
func TestVBoxManageConfigPrepare_VBoxManage(t *testing.T) {
|
||||
// Test with empty
|
||||
c := new(VBoxManageConfig)
|
||||
errs := c.Prepare(interpolate.NewContext())
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("err: %#v", errs)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(c.VBoxManage, [][]string{}) {
|
||||
t.Fatalf("bad: %#v", c.VBoxManage)
|
||||
}
|
||||
|
||||
// Test with a good one
|
||||
c = new(VBoxManageConfig)
|
||||
c.VBoxManage = [][]string{
|
||||
{"foo", "bar", "baz"},
|
||||
}
|
||||
errs = c.Prepare(interpolate.NewContext())
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("err: %#v", errs)
|
||||
}
|
||||
|
||||
expected := [][]string{
|
||||
{"foo", "bar", "baz"},
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(c.VBoxManage, expected) {
|
||||
t.Fatalf("bad: %#v", c.VBoxManage)
|
||||
}
|
||||
}
|
||||
|
||||
func TestVBoxManageConfigPrepare_PostVBoxManage(t *testing.T) {
|
||||
// Test with empty
|
||||
c := new(VBoxManageConfig)
|
||||
errs := c.Prepare(interpolate.NewContext())
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("err: %#v", errs)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(c.VBoxManagePost, [][]string{}) {
|
||||
t.Fatalf("bad: %#v", c.VBoxManagePost)
|
||||
}
|
||||
|
||||
// Test with a good one
|
||||
c = new(VBoxManageConfig)
|
||||
c.VBoxManagePost = [][]string{
|
||||
{"foo", "bar", "baz"},
|
||||
}
|
||||
errs = c.Prepare(interpolate.NewContext())
|
||||
if len(errs) > 0 {
|
||||
t.Fatalf("err: %#v", errs)
|
||||
}
|
||||
|
||||
expected := [][]string{
|
||||
{"foo", "bar", "baz"},
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(c.VBoxManagePost, expected) {
|
||||
t.Fatalf("bad: %#v", c.VBoxManagePost)
|
||||
}
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
package virtualbox_acc
|
||||
|
||||
// This is the code necessary for running the provisioner acceptance tests.
|
||||
// It provides the builder config and cleans up created resource.
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/hashicorp/packer/builder/virtualbox/iso"
|
||||
|
||||
"github.com/hashicorp/packer-plugin-sdk/acctest/testutils"
|
||||
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
||||
)
|
||||
|
||||
type VirtualBoxISOAccTest struct{}
|
||||
|
||||
func (v *VirtualBoxISOAccTest) GetConfigs() (map[string]string, error) {
|
||||
filePath := filepath.Join("../../builder/virtualbox/iso/acceptance/test-fixtures/", "virtualbox-iso.txt")
|
||||
config, err := os.Open(filePath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Expected to find %s", filePath)
|
||||
}
|
||||
defer config.Close()
|
||||
|
||||
file, err := ioutil.ReadAll(config)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Unable to read %s", filePath)
|
||||
}
|
||||
return map[string]string{"linux": string(file)}, nil
|
||||
}
|
||||
|
||||
func (v *VirtualBoxISOAccTest) CleanUp() error {
|
||||
testutils.CleanupFiles("virtualbox-iso-packer-acc-test")
|
||||
testutils.CleanupFiles("packer_cache")
|
||||
return nil
|
||||
}
|
||||
|
||||
func (v *VirtualBoxISOAccTest) GetBuilderStore() packersdk.MapOfBuilder {
|
||||
return packersdk.MapOfBuilder{
|
||||
"virtualbox-iso": func() (packersdk.Builder, error) { return &iso.Builder{}, nil },
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
# Preseeding only locale sets language, country and locale.
|
||||
d-i debian-installer/locale string en_US
|
||||
|
||||
# Keyboard selection.
|
||||
d-i console-setup/ask_detect boolean false
|
||||
d-i keyboard-configuration/xkb-keymap select us
|
||||
|
||||
choose-mirror-bin mirror/http/proxy string
|
||||
d-i base-installer/kernel/override-image string linux-server
|
||||
d-i clock-setup/utc boolean true
|
||||
d-i clock-setup/utc-auto boolean true
|
||||
d-i finish-install/reboot_in_progress note
|
||||
d-i grub-installer/only_debian boolean true
|
||||
d-i grub-installer/with_other_os boolean true
|
||||
d-i mirror/country string manual
|
||||
d-i mirror/http/directory string /ubuntu/
|
||||
d-i mirror/http/hostname string archive.ubuntu.com
|
||||
d-i mirror/http/proxy string
|
||||
d-i partman-auto-lvm/guided_size string max
|
||||
d-i partman-auto/choose_recipe select atomic
|
||||
d-i partman-auto/method string lvm
|
||||
d-i partman-lvm/confirm boolean true
|
||||
d-i partman-lvm/confirm boolean true
|
||||
d-i partman-lvm/confirm_nooverwrite boolean true
|
||||
d-i partman-lvm/device_remove_lvm boolean true
|
||||
d-i partman/choose_partition select finish
|
||||
d-i partman/confirm boolean true
|
||||
d-i partman/confirm_nooverwrite boolean true
|
||||
d-i partman/confirm_write_new_label boolean true
|
||||
d-i passwd/user-fullname string vagrant
|
||||
d-i passwd/user-uid string 1000
|
||||
d-i passwd/user-password password vagrant
|
||||
d-i passwd/user-password-again password vagrant
|
||||
d-i passwd/username string vagrant
|
||||
d-i pkgsel/include string openssh-server cryptsetup build-essential libssl-dev libreadline-dev zlib1g-dev linux-source dkms nfs-kernel-server nfs-common linux-headers-$(uname -r) perl
|
||||
d-i pkgsel/install-language-support boolean false
|
||||
d-i pkgsel/update-policy select none
|
||||
d-i pkgsel/upgrade select full-upgrade
|
||||
d-i time/zone string UTC
|
||||
d-i user-setup/allow-password-weak boolean true
|
||||
d-i user-setup/encrypt-home boolean false
|
||||
tasksel tasksel/first multiselect standard, server
|
|
@ -1,43 +0,0 @@
|
|||
{
|
||||
"type": "virtualbox-iso",
|
||||
"iso_checksum": "sha256:946a6077af6f5f95a51f82fdc44051c7aa19f9cfc5f737954845a6050543d7c2",
|
||||
"iso_url": "http://old-releases.ubuntu.com/releases/14.04.1/ubuntu-14.04.1-server-amd64.iso",
|
||||
"disk_size": "40960",
|
||||
"guest_os_type": "Ubuntu_64",
|
||||
"headless" : "true",
|
||||
|
||||
"ssh_password": "vagrant",
|
||||
"ssh_username": "vagrant",
|
||||
"ssh_wait_timeout": "10000s",
|
||||
|
||||
"http_directory": "../../builder/virtualbox/iso/acceptance/test-fixtures/http",
|
||||
"boot_wait": "10s",
|
||||
"boot_command": [
|
||||
"<esc><wait>",
|
||||
"<esc><wait>",
|
||||
"<enter><wait>",
|
||||
"/install/vmlinuz<wait>",
|
||||
" auto<wait>",
|
||||
" console-setup/ask_detect=false<wait>",
|
||||
" console-setup/layoutcode=us<wait>",
|
||||
" console-setup/modelcode=pc105<wait>",
|
||||
" debconf/frontend=noninteractive<wait>",
|
||||
" debian-installer=en_US.UTF-8<wait>",
|
||||
" fb=false<wait>",
|
||||
" initrd=/install/initrd.gz<wait>",
|
||||
" kbd-chooser/method=us<wait>",
|
||||
" keyboard-configuration/layout=USA<wait>",
|
||||
" keyboard-configuration/variant=USA<wait>",
|
||||
" locale=en_US.UTF-8<wait>",
|
||||
" netcfg/get_domain=vm<wait>",
|
||||
" netcfg/get_hostname=vagrant<wait>",
|
||||
" noapic<wait>",
|
||||
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg<wait>",
|
||||
" -- <wait>",
|
||||
"<enter><wait>"
|
||||
],
|
||||
|
||||
"output_directory": "virtualbox-iso-packer-acc-test",
|
||||
"shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now",
|
||||
"post_shutdown_delay": "60s"
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
package iso
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
builderT "github.com/hashicorp/packer/acctest"
|
||||
)
|
||||
|
||||
func TestBuilderAcc_basic(t *testing.T) {
|
||||
templatePath := filepath.Join("testdata", "minimal.json")
|
||||
bytes, err := ioutil.ReadFile(templatePath)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to load template file %s", templatePath)
|
||||
}
|
||||
|
||||
builderT.Test(t, builderT.TestCase{
|
||||
Builder: &Builder{},
|
||||
Template: string(bytes),
|
||||
})
|
||||
}
|
|
@ -1,369 +0,0 @@
|
|||
package iso
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
packercommon "github.com/hashicorp/packer-plugin-sdk/common"
|
||||
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
||||
"github.com/hashicorp/packer/builder/virtualbox/common"
|
||||
)
|
||||
|
||||
func testConfig() map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
"iso_checksum": "md5:0B0F137F17AC10944716020B018F8126",
|
||||
"iso_url": "http://www.google.com/",
|
||||
"shutdown_command": "yes",
|
||||
"ssh_username": "foo",
|
||||
|
||||
packercommon.BuildNameConfigKey: "foo",
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuilder_ImplementsBuilder(t *testing.T) {
|
||||
var raw interface{}
|
||||
raw = &Builder{}
|
||||
if _, ok := raw.(packersdk.Builder); !ok {
|
||||
t.Error("Builder must implement builder.")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuilderPrepare_Defaults(t *testing.T) {
|
||||
var b Builder
|
||||
config := testConfig()
|
||||
_, warns, err := b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("should not have error: %s", err)
|
||||
}
|
||||
|
||||
if b.config.GuestAdditionsMode != common.GuestAdditionsModeUpload {
|
||||
t.Errorf("bad guest additions mode: %s", b.config.GuestAdditionsMode)
|
||||
}
|
||||
|
||||
if b.config.GuestOSType != "Other" {
|
||||
t.Errorf("bad guest OS type: %s", b.config.GuestOSType)
|
||||
}
|
||||
|
||||
if b.config.VMName == "" {
|
||||
t.Errorf("bad vm name: %s", b.config.VMName)
|
||||
}
|
||||
|
||||
if b.config.Format != "ovf" {
|
||||
t.Errorf("bad format: %s", b.config.Format)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuilderPrepare_DiskSize(t *testing.T) {
|
||||
var b Builder
|
||||
config := testConfig()
|
||||
|
||||
delete(config, "disk_size")
|
||||
_, warns, err := b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("bad err: %s", err)
|
||||
}
|
||||
|
||||
if b.config.DiskSize != 40000 {
|
||||
t.Fatalf("bad size: %d", b.config.DiskSize)
|
||||
}
|
||||
|
||||
config["disk_size"] = 60000
|
||||
b = Builder{}
|
||||
_, warns, err = b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("should not have error: %s", err)
|
||||
}
|
||||
|
||||
if b.config.DiskSize != 60000 {
|
||||
t.Fatalf("bad size: %d", b.config.DiskSize)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuilderPrepare_FloppyFiles(t *testing.T) {
|
||||
var b Builder
|
||||
config := testConfig()
|
||||
|
||||
delete(config, "floppy_files")
|
||||
_, warns, err := b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("bad err: %s", err)
|
||||
}
|
||||
|
||||
if len(b.config.FloppyFiles) != 0 {
|
||||
t.Fatalf("bad: %#v", b.config.FloppyFiles)
|
||||
}
|
||||
|
||||
floppies_path := "../../test-fixtures/floppies"
|
||||
config["floppy_files"] = []string{fmt.Sprintf("%s/bar.bat", floppies_path), fmt.Sprintf("%s/foo.ps1", floppies_path)}
|
||||
b = Builder{}
|
||||
_, warns, err = b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("should not have error: %s", err)
|
||||
}
|
||||
|
||||
expected := []string{fmt.Sprintf("%s/bar.bat", floppies_path), fmt.Sprintf("%s/foo.ps1", floppies_path)}
|
||||
if !reflect.DeepEqual(b.config.FloppyFiles, expected) {
|
||||
t.Fatalf("bad: %#v", b.config.FloppyFiles)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuilderPrepare_InvalidFloppies(t *testing.T) {
|
||||
var b Builder
|
||||
config := testConfig()
|
||||
config["floppy_files"] = []string{"nonexistent.bat", "nonexistent.ps1"}
|
||||
b = Builder{}
|
||||
_, _, errs := b.Prepare(config)
|
||||
if errs == nil {
|
||||
t.Fatalf("Nonexistent floppies should trigger multierror")
|
||||
}
|
||||
|
||||
if len(errs.(*packersdk.MultiError).Errors) != 2 {
|
||||
t.Fatalf("Multierror should work and report 2 errors")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuilderPrepare_GuestAdditionsMode(t *testing.T) {
|
||||
var b Builder
|
||||
config := testConfig()
|
||||
|
||||
// test default mode
|
||||
delete(config, "guest_additions_mode")
|
||||
_, warns, err := b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("bad err: %s", err)
|
||||
}
|
||||
|
||||
// Test another mode
|
||||
config["guest_additions_mode"] = "attach"
|
||||
b = Builder{}
|
||||
_, warns, err = b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("should not have error: %s", err)
|
||||
}
|
||||
|
||||
if b.config.GuestAdditionsMode != common.GuestAdditionsModeAttach {
|
||||
t.Fatalf("bad: %s", b.config.GuestAdditionsMode)
|
||||
}
|
||||
|
||||
// Test bad mode
|
||||
config["guest_additions_mode"] = "teleport"
|
||||
b = Builder{}
|
||||
_, warns, err = b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err == nil {
|
||||
t.Fatal("should error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuilderPrepare_GuestAdditionsPath(t *testing.T) {
|
||||
var b Builder
|
||||
config := testConfig()
|
||||
|
||||
delete(config, "guest_additions_path")
|
||||
_, warns, err := b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("bad err: %s", err)
|
||||
}
|
||||
|
||||
if b.config.GuestAdditionsPath != "VBoxGuestAdditions.iso" {
|
||||
t.Fatalf("bad: %s", b.config.GuestAdditionsPath)
|
||||
}
|
||||
|
||||
config["guest_additions_path"] = "foo"
|
||||
b = Builder{}
|
||||
_, warns, err = b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("should not have error: %s", err)
|
||||
}
|
||||
|
||||
if b.config.GuestAdditionsPath != "foo" {
|
||||
t.Fatalf("bad size: %s", b.config.GuestAdditionsPath)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuilderPrepare_GuestAdditionsSHA256(t *testing.T) {
|
||||
var b Builder
|
||||
config := testConfig()
|
||||
|
||||
delete(config, "guest_additions_sha256")
|
||||
_, warns, err := b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("bad err: %s", err)
|
||||
}
|
||||
|
||||
if b.config.GuestAdditionsSHA256 != "" {
|
||||
t.Fatalf("bad: %s", b.config.GuestAdditionsSHA256)
|
||||
}
|
||||
|
||||
config["guest_additions_sha256"] = "FOO"
|
||||
b = Builder{}
|
||||
_, warns, err = b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("should not have error: %s", err)
|
||||
}
|
||||
|
||||
if b.config.GuestAdditionsSHA256 != "foo" {
|
||||
t.Fatalf("bad size: %s", b.config.GuestAdditionsSHA256)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuilderPrepare_GuestAdditionsURL(t *testing.T) {
|
||||
var b Builder
|
||||
config := testConfig()
|
||||
|
||||
config["guest_additions_url"] = ""
|
||||
_, warns, err := b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
if b.config.GuestAdditionsURL != "" {
|
||||
t.Fatalf("should be empty: %s", b.config.GuestAdditionsURL)
|
||||
}
|
||||
|
||||
config["guest_additions_url"] = "http://www.packer.io"
|
||||
b = Builder{}
|
||||
_, warns, err = b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err != nil {
|
||||
t.Errorf("should not have error: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuilderPrepare_HardDriveInterface(t *testing.T) {
|
||||
var b Builder
|
||||
config := testConfig()
|
||||
|
||||
// Test a default boot_wait
|
||||
delete(config, "hard_drive_interface")
|
||||
_, warns, err := b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
if b.config.HardDriveInterface != "ide" {
|
||||
t.Fatalf("bad: %s", b.config.HardDriveInterface)
|
||||
}
|
||||
|
||||
// Test with a bad
|
||||
config["hard_drive_interface"] = "fake"
|
||||
b = Builder{}
|
||||
_, warns, err = b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err == nil {
|
||||
t.Fatal("should have error")
|
||||
}
|
||||
|
||||
// Test with a good
|
||||
config["hard_drive_interface"] = "sata"
|
||||
b = Builder{}
|
||||
_, warns, err = b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("should not have error: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuilderPrepare_InvalidKey(t *testing.T) {
|
||||
var b Builder
|
||||
config := testConfig()
|
||||
|
||||
// Add a random key
|
||||
config["i_should_not_be_valid"] = true
|
||||
_, warns, err := b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err == nil {
|
||||
t.Fatal("should have error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestBuilderPrepare_ISOInterface(t *testing.T) {
|
||||
var b Builder
|
||||
config := testConfig()
|
||||
|
||||
// Test a default boot_wait
|
||||
delete(config, "iso_interface")
|
||||
_, warns, err := b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
|
||||
if b.config.ISOInterface != "ide" {
|
||||
t.Fatalf("bad: %s", b.config.ISOInterface)
|
||||
}
|
||||
|
||||
// Test with a bad
|
||||
config["iso_interface"] = "fake"
|
||||
b = Builder{}
|
||||
_, warns, err = b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err == nil {
|
||||
t.Fatal("should have error")
|
||||
}
|
||||
|
||||
// Test with a good
|
||||
config["iso_interface"] = "sata"
|
||||
b = Builder{}
|
||||
_, warns, err = b.Prepare(config)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("should not have error: %s", err)
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
# Preseeding only locale sets language, country and locale.
|
||||
d-i debian-installer/locale string en_US
|
||||
|
||||
# Keyboard selection.
|
||||
d-i console-setup/ask_detect boolean false
|
||||
d-i keyboard-configuration/xkb-keymap select us
|
||||
|
||||
choose-mirror-bin mirror/http/proxy string
|
||||
d-i base-installer/kernel/override-image string linux-server
|
||||
d-i clock-setup/utc boolean true
|
||||
d-i clock-setup/utc-auto boolean true
|
||||
d-i finish-install/reboot_in_progress note
|
||||
d-i grub-installer/only_debian boolean true
|
||||
d-i grub-installer/with_other_os boolean true
|
||||
d-i mirror/country string manual
|
||||
d-i mirror/http/directory string /ubuntu/
|
||||
d-i mirror/http/hostname string archive.ubuntu.com
|
||||
d-i mirror/http/proxy string
|
||||
d-i partman-auto-lvm/guided_size string max
|
||||
d-i partman-auto/choose_recipe select atomic
|
||||
d-i partman-auto/method string lvm
|
||||
d-i partman-lvm/confirm boolean true
|
||||
d-i partman-lvm/confirm boolean true
|
||||
d-i partman-lvm/confirm_nooverwrite boolean true
|
||||
d-i partman-lvm/device_remove_lvm boolean true
|
||||
d-i partman/choose_partition select finish
|
||||
d-i partman/confirm boolean true
|
||||
d-i partman/confirm_nooverwrite boolean true
|
||||
d-i partman/confirm_write_new_label boolean true
|
||||
d-i passwd/user-fullname string vagrant
|
||||
d-i passwd/user-uid string 1000
|
||||
d-i passwd/user-password password vagrant
|
||||
d-i passwd/user-password-again password vagrant
|
||||
d-i passwd/username string vagrant
|
||||
d-i pkgsel/include string openssh-server cryptsetup build-essential libssl-dev libreadline-dev zlib1g-dev linux-source dkms nfs-kernel-server nfs-common linux-headers-$(uname -r) perl
|
||||
d-i pkgsel/install-language-support boolean false
|
||||
d-i pkgsel/update-policy select none
|
||||
d-i pkgsel/upgrade select full-upgrade
|
||||
d-i time/zone string UTC
|
||||
d-i user-setup/allow-password-weak boolean true
|
||||
d-i user-setup/encrypt-home boolean false
|
||||
tasksel tasksel/first multiselect standard, server
|
|
@ -1,45 +0,0 @@
|
|||
{
|
||||
"builders": [
|
||||
{
|
||||
"type": "test",
|
||||
"iso_checksum": "sha256:946a6077af6f5f95a51f82fdc44051c7aa19f9cfc5f737954845a6050543d7c2",
|
||||
"iso_url": "http://old-releases.ubuntu.com/releases/14.04.1/ubuntu-14.04.1-server-amd64.iso",
|
||||
"disk_size": "40960",
|
||||
"guest_os_type": "Ubuntu_64",
|
||||
|
||||
"ssh_password": "vagrant",
|
||||
"ssh_username": "vagrant",
|
||||
"ssh_wait_timeout": "10000s",
|
||||
|
||||
"http_directory": "./testdata/http",
|
||||
"boot_wait": "10s",
|
||||
"boot_command": [
|
||||
"<esc><wait>",
|
||||
"<esc><wait>",
|
||||
"<enter><wait>",
|
||||
"/install/vmlinuz<wait>",
|
||||
" auto<wait>",
|
||||
" console-setup/ask_detect=false<wait>",
|
||||
" console-setup/layoutcode=us<wait>",
|
||||
" console-setup/modelcode=pc105<wait>",
|
||||
" debconf/frontend=noninteractive<wait>",
|
||||
" debian-installer=en_US.UTF-8<wait>",
|
||||
" fb=false<wait>",
|
||||
" initrd=/install/initrd.gz<wait>",
|
||||
" kbd-chooser/method=us<wait>",
|
||||
" keyboard-configuration/layout=USA<wait>",
|
||||
" keyboard-configuration/variant=USA<wait>",
|
||||
" locale=en_US.UTF-8<wait>",
|
||||
" netcfg/get_domain=vm<wait>",
|
||||
" netcfg/get_hostname=vagrant<wait>",
|
||||
" noapic<wait>",
|
||||
" preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg<wait>",
|
||||
" -- <wait>",
|
||||
"<enter><wait>"
|
||||
],
|
||||
|
||||
"shutdown_command": "echo 'vagrant' | sudo -S shutdown -P now",
|
||||
"post_shutdown_delay": "60s"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,148 +0,0 @@
|
|||
package ovf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
||||
)
|
||||
|
||||
func testConfig(t *testing.T) map[string]interface{} {
|
||||
return map[string]interface{}{
|
||||
"ssh_username": "foo",
|
||||
"shutdown_command": "foo",
|
||||
"source_path": "config_test.go",
|
||||
}
|
||||
}
|
||||
|
||||
func getTempFile(t *testing.T) *os.File {
|
||||
tf, err := ioutil.TempFile("", "packer")
|
||||
if err != nil {
|
||||
t.Fatalf("err: %s", err)
|
||||
}
|
||||
tf.Close()
|
||||
|
||||
// don't forget to cleanup the file downstream:
|
||||
// defer os.Remove(tf.Name())
|
||||
|
||||
return tf
|
||||
}
|
||||
|
||||
func TestNewConfig_FloppyFiles(t *testing.T) {
|
||||
cfg := testConfig(t)
|
||||
floppies_path := "../../test-fixtures/floppies"
|
||||
cfg["floppy_files"] = []string{fmt.Sprintf("%s/bar.bat", floppies_path), fmt.Sprintf("%s/foo.ps1", floppies_path)}
|
||||
var c Config
|
||||
_, err := c.Prepare(cfg)
|
||||
if err != nil {
|
||||
t.Fatalf("should not have error: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewConfig_InvalidFloppies(t *testing.T) {
|
||||
cfg := testConfig(t)
|
||||
cfg["floppy_files"] = []string{"nonexistent.bat", "nonexistent.ps1"}
|
||||
var c Config
|
||||
_, errs := c.Prepare(cfg)
|
||||
if errs == nil {
|
||||
t.Fatalf("Nonexistent floppies should trigger multierror")
|
||||
}
|
||||
|
||||
if len(errs.(*packersdk.MultiError).Errors) != 2 {
|
||||
t.Fatalf("Multierror should work and report 2 errors")
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewConfig_sourcePath(t *testing.T) {
|
||||
// Okay, because it gets caught during download
|
||||
cfg := testConfig(t)
|
||||
delete(cfg, "source_path")
|
||||
var c Config
|
||||
warns, err := c.Prepare(cfg)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err == nil {
|
||||
t.Fatalf("should error with empty `source_path`")
|
||||
}
|
||||
|
||||
// Good
|
||||
tf := getTempFile(t)
|
||||
defer os.Remove(tf.Name())
|
||||
|
||||
cfg = testConfig(t)
|
||||
cfg["source_path"] = tf.Name()
|
||||
warns, err = c.Prepare(cfg)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("bad: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNewConfig_shutdown_timeout(t *testing.T) {
|
||||
cfg := testConfig(t)
|
||||
tf := getTempFile(t)
|
||||
defer os.Remove(tf.Name())
|
||||
|
||||
// Expect this to fail
|
||||
cfg["source_path"] = tf.Name()
|
||||
cfg["shutdown_timeout"] = "NaN"
|
||||
var c Config
|
||||
warns, err := c.Prepare(cfg)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err == nil {
|
||||
t.Fatal("should error")
|
||||
}
|
||||
|
||||
// Passes when given a valid time duration
|
||||
cfg["shutdown_timeout"] = "10s"
|
||||
warns, err = c.Prepare(cfg)
|
||||
if len(warns) > 0 {
|
||||
t.Fatalf("bad: %#v", warns)
|
||||
}
|
||||
if err != nil {
|
||||
t.Fatalf("bad: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
// TestChecksumFileNameMixedCaseBug reproduces Github issue #9049:
|
||||
// https://github.com/hashicorp/packer/issues/9049
|
||||
func TestChecksumFileNameMixedCaseBug(t *testing.T) {
|
||||
tt := []struct {
|
||||
Name string
|
||||
ChecksumPath string
|
||||
}{
|
||||
{"Lowercase", "file:/tmp/random/file.md5"},
|
||||
{"MiXeDcAsE", "file:/tmp/RaNdOm/FiLe.Md5"},
|
||||
}
|
||||
|
||||
for _, tc := range tt {
|
||||
|
||||
cfg := testConfig(t)
|
||||
cfg["source_path"] = "bug.ovf"
|
||||
cfg["checksum"] = tc.ChecksumPath
|
||||
cfg["type"] = "virtualbox-ovf"
|
||||
cfg["guest_additions_mode"] = "disable"
|
||||
cfg["headless"] = false
|
||||
|
||||
var c Config
|
||||
warns, err := c.Prepare(cfg)
|
||||
if err != nil {
|
||||
t.Errorf("config failed to Prepare, %s", err.Error())
|
||||
}
|
||||
|
||||
if len(warns) != 0 {
|
||||
t.Errorf("Encountered warnings during config preparation: %s", warns)
|
||||
}
|
||||
|
||||
if c.Checksum != tc.ChecksumPath {
|
||||
t.Errorf("%s test failed, Checksum and ChecksumPath are expected to be equal, expected: %s, got: %s", tc.Name, tc.ChecksumPath, c.Checksum)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
package ovf
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/packer-plugin-sdk/multistep"
|
||||
vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common"
|
||||
)
|
||||
|
||||
func TestStepImport_impl(t *testing.T) {
|
||||
var _ multistep.Step = new(StepImport)
|
||||
}
|
||||
|
||||
func TestStepImport(t *testing.T) {
|
||||
state := testState(t)
|
||||
state.Put("vm_path", "foo")
|
||||
|
||||
step := new(StepImport)
|
||||
step.Name = "bar"
|
||||
|
||||
driver := state.Get("driver").(*vboxcommon.DriverMock)
|
||||
|
||||
// Test the run
|
||||
if action := step.Run(context.Background(), state); action != multistep.ActionContinue {
|
||||
t.Fatalf("bad action: %#v", action)
|
||||
}
|
||||
if _, ok := state.GetOk("error"); ok {
|
||||
t.Fatal("should NOT have error")
|
||||
}
|
||||
|
||||
// Test driver
|
||||
if !driver.ImportCalled {
|
||||
t.Fatal("import should be called")
|
||||
}
|
||||
if driver.ImportName != step.Name {
|
||||
t.Fatalf("bad: %#v", driver.ImportName)
|
||||
}
|
||||
|
||||
// Test output state
|
||||
if name, ok := state.GetOk("vmName"); !ok {
|
||||
t.Fatal("vmName should be set")
|
||||
} else if name != "bar" {
|
||||
t.Fatalf("bad: %#v", name)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStepImport_Cleanup(t *testing.T) {
|
||||
state := testState(t)
|
||||
state.Put("vm_path", "foo")
|
||||
|
||||
step := new(StepImport)
|
||||
step.vmName = "bar"
|
||||
|
||||
driver := state.Get("driver").(*vboxcommon.DriverMock)
|
||||
|
||||
step.KeepRegistered = true
|
||||
step.Cleanup(state)
|
||||
if driver.DeleteCalled {
|
||||
t.Fatal("delete should not be called")
|
||||
}
|
||||
|
||||
state.Put(multistep.StateHalted, true)
|
||||
step.Cleanup(state)
|
||||
if !driver.DeleteCalled {
|
||||
t.Fatal("delete should be called")
|
||||
}
|
||||
if driver.DeleteName != "bar" {
|
||||
t.Fatalf("bad: %#v", driver.DeleteName)
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
package ovf
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/packer-plugin-sdk/multistep"
|
||||
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
||||
vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common"
|
||||
)
|
||||
|
||||
func testState(t *testing.T) multistep.StateBag {
|
||||
state := new(multistep.BasicStateBag)
|
||||
state.Put("driver", new(vboxcommon.DriverMock))
|
||||
state.Put("ui", &packersdk.BasicUi{
|
||||
Reader: new(bytes.Buffer),
|
||||
Writer: new(bytes.Buffer),
|
||||
})
|
||||
return state
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
package version
|
||||
|
||||
import (
|
||||
"github.com/hashicorp/packer-plugin-sdk/version"
|
||||
packerVersion "github.com/hashicorp/packer/version"
|
||||
)
|
||||
|
||||
var VirtualboxPluginVersion *version.PluginVersion
|
||||
|
||||
func init() {
|
||||
VirtualboxPluginVersion = version.InitializePluginVersion(
|
||||
packerVersion.Version, packerVersion.VersionPrerelease)
|
||||
}
|
|
@ -51,9 +51,6 @@ import (
|
|||
tritonbuilder "github.com/hashicorp/packer/builder/triton"
|
||||
uclouduhostbuilder "github.com/hashicorp/packer/builder/ucloud/uhost"
|
||||
vagrantbuilder "github.com/hashicorp/packer/builder/vagrant"
|
||||
virtualboxisobuilder "github.com/hashicorp/packer/builder/virtualbox/iso"
|
||||
virtualboxovfbuilder "github.com/hashicorp/packer/builder/virtualbox/ovf"
|
||||
virtualboxvmbuilder "github.com/hashicorp/packer/builder/virtualbox/vm"
|
||||
vmwareisobuilder "github.com/hashicorp/packer/builder/vmware/iso"
|
||||
vmwarevmxbuilder "github.com/hashicorp/packer/builder/vmware/vmx"
|
||||
yandexbuilder "github.com/hashicorp/packer/builder/yandex"
|
||||
|
@ -132,9 +129,6 @@ var Builders = map[string]packersdk.Builder{
|
|||
"triton": new(tritonbuilder.Builder),
|
||||
"ucloud-uhost": new(uclouduhostbuilder.Builder),
|
||||
"vagrant": new(vagrantbuilder.Builder),
|
||||
"virtualbox-iso": new(virtualboxisobuilder.Builder),
|
||||
"virtualbox-ovf": new(virtualboxovfbuilder.Builder),
|
||||
"virtualbox-vm": new(virtualboxvmbuilder.Builder),
|
||||
"vmware-iso": new(vmwareisobuilder.Builder),
|
||||
"vmware-vmx": new(vmwarevmxbuilder.Builder),
|
||||
"yandex": new(yandexbuilder.Builder),
|
||||
|
|
|
@ -22,6 +22,9 @@ import (
|
|||
dockerpushpostprocessor "github.com/hashicorp/packer-plugin-docker/post-processor/docker-push"
|
||||
dockersavepostprocessor "github.com/hashicorp/packer-plugin-docker/post-processor/docker-save"
|
||||
dockertagpostprocessor "github.com/hashicorp/packer-plugin-docker/post-processor/docker-tag"
|
||||
virtualboxisobuilder "github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/iso"
|
||||
virtualboxovfbuilder "github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/ovf"
|
||||
virtualboxvmbuilder "github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/vm"
|
||||
vsphereclonebuilder "github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone"
|
||||
vsphereisobuilder "github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/iso"
|
||||
vspherepostprocessor "github.com/hashicorp/packer-plugin-vsphere/post-processor/vsphere"
|
||||
|
@ -46,6 +49,9 @@ var VendoredBuilders = map[string]packersdk.Builder{
|
|||
"amazon-instance": new(amazoninstancebuilder.Builder),
|
||||
"vsphere-clone": new(vsphereclonebuilder.Builder),
|
||||
"vsphere-iso": new(vsphereisobuilder.Builder),
|
||||
"virtualbox-iso": new(virtualboxisobuilder.Builder),
|
||||
"virtualbox-ovf": new(virtualboxovfbuilder.Builder),
|
||||
"virtualbox-vm": new(virtualboxvmbuilder.Builder),
|
||||
}
|
||||
|
||||
// VendoredProvisioners are provisioner components that were once bundled with the
|
||||
|
|
4
go.mod
4
go.mod
|
@ -30,7 +30,6 @@ require (
|
|||
github.com/go-ini/ini v1.25.4
|
||||
github.com/go-resty/resty/v2 v2.3.0
|
||||
github.com/gobwas/glob v0.2.3
|
||||
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
|
||||
github.com/google/go-cmp v0.5.5
|
||||
github.com/google/go-github/v33 v33.0.1-0.20210113204525-9318e629ec69
|
||||
github.com/google/uuid v1.1.2
|
||||
|
@ -46,12 +45,13 @@ require (
|
|||
github.com/hashicorp/go-multierror v1.1.1
|
||||
github.com/hashicorp/go-oracle-terraform v0.0.0-20181016190316-007121241b79
|
||||
github.com/hashicorp/go-uuid v1.0.2
|
||||
github.com/hashicorp/go-version v1.2.0
|
||||
github.com/hashicorp/go-version v1.3.0
|
||||
github.com/hashicorp/hcl/v2 v2.9.1
|
||||
github.com/hashicorp/packer-plugin-amazon v0.0.1
|
||||
github.com/hashicorp/packer-plugin-ansible v0.0.2
|
||||
github.com/hashicorp/packer-plugin-docker v0.0.7
|
||||
github.com/hashicorp/packer-plugin-sdk v0.1.3
|
||||
github.com/hashicorp/packer-plugin-virtualbox v0.0.1
|
||||
github.com/hashicorp/packer-plugin-vsphere v0.0.0-20210415100050-d0269b5646e6
|
||||
github.com/hashicorp/vault/api v1.0.4
|
||||
github.com/hetznercloud/hcloud-go v1.15.1
|
||||
|
|
7
go.sum
7
go.sum
|
@ -402,8 +402,9 @@ github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2I
|
|||
github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
|
||||
github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
github.com/hashicorp/go-version v1.2.0 h1:3vNe/fWF5CBgRIguda1meWhsZHy3m8gCJ5wx+dIzX/E=
|
||||
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
github.com/hashicorp/go-version v1.3.0 h1:McDWVJIU/y+u1BRV06dPaLfLCaT7fUTJLp5r04x7iNw=
|
||||
github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
|
||||
github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
|
@ -451,6 +452,10 @@ github.com/hashicorp/packer-plugin-sdk v0.1.2/go.mod h1:KRjczE1/c9NV5Re+PXt3myJs
|
|||
github.com/hashicorp/packer-plugin-sdk v0.1.3-0.20210407232143-c217d82aefb6/go.mod h1:xePpgQgQYv/bamiypx3hH9ukidxDdcN8q0R0wLi8IEQ=
|
||||
github.com/hashicorp/packer-plugin-sdk v0.1.3 h1:oHTVlgoX2piUzL54+LBo9uIMfW+L/kY7or83dDStdIY=
|
||||
github.com/hashicorp/packer-plugin-sdk v0.1.3/go.mod h1:xePpgQgQYv/bamiypx3hH9ukidxDdcN8q0R0wLi8IEQ=
|
||||
github.com/hashicorp/packer-plugin-virtualbox v0.0.0-20210415132603-5d753f7335b4 h1:AQk/P0QydTRFda9br8Dv3DDv7DCjGLHwfLjXmudA900=
|
||||
github.com/hashicorp/packer-plugin-virtualbox v0.0.0-20210415132603-5d753f7335b4/go.mod h1:OOGNMK8Y8zjsYngesZH5kCbH0Fj8PKvhqPp8w1ejM3Y=
|
||||
github.com/hashicorp/packer-plugin-virtualbox v0.0.1 h1:vTfy7a10RUVMdNnDLo0EQrCVbAG4rGWkaDTMC7MVBi4=
|
||||
github.com/hashicorp/packer-plugin-virtualbox v0.0.1/go.mod h1:OOGNMK8Y8zjsYngesZH5kCbH0Fj8PKvhqPp8w1ejM3Y=
|
||||
github.com/hashicorp/packer-plugin-vsphere v0.0.0-20210415100050-d0269b5646e6 h1:pOv7Apd4P3KEpNBHLV4E7tKlwHoInCU/bnPVadGSDxY=
|
||||
github.com/hashicorp/packer-plugin-vsphere v0.0.0-20210415100050-d0269b5646e6/go.mod h1:XMhsLDDT7sD2BWaruLvGPynnn4IqdbrfvuKhb1GK1RI=
|
||||
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
language: go
|
||||
|
||||
go:
|
||||
- 1.2
|
||||
- 1.3
|
||||
- 1.4
|
||||
- 1.9
|
||||
- "1.10"
|
||||
- 1.11
|
||||
- 1.12
|
||||
|
||||
script:
|
||||
- go test
|
|
@ -0,0 +1,25 @@
|
|||
# 1.3.0 (March 31, 2021)
|
||||
|
||||
Please note that CHANGELOG.md does not exist in the source code prior to this release.
|
||||
|
||||
FEATURES:
|
||||
- Add `Core` function to return a version without prerelease or metadata ([#85](https://github.com/hashicorp/go-version/pull/85))
|
||||
|
||||
# 1.2.1 (June 17, 2020)
|
||||
|
||||
BUG FIXES:
|
||||
- Prevent `Version.Equal` method from panicking on `nil` encounter ([#73](https://github.com/hashicorp/go-version/pull/73))
|
||||
|
||||
# 1.2.0 (April 23, 2019)
|
||||
|
||||
FEATURES:
|
||||
- Add `GreaterThanOrEqual` and `LessThanOrEqual` helper methods ([#53](https://github.com/hashicorp/go-version/pull/53))
|
||||
|
||||
# 1.1.0 (Jan 07, 2019)
|
||||
|
||||
FEATURES:
|
||||
- Add `NewSemver` constructor ([#45](https://github.com/hashicorp/go-version/pull/45))
|
||||
|
||||
# 1.0.0 (August 24, 2018)
|
||||
|
||||
Initial release.
|
|
@ -1,5 +1,6 @@
|
|||
# Versioning Library for Go
|
||||
[![Build Status](https://travis-ci.org/hashicorp/go-version.svg?branch=master)](https://travis-ci.org/hashicorp/go-version)
|
||||
[![Build Status](https://circleci.com/gh/hashicorp/go-version/tree/master.svg?style=svg)](https://circleci.com/gh/hashicorp/go-version/tree/master)
|
||||
[![GoDoc](https://godoc.org/github.com/hashicorp/go-version?status.svg)](https://godoc.org/github.com/hashicorp/go-version)
|
||||
|
||||
go-version is a library for parsing versions and version constraints,
|
||||
and verifying versions against a set of constraints. go-version
|
||||
|
|
|
@ -278,8 +278,20 @@ func comparePrereleases(v string, other string) int {
|
|||
return 0
|
||||
}
|
||||
|
||||
// Core returns a new version constructed from only the MAJOR.MINOR.PATCH
|
||||
// segments of the version, without prerelease or metadata.
|
||||
func (v *Version) Core() *Version {
|
||||
segments := v.Segments64()
|
||||
segmentsOnly := fmt.Sprintf("%d.%d.%d", segments[0], segments[1], segments[2])
|
||||
return Must(NewVersion(segmentsOnly))
|
||||
}
|
||||
|
||||
// Equal tests if two versions are equal.
|
||||
func (v *Version) Equal(o *Version) bool {
|
||||
if v == nil || o == nil {
|
||||
return v == o
|
||||
}
|
||||
|
||||
return v.Compare(o) == 0
|
||||
}
|
||||
|
||||
|
@ -288,7 +300,7 @@ func (v *Version) GreaterThan(o *Version) bool {
|
|||
return v.Compare(o) > 0
|
||||
}
|
||||
|
||||
// GreaterThanOrEqualTo tests if this version is greater than or equal to another version.
|
||||
// GreaterThanOrEqual tests if this version is greater than or equal to another version.
|
||||
func (v *Version) GreaterThanOrEqual(o *Version) bool {
|
||||
return v.Compare(o) >= 0
|
||||
}
|
||||
|
@ -298,7 +310,7 @@ func (v *Version) LessThan(o *Version) bool {
|
|||
return v.Compare(o) < 0
|
||||
}
|
||||
|
||||
// LessThanOrEqualTo tests if this version is less than or equal to another version.
|
||||
// LessThanOrEqual tests if this version is less than or equal to another version.
|
||||
func (v *Version) LessThanOrEqual(o *Version) bool {
|
||||
return v.Compare(o) <= 0
|
||||
}
|
||||
|
|
|
@ -0,0 +1,373 @@
|
|||
Mozilla Public License Version 2.0
|
||||
==================================
|
||||
|
||||
1. Definitions
|
||||
--------------
|
||||
|
||||
1.1. "Contributor"
|
||||
means each individual or legal entity that creates, contributes to
|
||||
the creation of, or owns Covered Software.
|
||||
|
||||
1.2. "Contributor Version"
|
||||
means the combination of the Contributions of others (if any) used
|
||||
by a Contributor and that particular Contributor's Contribution.
|
||||
|
||||
1.3. "Contribution"
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
1.4. "Covered Software"
|
||||
means Source Code Form to which the initial Contributor has attached
|
||||
the notice in Exhibit A, the Executable Form of such Source Code
|
||||
Form, and Modifications of such Source Code Form, in each case
|
||||
including portions thereof.
|
||||
|
||||
1.5. "Incompatible With Secondary Licenses"
|
||||
means
|
||||
|
||||
(a) that the initial Contributor has attached the notice described
|
||||
in Exhibit B to the Covered Software; or
|
||||
|
||||
(b) that the Covered Software was made available under the terms of
|
||||
version 1.1 or earlier of the License, but not also under the
|
||||
terms of a Secondary License.
|
||||
|
||||
1.6. "Executable Form"
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
1.7. "Larger Work"
|
||||
means a work that combines Covered Software with other material, in
|
||||
a separate file or files, that is not Covered Software.
|
||||
|
||||
1.8. "License"
|
||||
means this document.
|
||||
|
||||
1.9. "Licensable"
|
||||
means having the right to grant, to the maximum extent possible,
|
||||
whether at the time of the initial grant or subsequently, any and
|
||||
all of the rights conveyed by this License.
|
||||
|
||||
1.10. "Modifications"
|
||||
means any of the following:
|
||||
|
||||
(a) any file in Source Code Form that results from an addition to,
|
||||
deletion from, or modification of the contents of Covered
|
||||
Software; or
|
||||
|
||||
(b) any new file in Source Code Form that contains any Covered
|
||||
Software.
|
||||
|
||||
1.11. "Patent Claims" of a Contributor
|
||||
means any patent claim(s), including without limitation, method,
|
||||
process, and apparatus claims, in any patent Licensable by such
|
||||
Contributor that would be infringed, but for the grant of the
|
||||
License, by the making, using, selling, offering for sale, having
|
||||
made, import, or transfer of either its Contributions or its
|
||||
Contributor Version.
|
||||
|
||||
1.12. "Secondary License"
|
||||
means either the GNU General Public License, Version 2.0, the GNU
|
||||
Lesser General Public License, Version 2.1, the GNU Affero General
|
||||
Public License, Version 3.0, or any later versions of those
|
||||
licenses.
|
||||
|
||||
1.13. "Source Code Form"
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
1.14. "You" (or "Your")
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, "You" includes any entity that
|
||||
controls, is controlled by, or is under common control with You. For
|
||||
purposes of this definition, "control" means (a) the power, direct
|
||||
or indirect, to cause the direction or management of such entity,
|
||||
whether by contract or otherwise, or (b) ownership of more than
|
||||
fifty percent (50%) of the outstanding shares or beneficial
|
||||
ownership of such entity.
|
||||
|
||||
2. License Grants and Conditions
|
||||
--------------------------------
|
||||
|
||||
2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
(a) under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or
|
||||
as part of a Larger Work; and
|
||||
|
||||
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
||||
for sale, have made, import, and otherwise transfer either its
|
||||
Contributions or its Contributor Version.
|
||||
|
||||
2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution
|
||||
become effective for each Contribution on the date the Contributor first
|
||||
distributes such Contribution.
|
||||
|
||||
2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under
|
||||
this License. No additional rights or licenses will be implied from the
|
||||
distribution or licensing of Covered Software under this License.
|
||||
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||
Contributor:
|
||||
|
||||
(a) for any code that a Contributor has removed from Covered Software;
|
||||
or
|
||||
|
||||
(b) for infringements caused by: (i) Your and any other third party's
|
||||
modifications of Covered Software, or (ii) the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
|
||||
(c) under Patent Claims infringed by Covered Software in the absence of
|
||||
its Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks,
|
||||
or logos of any Contributor (except as may be necessary to comply with
|
||||
the notice requirements in Section 3.4).
|
||||
|
||||
2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this
|
||||
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||
permitted under the terms of Section 3.3).
|
||||
|
||||
2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its
|
||||
Contributions are its original creation(s) or it has sufficient rights
|
||||
to grant the rights to its Contributions conveyed by this License.
|
||||
|
||||
2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under
|
||||
applicable copyright doctrines of fair use, fair dealing, or other
|
||||
equivalents.
|
||||
|
||||
2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
||||
in Section 2.1.
|
||||
|
||||
3. Responsibilities
|
||||
-------------------
|
||||
|
||||
3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under
|
||||
the terms of this License. You must inform recipients that the Source
|
||||
Code Form of the Covered Software is governed by the terms of this
|
||||
License, and how they can obtain a copy of this License. You may not
|
||||
attempt to alter or restrict the recipients' rights in the Source Code
|
||||
Form.
|
||||
|
||||
3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
(a) such Covered Software must also be made available in Source Code
|
||||
Form, as described in Section 3.1, and You must inform recipients of
|
||||
the Executable Form how they can obtain a copy of such Source Code
|
||||
Form by reasonable means in a timely manner, at a charge no more
|
||||
than the cost of distribution to the recipient; and
|
||||
|
||||
(b) You may distribute such Executable Form under the terms of this
|
||||
License, or sublicense it under different terms, provided that the
|
||||
license for the Executable Form does not attempt to limit or alter
|
||||
the recipients' rights in the Source Code Form under this License.
|
||||
|
||||
3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for
|
||||
the Covered Software. If the Larger Work is a combination of Covered
|
||||
Software with a work governed by one or more Secondary Licenses, and the
|
||||
Covered Software is not Incompatible With Secondary Licenses, this
|
||||
License permits You to additionally distribute such Covered Software
|
||||
under the terms of such Secondary License(s), so that the recipient of
|
||||
the Larger Work may, at their option, further distribute the Covered
|
||||
Software under the terms of either this License or such Secondary
|
||||
License(s).
|
||||
|
||||
3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices
|
||||
(including copyright notices, patent notices, disclaimers of warranty,
|
||||
or limitations of liability) contained within the Source Code Form of
|
||||
the Covered Software, except that You may alter any license notices to
|
||||
the extent required to remedy known factual inaccuracies.
|
||||
|
||||
3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on
|
||||
behalf of any Contributor. You must make it absolutely clear that any
|
||||
such warranty, support, indemnity, or liability obligation is offered by
|
||||
You alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation
|
||||
---------------------------------------------------
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this
|
||||
License with respect to some or all of the Covered Software due to
|
||||
statute, judicial order, or regulation then You must: (a) comply with
|
||||
the terms of this License to the maximum extent possible; and (b)
|
||||
describe the limitations and the code they affect. Such description must
|
||||
be placed in a text file included with all distributions of the Covered
|
||||
Software under this License. Except to the extent prohibited by statute
|
||||
or regulation, such description must be sufficiently detailed for a
|
||||
recipient of ordinary skill to be able to understand it.
|
||||
|
||||
5. Termination
|
||||
--------------
|
||||
|
||||
5.1. The rights granted under this License will terminate automatically
|
||||
if You fail to comply with any of its terms. However, if You become
|
||||
compliant, then the rights granted under this License from a particular
|
||||
Contributor are reinstated (a) provisionally, unless and until such
|
||||
Contributor explicitly and finally terminates Your grants, and (b) on an
|
||||
ongoing basis, if such Contributor fails to notify You of the
|
||||
non-compliance by some reasonable means prior to 60 days after You have
|
||||
come back into compliance. Moreover, Your grants from a particular
|
||||
Contributor are reinstated on an ongoing basis if such Contributor
|
||||
notifies You of the non-compliance by some reasonable means, this is the
|
||||
first time You have received notice of non-compliance with this License
|
||||
from such Contributor, and You become compliant prior to 30 days after
|
||||
Your receipt of the notice.
|
||||
|
||||
5.2. If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions,
|
||||
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||
directly or indirectly infringes any patent, then the rights granted to
|
||||
You by any and all Contributors for the Covered Software under Section
|
||||
2.1 of this License shall terminate.
|
||||
|
||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
||||
end user license agreements (excluding distributors and resellers) which
|
||||
have been validly granted by You or Your distributors under this License
|
||||
prior to termination shall survive termination.
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 6. Disclaimer of Warranty *
|
||||
* ------------------------- *
|
||||
* *
|
||||
* Covered Software is provided under this License on an "as is" *
|
||||
* basis, without warranty of any kind, either expressed, implied, or *
|
||||
* statutory, including, without limitation, warranties that the *
|
||||
* Covered Software is free of defects, merchantable, fit for a *
|
||||
* particular purpose or non-infringing. The entire risk as to the *
|
||||
* quality and performance of the Covered Software is with You. *
|
||||
* Should any Covered Software prove defective in any respect, You *
|
||||
* (not any Contributor) assume the cost of any necessary servicing, *
|
||||
* repair, or correction. This disclaimer of warranty constitutes an *
|
||||
* essential part of this License. No use of any Covered Software is *
|
||||
* authorized under this License except under this disclaimer. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 7. Limitation of Liability *
|
||||
* -------------------------- *
|
||||
* *
|
||||
* Under no circumstances and under no legal theory, whether tort *
|
||||
* (including negligence), contract, or otherwise, shall any *
|
||||
* Contributor, or anyone who distributes Covered Software as *
|
||||
* permitted above, be liable to You for any direct, indirect, *
|
||||
* special, incidental, or consequential damages of any character *
|
||||
* including, without limitation, damages for lost profits, loss of *
|
||||
* goodwill, work stoppage, computer failure or malfunction, or any *
|
||||
* and all other commercial damages or losses, even if such party *
|
||||
* shall have been informed of the possibility of such damages. This *
|
||||
* limitation of liability shall not apply to liability for death or *
|
||||
* personal injury resulting from such party's negligence to the *
|
||||
* extent applicable law prohibits such limitation. Some *
|
||||
* jurisdictions do not allow the exclusion or limitation of *
|
||||
* incidental or consequential damages, so this exclusion and *
|
||||
* limitation may not apply to You. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
8. Litigation
|
||||
-------------
|
||||
|
||||
Any litigation relating to this License may be brought only in the
|
||||
courts of a jurisdiction where the defendant maintains its principal
|
||||
place of business and such litigation shall be governed by laws of that
|
||||
jurisdiction, without reference to its conflict-of-law provisions.
|
||||
Nothing in this Section shall prevent a party's ability to bring
|
||||
cross-claims or counter-claims.
|
||||
|
||||
9. Miscellaneous
|
||||
----------------
|
||||
|
||||
This License represents the complete agreement concerning the subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. Any law or regulation which provides
|
||||
that the language of a contract shall be construed against the drafter
|
||||
shall not be used to construe this License against a Contributor.
|
||||
|
||||
10. Versions of the License
|
||||
---------------------------
|
||||
|
||||
10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version
|
||||
of the License under which You originally received the Covered Software,
|
||||
or under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a
|
||||
modified version of this License if you rename the license and remove
|
||||
any references to the name of the license steward (except to note that
|
||||
such modified license differs from this License).
|
||||
|
||||
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||
Licenses
|
||||
|
||||
If You choose to distribute Source Code Form that is Incompatible With
|
||||
Secondary Licenses under the terms of this version of the License, the
|
||||
notice described in Exhibit B of this License must be attached.
|
||||
|
||||
Exhibit A - Source Code Form License Notice
|
||||
-------------------------------------------
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular
|
||||
file, then You may include the notice in a location (such as a LICENSE
|
||||
file in a relevant directory) where a recipient would be likely to look
|
||||
for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||
---------------------------------------------------------
|
||||
|
||||
This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
defined by the Mozilla Public License, v. 2.0.
|
|
@ -18,7 +18,7 @@ import (
|
|||
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
||||
"github.com/hashicorp/packer-plugin-sdk/template/config"
|
||||
"github.com/hashicorp/packer-plugin-sdk/template/interpolate"
|
||||
vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common"
|
||||
vboxcommon "github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/common"
|
||||
)
|
||||
|
||||
const BuilderId = "mitchellh.virtualbox"
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
"github.com/hashicorp/packer-plugin-sdk/multistep"
|
||||
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
||||
vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common"
|
||||
vboxcommon "github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/common"
|
||||
|
||||
"path/filepath"
|
||||
"strconv"
|
|
@ -8,7 +8,7 @@ import (
|
|||
|
||||
"github.com/hashicorp/packer-plugin-sdk/multistep"
|
||||
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
||||
vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common"
|
||||
vboxcommon "github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/common"
|
||||
)
|
||||
|
||||
// This step creates the actual virtual machine.
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/hashicorp/packer-plugin-sdk/multistep"
|
||||
"github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps"
|
||||
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
||||
vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common"
|
||||
vboxcommon "github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/common"
|
||||
)
|
||||
|
||||
// Builder implements packersdk.Builder and builds the actual VirtualBox
|
|
@ -12,7 +12,7 @@ import (
|
|||
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
||||
"github.com/hashicorp/packer-plugin-sdk/template/config"
|
||||
"github.com/hashicorp/packer-plugin-sdk/template/interpolate"
|
||||
vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common"
|
||||
vboxcommon "github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/common"
|
||||
)
|
||||
|
||||
// Config is the configuration structure for the builder.
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
"github.com/hashicorp/packer-plugin-sdk/multistep"
|
||||
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
||||
vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common"
|
||||
vboxcommon "github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/common"
|
||||
)
|
||||
|
||||
// This step imports an OVF VM into VirtualBox.
|
|
@ -10,7 +10,7 @@ import (
|
|||
"github.com/hashicorp/packer-plugin-sdk/multistep"
|
||||
"github.com/hashicorp/packer-plugin-sdk/multistep/commonsteps"
|
||||
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
||||
vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common"
|
||||
vboxcommon "github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/common"
|
||||
)
|
||||
|
||||
// Builder implements packersdk.Builder and builds the actual VirtualBox
|
|
@ -14,7 +14,7 @@ import (
|
|||
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
||||
"github.com/hashicorp/packer-plugin-sdk/template/config"
|
||||
"github.com/hashicorp/packer-plugin-sdk/template/interpolate"
|
||||
vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common"
|
||||
vboxcommon "github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/common"
|
||||
)
|
||||
|
||||
// Config is the configuration structure for the builder.
|
|
@ -7,7 +7,7 @@ import (
|
|||
|
||||
"github.com/hashicorp/packer-plugin-sdk/multistep"
|
||||
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
||||
vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common"
|
||||
vboxcommon "github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/common"
|
||||
)
|
||||
|
||||
type StepCreateSnapshot struct {
|
|
@ -6,7 +6,7 @@ import (
|
|||
|
||||
"github.com/hashicorp/packer-plugin-sdk/multistep"
|
||||
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
|
||||
vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common"
|
||||
vboxcommon "github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/common"
|
||||
)
|
||||
|
||||
type StepSetSnapshot struct {
|
|
@ -336,7 +336,6 @@ github.com/gofrs/flock
|
|||
# github.com/gofrs/uuid v4.0.0+incompatible
|
||||
github.com/gofrs/uuid
|
||||
# github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
|
||||
## explicit
|
||||
github.com/golang-collections/collections/stack
|
||||
# github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e
|
||||
github.com/golang/groupcache/lru
|
||||
|
@ -467,7 +466,7 @@ github.com/hashicorp/go-sockaddr
|
|||
# github.com/hashicorp/go-uuid v1.0.2
|
||||
## explicit
|
||||
github.com/hashicorp/go-uuid
|
||||
# github.com/hashicorp/go-version v1.2.0
|
||||
# github.com/hashicorp/go-version v1.3.0
|
||||
## explicit
|
||||
github.com/hashicorp/go-version
|
||||
# github.com/hashicorp/golang-lru v0.5.3
|
||||
|
@ -562,6 +561,12 @@ github.com/hashicorp/packer-plugin-sdk/tmp
|
|||
github.com/hashicorp/packer-plugin-sdk/useragent
|
||||
github.com/hashicorp/packer-plugin-sdk/uuid
|
||||
github.com/hashicorp/packer-plugin-sdk/version
|
||||
# github.com/hashicorp/packer-plugin-virtualbox v0.0.1
|
||||
## explicit
|
||||
github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/common
|
||||
github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/iso
|
||||
github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/ovf
|
||||
github.com/hashicorp/packer-plugin-virtualbox/builder/virtualbox/vm
|
||||
# github.com/hashicorp/packer-plugin-vsphere v0.0.0-20210415100050-d0269b5646e6
|
||||
## explicit
|
||||
github.com/hashicorp/packer-plugin-vsphere/builder/vsphere/clone
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
---
|
||||
description: >
|
||||
The VirtualBox Packer builder is able to create VirtualBox virtual machines
|
||||
and
|
||||
|
||||
export them in the OVA or OVF format.
|
||||
page_title: VirtualBox - Builders
|
||||
---
|
||||
|
||||
# VirtualBox Builder
|
||||
|
||||
The VirtualBox Packer builder is able to create
|
||||
[VirtualBox](https://www.virtualbox.org) virtual machines and export them in
|
||||
the OVA or OVF format.
|
||||
|
||||
Packer actually comes with multiple builders able to create VirtualBox
|
||||
machines, depending on the strategy you want to use to build the image. Packer
|
||||
supports the following VirtualBox builders:
|
||||
|
||||
- [virtualbox-iso](/docs/builders/virtualbox-iso) - Starts from an ISO
|
||||
file, creates a brand new VirtualBox VM, installs an OS, provisions
|
||||
software within the OS, then exports that machine to create an image. This
|
||||
is best for people who want to start from scratch.
|
||||
|
||||
- [virtualbox-ovf](/docs/builders/virtualbox-ovf) - This builder imports
|
||||
an existing OVF/OVA file, runs provisioners on top of that VM, and exports
|
||||
that machine to create an image. This is best if you have an existing
|
||||
VirtualBox VM export you want to use as the source. As an additional
|
||||
benefit, you can feed the artifact of this builder back into itself to
|
||||
iterate on a machine.
|
||||
|
||||
- [virtualbox-vm](/docs/builders/virtualbox-vm) - This builder uses an
|
||||
existing VM to run defined provisioners on top of that VM, and optionally
|
||||
creates a snapshot to save the changes applied from the provisioners. In
|
||||
addition the builder is able to export that machine to create an image. The
|
||||
builder is able to attach to a defined snapshot as a starting point, which
|
||||
could be defined statically or dynamically via a variable.
|
|
@ -1,279 +0,0 @@
|
|||
---
|
||||
modeline: |
|
||||
vim: set ft=pandoc:
|
||||
description: |
|
||||
The VirtualBox Packer builder is able to create VirtualBox virtual machines
|
||||
and export them in the OVF format, starting from an ISO image.
|
||||
page_title: VirtualBox ISO - Builders
|
||||
---
|
||||
|
||||
# VirtualBox Builder (from an ISO)
|
||||
|
||||
Type: `virtualbox-iso`
|
||||
Artifact BuilderId: `mitchellh.virtualbox`
|
||||
|
||||
The VirtualBox Packer builder is able to create
|
||||
[VirtualBox](https://www.virtualbox.org/) virtual machines and export them in
|
||||
the OVF format, starting from an ISO image.
|
||||
|
||||
The builder builds a virtual machine by creating a new virtual machine from
|
||||
scratch, booting it, installing an OS, provisioning software within the OS, then
|
||||
shutting it down. The result of the VirtualBox builder is a directory containing
|
||||
all the files necessary to run the virtual machine portably.
|
||||
|
||||
## Basic Example
|
||||
|
||||
Here is a basic example. This example is not functional. It will start the OS
|
||||
installer but then fail because we don't provide the preseed file for Ubuntu to
|
||||
self-install. Still, the example serves to show the basic configuration:
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "virtualbox-iso",
|
||||
"guest_os_type": "Ubuntu_64",
|
||||
"iso_url": "http://releases.ubuntu.com/12.04/ubuntu-12.04.5-server-amd64.iso",
|
||||
"iso_checksum": "md5:769474248a3897f4865817446f9a4a53",
|
||||
"ssh_username": "packer",
|
||||
"ssh_password": "packer",
|
||||
"shutdown_command": "echo 'packer' | sudo -S shutdown -P now"
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
source "virtualbox-iso" "basic-example" {
|
||||
guest_os_type = "Ubuntu_64"
|
||||
iso_url = "http://releases.ubuntu.com/12.04/ubuntu-12.04.5-server-amd64.iso"
|
||||
iso_checksum = "md5:769474248a3897f4865817446f9a4a53"
|
||||
ssh_username = "packer"
|
||||
ssh_password = "packer"
|
||||
shutdown_command = "echo 'packer' | sudo -S shutdown -P now"
|
||||
}
|
||||
|
||||
build {
|
||||
sources = ["sources.virtualbox-iso.basic-example"]
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
It is important to add a `shutdown_command`. By default Packer halts the virtual
|
||||
machine and the file system may not be sync'd. Thus, changes made in a
|
||||
provisioner might not be saved.
|
||||
|
||||
## VirtualBox-ISO Builder Configuration Reference
|
||||
|
||||
There are many configuration options available for the builder. In addition to
|
||||
the items listed here, you will want to look at the general configuration
|
||||
references for [ISO](#iso-configuration),
|
||||
[HTTP](#http-directory-configuration),
|
||||
[Floppy](#floppy-configuration),
|
||||
[Export](#export-configuration),
|
||||
[Boot](#boot-configuration),
|
||||
[Shutdown](#shutdown-configuration),
|
||||
[Run](#run-configuration),
|
||||
[Communicator](#communicator-configuration)
|
||||
configuration references, which are
|
||||
necessary for this build to succeed and can be found further down the page.
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'builder/virtualbox/iso/Config-not-required.mdx'
|
||||
|
||||
@include 'builder/virtualbox/common/VBoxVersionConfig-not-required.mdx'
|
||||
|
||||
@include 'builder/virtualbox/common/VBoxBundleConfig-not-required.mdx'
|
||||
|
||||
@include 'builder/virtualbox/common/GuestAdditionsConfig-not-required.mdx'
|
||||
|
||||
### ISO Configuration
|
||||
|
||||
@include 'packer-plugin-sdk/multistep/commonsteps/ISOConfig.mdx'
|
||||
|
||||
#### Required:
|
||||
|
||||
@include 'packer-plugin-sdk/multistep/commonsteps/ISOConfig-required.mdx'
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'packer-plugin-sdk/multistep/commonsteps/ISOConfig-not-required.mdx'
|
||||
|
||||
### Http directory configuration
|
||||
|
||||
@include 'packer-plugin-sdk/multistep/commonsteps/HTTPConfig.mdx'
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'packer-plugin-sdk/multistep/commonsteps/HTTPConfig-not-required.mdx'
|
||||
|
||||
### Floppy configuration
|
||||
|
||||
@include 'packer-plugin-sdk/multistep/commonsteps/FloppyConfig.mdx'
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'packer-plugin-sdk/multistep/commonsteps/FloppyConfig-not-required.mdx'
|
||||
|
||||
### CD configuration
|
||||
|
||||
@include 'packer-plugin-sdk/multistep/commonsteps/CDConfig.mdx'
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'packer-plugin-sdk/multistep/commonsteps/CDConfig-not-required.mdx'
|
||||
|
||||
### Export configuration
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'builder/virtualbox/common/ExportConfig-not-required.mdx'
|
||||
|
||||
### Output configuration
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'builder/virtualbox/common/OutputConfig-not-required.mdx'
|
||||
|
||||
### Run configuration
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'builder/virtualbox/common/RunConfig-not-required.mdx'
|
||||
|
||||
### Shutdown configuration
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'builder/virtualbox/common/ShutdownConfig-not-required.mdx'
|
||||
|
||||
### Hardware configuration
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'builder/virtualbox/common/HWConfig-not-required.mdx'
|
||||
|
||||
### VBox Manage configuration
|
||||
|
||||
@include 'builder/virtualbox/common/VBoxManageConfig.mdx'
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'builder/virtualbox/common/VBoxManageConfig-not-required.mdx'
|
||||
|
||||
### Communicator configuration
|
||||
|
||||
#### Optional common fields:
|
||||
|
||||
@include 'packer-plugin-sdk/communicator/Config-not-required.mdx'
|
||||
|
||||
@include 'builder/virtualbox/common/CommConfig-not-required.mdx'
|
||||
|
||||
#### Optional SSH fields:
|
||||
|
||||
@include 'packer-plugin-sdk/communicator/SSH-not-required.mdx'
|
||||
|
||||
@include 'packer-plugin-sdk/communicator/SSH-Private-Key-File-not-required.mdx'
|
||||
|
||||
@include 'packer-plugin-sdk/communicator/SSH-Agent-Auth-not-required.mdx'
|
||||
|
||||
#### Optional WinRM fields:
|
||||
|
||||
@include 'packer-plugin-sdk/communicator/WinRM-not-required.mdx'
|
||||
|
||||
### Boot Configuration
|
||||
|
||||
@include 'packer-plugin-sdk/bootcommand/BootConfig.mdx'
|
||||
|
||||
Please note that for the Virtuabox builder, the IP address of the HTTP server
|
||||
Packer launches for you to access files like the preseed file in the example
|
||||
above (`{{ .HTTPIP }}`) is hardcoded to 10.0.2.2. If you change the network
|
||||
of your VM you must guarantee that you can still access this HTTP server.
|
||||
|
||||
The boot command is sent to the VM through the `VBoxManage` utility in as few
|
||||
invocations as possible. We send each character in groups of 25, with a default
|
||||
delay of 100ms between groups. The delay alleviates issues with latency and CPU
|
||||
contention. If you notice missing keys, you can tune this delay by specifying
|
||||
"boot_keygroup_interval" in your Packer template, for example:
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
{
|
||||
"builders": [
|
||||
{
|
||||
"type": "virtualbox-iso",
|
||||
"boot_keygroup_interval": "500ms"
|
||||
...
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
source "virtualbox-iso" "basic-example" {
|
||||
boot_keygroup_interval = "500ms"
|
||||
# ...
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'packer-plugin-sdk/bootcommand/BootConfig-not-required.mdx'
|
||||
|
||||
@include 'builders/virtualbox-ssh-key-pair.mdx'
|
||||
|
||||
## Guest Additions
|
||||
|
||||
Packer will automatically download the proper guest additions for the version of
|
||||
VirtualBox that is running and upload those guest additions into the virtual
|
||||
machine so that provisioners can easily install them.
|
||||
|
||||
Packer downloads the guest additions from the official VirtualBox website, and
|
||||
verifies the file with the official checksums released by VirtualBox.
|
||||
|
||||
After the virtual machine is up and the operating system is installed, Packer
|
||||
uploads the guest additions into the virtual machine. The path where they are
|
||||
uploaded is controllable by `guest_additions_path`, and defaults to
|
||||
"VBoxGuestAdditions.iso". Without an absolute path, it is uploaded to the home
|
||||
directory of the SSH user.
|
||||
|
||||
## Creating an EFI enabled VM
|
||||
|
||||
If you want to create an EFI enabled VM, make sure you set the `iso_interface`
|
||||
to "sata". Otherwise your attached drive will not be bootable. Example:
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
"iso_interface": "sata",
|
||||
"vboxmanage": [
|
||||
[ "modifyvm", "{{.Name}}", "--firmware", "EFI" ]
|
||||
]
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
iso_interface = "sata"
|
||||
vboxmanage = [
|
||||
[ "modifyvm", "{{.Name}}", "--firmware", "EFI" ]
|
||||
]
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
|
@ -1,249 +0,0 @@
|
|||
---
|
||||
modeline: |
|
||||
vim: set ft=pandoc:
|
||||
description: |
|
||||
This VirtualBox Packer builder is able to create VirtualBox virtual machines
|
||||
and export them in the OVF format, starting from an existing OVF/OVA (exported
|
||||
virtual machine image).
|
||||
page_title: VirtualBox OVF/OVA - Builders
|
||||
---
|
||||
|
||||
# VirtualBox Builder (from an OVF/OVA)
|
||||
|
||||
Type: `virtualbox-ovf`
|
||||
Artifact BuilderId: `mitchellh.virtualbox`
|
||||
|
||||
This VirtualBox Packer builder is able to create
|
||||
[VirtualBox](https://www.virtualbox.org/) virtual machines and export them in
|
||||
the OVF format, starting from an existing OVF/OVA (exported virtual machine
|
||||
image).
|
||||
|
||||
When exporting from VirtualBox make sure to choose OVF Version 2, since Version
|
||||
1 is not compatible and will generate errors like this:
|
||||
|
||||
```shell-session
|
||||
==> virtualbox-ovf: Progress state: VBOX_E_FILE_ERROR
|
||||
==> virtualbox-ovf: VBoxManage: error: Appliance read failed
|
||||
==> virtualbox-ovf: VBoxManage: error: Error reading "source.ova": element "Section" has no "type" attribute, line 21
|
||||
==> virtualbox-ovf: VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component Appliance, interface IAppliance
|
||||
==> virtualbox-ovf: VBoxManage: error: Context: "int handleImportAppliance(HandlerArg*)" at line 304 of file VBoxManageAppliance.cpp
|
||||
```
|
||||
|
||||
The builder builds a virtual machine by importing an existing OVF or OVA file.
|
||||
It then boots this image, runs provisioners on this new VM, and exports that VM
|
||||
to create the image. The imported machine is deleted prior to finishing the
|
||||
build.
|
||||
|
||||
## Basic Example
|
||||
|
||||
Here is a basic example. This example is functional if you have an OVF matching
|
||||
the settings here.
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "virtualbox-ovf",
|
||||
"source_path": "source.ovf",
|
||||
"ssh_username": "packer",
|
||||
"ssh_password": "packer",
|
||||
"shutdown_command": "echo 'packer' | sudo -S shutdown -P now"
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
source "virtualbox-ovf" "basic-example" {
|
||||
source_path = "source.ovf"
|
||||
ssh_username = "packer"
|
||||
ssh_password = "packer"
|
||||
shutdown_command = "echo 'packer' | sudo -S shutdown -P now"
|
||||
}
|
||||
|
||||
build {
|
||||
sources = ["sources.virtualbox-ovf.basic-example"]
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
It is important to add a `shutdown_command`. By default Packer halts the virtual
|
||||
machine and the file system may not be sync'd. Thus, changes made in a
|
||||
provisioner might not be saved.
|
||||
|
||||
## Configuration Reference
|
||||
|
||||
There are many configuration options available for the builder. In addition to
|
||||
the items listed here, you will want to look at the general configuration
|
||||
references for [ISO](#iso-configuration),
|
||||
[HTTP](#http-directory-configuration),
|
||||
[Floppy](#floppy-configuration),
|
||||
[Export](#export-configuration),
|
||||
[Boot](#boot-configuration),
|
||||
[Shutdown](#shutdown-configuration),
|
||||
[Run](#run-configuration),
|
||||
[Communicator](#communicator-configuration)
|
||||
configuration references, which are
|
||||
necessary for this build to succeed and can be found further down the page.
|
||||
|
||||
### Required:
|
||||
|
||||
@include 'builder/virtualbox/ovf/Config-required.mdx'
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'builder/virtualbox/ovf/Config-not-required.mdx'
|
||||
|
||||
@include 'builder/virtualbox/common/VBoxVersionConfig-not-required.mdx'
|
||||
|
||||
@include 'builder/virtualbox/common/GuestAdditionsConfig-not-required.mdx'
|
||||
|
||||
### VBoxManage configuration
|
||||
|
||||
@include 'builder/virtualbox/common/VBoxManageConfig-not-required.mdx'
|
||||
|
||||
### Http directory configuration
|
||||
|
||||
@include 'packer-plugin-sdk/multistep/commonsteps/HTTPConfig.mdx'
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'packer-plugin-sdk/multistep/commonsteps/HTTPConfig-not-required.mdx'
|
||||
|
||||
### Floppy configuration
|
||||
|
||||
@include 'packer-plugin-sdk/multistep/commonsteps/FloppyConfig.mdx'
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'packer-plugin-sdk/multistep/commonsteps/FloppyConfig-not-required.mdx'
|
||||
|
||||
### CD configuration
|
||||
|
||||
@include 'packer-plugin-sdk/multistep/commonsteps/CDConfig.mdx'
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'packer-plugin-sdk/multistep/commonsteps/CDConfig-not-required.mdx'
|
||||
|
||||
### Export configuration
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'builder/virtualbox/common/ExportConfig-not-required.mdx'
|
||||
|
||||
### Output configuration
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'builder/virtualbox/common/OutputConfig-not-required.mdx'
|
||||
|
||||
### Run configuration
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'builder/virtualbox/common/RunConfig-not-required.mdx'
|
||||
|
||||
### Shutdown configuration
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'builder/virtualbox/common/ShutdownConfig-not-required.mdx'
|
||||
|
||||
### Communicator configuration
|
||||
|
||||
#### Optional common fields:
|
||||
|
||||
@include 'packer-plugin-sdk/communicator/Config-not-required.mdx'
|
||||
|
||||
@include 'builder/virtualbox/common/CommConfig-not-required.mdx'
|
||||
|
||||
#### Optional SSH fields:
|
||||
|
||||
@include 'packer-plugin-sdk/communicator/SSH-not-required.mdx'
|
||||
|
||||
@include 'packer-plugin-sdk/communicator/SSHTemporaryKeyPair-not-required.mdx'
|
||||
|
||||
@include 'packer-plugin-sdk/communicator/SSH-Key-Pair-Name-not-required.mdx'
|
||||
|
||||
@include 'packer-plugin-sdk/communicator/SSH-Private-Key-File-not-required.mdx'
|
||||
|
||||
@include 'packer-plugin-sdk/communicator/SSH-Agent-Auth-not-required.mdx'
|
||||
|
||||
#### Optional WinRM fields:
|
||||
|
||||
@include 'packer-plugin-sdk/communicator/WinRM-not-required.mdx'
|
||||
|
||||
### Boot Configuration
|
||||
|
||||
@include 'packer-plugin-sdk/bootcommand/BootConfig.mdx'
|
||||
|
||||
Please note that for the Virtuabox builder, the IP address of the HTTP server
|
||||
Packer launches for you to access files like the preseed file in the example
|
||||
above (`{{ .HTTPIP }}`) is hardcoded to 10.0.2.2. If you change the network
|
||||
of your VM you must guarantee that you can still access this HTTP server.
|
||||
|
||||
The boot command is sent to the VM through the `VBoxManage` utility in as few
|
||||
invocations as possible. We send each character in groups of 25, with a default
|
||||
delay of 100ms between groups. The delay alleviates issues with latency and CPU
|
||||
contention. If you notice missing keys, you can tune this delay by specifying
|
||||
"boot_keygroup_interval" in your Packer template, for example:
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
{
|
||||
"builders": [
|
||||
{
|
||||
"type": "virtualbox-ovf",
|
||||
"boot_keygroup_interval": "500ms"
|
||||
...
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
source "virtualbox-ovf" "basic-example" {
|
||||
boot_keygroup_interval = "500ms"
|
||||
# ...
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'packer-plugin-sdk/bootcommand/BootConfig-not-required.mdx'
|
||||
|
||||
@include 'builders/virtualbox-ssh-key-pair.mdx'
|
||||
|
||||
## Guest Additions
|
||||
|
||||
Packer will automatically download the proper guest additions for the version of
|
||||
VirtualBox that is running and upload those guest additions into the virtual
|
||||
machine so that provisioners can easily install them.
|
||||
|
||||
Packer downloads the guest additions from the official VirtualBox website, and
|
||||
verifies the file with the official checksums released by VirtualBox.
|
||||
|
||||
After the virtual machine is up and the operating system is installed, Packer
|
||||
uploads the guest additions into the virtual machine. The path where they are
|
||||
uploaded is controllable by `guest_additions_path`, and defaults to
|
||||
"VBoxGuestAdditions.iso". Without an absolute path, it is uploaded to the home
|
||||
directory of the SSH user.
|
||||
|
||||
## VBoxManage Commands
|
||||
|
||||
@include 'builder/virtualbox/common/VBoxManageConfig.mdx'
|
||||
|
||||
@include 'builder/virtualbox/common/VBoxManageConfig-not-required.mdx'
|
|
@ -1,264 +0,0 @@
|
|||
---
|
||||
modeline: |
|
||||
vim: set ft=pandoc:
|
||||
description: >
|
||||
The VirtualBox Packer builder is able to create VirtualBox virtual machines
|
||||
snapshots
|
||||
|
||||
and export them in the OVF format, starting from an ISO image.
|
||||
page_title: VirtualBox Snapshot - Builders
|
||||
---
|
||||
|
||||
# VirtualBox Builder (from an existing VM)
|
||||
|
||||
Type: `virtualbox-vm`
|
||||
Artifact BuilderId: `mitchellh.virtualbox`
|
||||
|
||||
The VirtualBox Packer builder is able to create
|
||||
[VirtualBox](https://www.virtualbox.org/) virtual machines snapshots and
|
||||
(optionally) export them in the OVF format, starting from an **existing**
|
||||
virtual machine.
|
||||
|
||||
The builder builds a virtual machine snapshot by using an existing virtual
|
||||
machine, booting it, provisioning software within the OS, then shutting it down.
|
||||
The result of the VirtualBox builder is a new snapshot persisting all changes
|
||||
from the applied provisioners.
|
||||
|
||||
## Basic Example
|
||||
|
||||
Here is a basic example. which serves to show the basic configuration:
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "virtualbox-vm",
|
||||
"communicator": "winrm",
|
||||
"headless": "{{user `headless`}}",
|
||||
"winrm_username": "vagrant",
|
||||
"winrm_password": "vagrant",
|
||||
"winrm_timeout": "2h",
|
||||
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
|
||||
"guest_additions_mode": "disable",
|
||||
"output_directory": "./builds-vm",
|
||||
"vm_name": "target-vm",
|
||||
"attach_snapshot": "Snapshot",
|
||||
"target_snapshot": "Target-Snapshot",
|
||||
"force_delete_snapshot": "true",
|
||||
"keep_registered": "false",
|
||||
"skip_export": "false"
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
source "virtualbox-vm" "basic-example" {
|
||||
communicator = "winrm"
|
||||
headless = "{{user `headless`}}"
|
||||
winrm_username = "vagrant"
|
||||
winrm_password = "vagrant"
|
||||
winrm_timeout = "2h"
|
||||
shutdown_command = "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\""
|
||||
guest_additions_mode = "disable"
|
||||
output_directory = "./builds-vm"
|
||||
vm_name = "target-vm"
|
||||
attach_snapshot = "Snapshot"
|
||||
target_snapshot = "Target-Snapshot"
|
||||
force_delete_snapshot = true
|
||||
keep_registered = false
|
||||
skip_export = false
|
||||
}
|
||||
|
||||
build {
|
||||
sources = ["sources.virtualbox-vm.basic-example"]
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
It is important to add a `shutdown_command`. By default Packer halts the virtual
|
||||
machine and the file system may not be sync'd. Thus, changes made in a
|
||||
provisioner might not be saved.
|
||||
|
||||
## Configuration Reference
|
||||
|
||||
There are many configuration options available for the builder. In addition to
|
||||
the items listed here, you will want to look at the general configuration
|
||||
references for [ISO](#iso-configuration),
|
||||
[HTTP](#http-directory-configuration),
|
||||
[Floppy](#floppy-configuration),
|
||||
[CD](#CD-configuration),
|
||||
[Export](#export-configuration),
|
||||
[Boot](#boot-configuration),
|
||||
[Shutdown](#shutdown-configuration),
|
||||
[Run](#run-configuration),
|
||||
[Communicator](#communicator-configuration)
|
||||
configuration references, which are
|
||||
necessary for this build to succeed and can be found further down the page.
|
||||
In addition to the options listed here, a
|
||||
[communicator](/docs/templates/legacy_json_templates/communicator) can be configured for this
|
||||
builder.
|
||||
|
||||
### Required:
|
||||
|
||||
@include 'builder/virtualbox/vm/Config-required.mdx'
|
||||
|
||||
### Optional:
|
||||
|
||||
@include 'builder/virtualbox/vm/Config-not-required.mdx'
|
||||
|
||||
@include 'builder/virtualbox/common/VBoxVersionConfig-not-required.mdx'
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'builder/virtualbox/common/ShutdownConfig-not-required.mdx'
|
||||
|
||||
### Http directory configuration
|
||||
|
||||
@include 'packer-plugin-sdk/multistep/commonsteps/HTTPConfig.mdx'
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'packer-plugin-sdk/multistep/commonsteps/HTTPConfig-not-required.mdx'
|
||||
|
||||
### Floppy configuration
|
||||
|
||||
@include 'packer-plugin-sdk/multistep/commonsteps/FloppyConfig.mdx'
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'packer-plugin-sdk/multistep/commonsteps/FloppyConfig-not-required.mdx'
|
||||
|
||||
### CD configuration
|
||||
|
||||
@include 'packer-plugin-sdk/multistep/commonsteps/CDConfig.mdx'
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'packer-plugin-sdk/multistep/commonsteps/CDConfig-not-required.mdx'
|
||||
|
||||
### Export configuration
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'builder/virtualbox/common/ExportConfig-not-required.mdx'
|
||||
|
||||
### Output configuration
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'builder/virtualbox/common/OutputConfig-not-required.mdx'
|
||||
|
||||
### Run configuration
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'builder/virtualbox/common/RunConfig-not-required.mdx'
|
||||
|
||||
### Shutdown configuration
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'builder/virtualbox/common/ShutdownConfig-not-required.mdx'
|
||||
|
||||
### Hardware configuration
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'builder/virtualbox/common/HWConfig-not-required.mdx'
|
||||
|
||||
### VBox Manage configuration
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'builder/virtualbox/common/VBoxManageConfig-not-required.mdx'
|
||||
|
||||
### Communicator configuration
|
||||
|
||||
#### Optional common fields:
|
||||
|
||||
@include 'packer-plugin-sdk/communicator/Config-not-required.mdx'
|
||||
|
||||
@include 'builder/virtualbox/common/CommConfig-not-required.mdx'
|
||||
|
||||
#### Optional SSH fields:
|
||||
|
||||
@include 'packer-plugin-sdk/communicator/SSH-not-required.mdx'
|
||||
|
||||
#### Optional WinRM fields:
|
||||
|
||||
@include 'packer-plugin-sdk/communicator/WinRM-not-required.mdx'
|
||||
|
||||
### Boot Configuration
|
||||
|
||||
@include 'packer-plugin-sdk/bootcommand/BootConfig.mdx'
|
||||
|
||||
Please note that for the Virtuabox builder, the IP address of the HTTP server
|
||||
Packer launches for you to access files like the preseed file in the example
|
||||
above (`{{ .HTTPIP }}`) is hardcoded to 10.0.2.2. If you change the network
|
||||
of your VM you must guarantee that you can still access this HTTP server.
|
||||
|
||||
The boot command is sent to the VM through the `VBoxManage` utility in as few
|
||||
invocations as possible. We send each character in groups of 25, with a default
|
||||
delay of 100ms between groups. The delay alleviates issues with latency and CPU
|
||||
contention. If you notice missing keys, you can tune this delay by specifying
|
||||
"boot_keygroup_interval" in your Packer template, for example:
|
||||
|
||||
<Tabs>
|
||||
<Tab heading="JSON">
|
||||
|
||||
```json
|
||||
{
|
||||
"builders": [
|
||||
{
|
||||
"type": "virtualbox-vm",
|
||||
"boot_keygroup_interval": "500ms"
|
||||
...
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab heading="HCL2">
|
||||
|
||||
```hcl
|
||||
source "virtualbox-vm" "basic-example" {
|
||||
boot_keygroup_interval = "500ms"
|
||||
# ...
|
||||
}
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
#### Optional:
|
||||
|
||||
@include 'packer-plugin-sdk/bootcommand/BootConfig-not-required.mdx'
|
||||
|
||||
@include 'builders/virtualbox-ssh-key-pair.mdx'
|
||||
|
||||
## Guest Additions
|
||||
|
||||
Packer will automatically download the proper guest additions for the version of
|
||||
VirtualBox that is running and upload those guest additions into the virtual
|
||||
machine so that provisioners can easily install them.
|
||||
|
||||
Packer downloads the guest additions from the official VirtualBox website, and
|
||||
verifies the file with the official checksums released by VirtualBox.
|
||||
|
||||
After the virtual machine is up and the operating system is installed, Packer
|
||||
uploads the guest additions into the virtual machine. The path where they are
|
||||
uploaded is controllable by `guest_additions_path`, and defaults to
|
||||
"VBoxGuestAdditions.iso". Without an absolute path, it is uploaded to the home
|
||||
directory of the SSH user.
|
||||
|
||||
## VBoxManage Commands
|
||||
|
||||
@include 'builder/virtualbox/common/VBoxManageConfig.mdx'
|
||||
|
||||
@include 'builder/virtualbox/common/VBoxManageConfig-not-required.mdx'
|
|
@ -1,15 +0,0 @@
|
|||
<!-- Code generated from the comments of the CommConfig struct in builder/virtualbox/common/comm_config.go; DO NOT EDIT MANUALLY -->
|
||||
|
||||
- `host_port_min` (int) - The minimum port to use for the Communicator port on the host machine which is forwarded
|
||||
to the SSH or WinRM port on the guest machine. By default this is 2222.
|
||||
|
||||
- `host_port_max` (int) - The maximum port to use for the Communicator port on the host machine which is forwarded
|
||||
to the SSH or WinRM port on the guest machine. Because Packer often runs in parallel,
|
||||
Packer will choose a randomly available port in this range to use as the
|
||||
host port. By default this is 4444.
|
||||
|
||||
- `skip_nat_mapping` (bool) - Defaults to false. When enabled, Packer
|
||||
does not setup forwarded port mapping for communicator (SSH or WinRM) requests and uses ssh_port or winrm_port
|
||||
on the host to communicate to the virtual machine.
|
||||
|
||||
<!-- End of code generated from the comments of the CommConfig struct in builder/virtualbox/common/comm_config.go; -->
|
|
@ -1,60 +0,0 @@
|
|||
<!-- Code generated from the comments of the ExportConfig struct in builder/virtualbox/common/export_config.go; DO NOT EDIT MANUALLY -->
|
||||
|
||||
- `format` (string) - Either ovf or ova, this specifies the output format
|
||||
of the exported virtual machine. This defaults to ovf.
|
||||
|
||||
- `export_opts` ([]string) - Additional options to pass to the [VBoxManage
|
||||
export](https://www.virtualbox.org/manual/ch09.html#vboxmanage-export).
|
||||
This can be useful for passing product information to include in the
|
||||
resulting appliance file. Packer JSON configuration file example:
|
||||
|
||||
In JSON:
|
||||
```json
|
||||
{
|
||||
"type": "virtualbox-iso",
|
||||
"export_opts":
|
||||
[
|
||||
"--manifest",
|
||||
"--vsys", "0",
|
||||
"--description", "{{user `vm_description`}}",
|
||||
"--version", "{{user `vm_version`}}"
|
||||
],
|
||||
"format": "ova",
|
||||
}
|
||||
```
|
||||
|
||||
In HCL2:
|
||||
```hcl
|
||||
source "virtualbox-iso" "basic-example" {
|
||||
export_opts = [
|
||||
"--manifest",
|
||||
"--vsys", "0",
|
||||
"--description", "{{user `vm_description`}}",
|
||||
"--version", "{{user `vm_version`}}"
|
||||
]
|
||||
format = "ova"
|
||||
}
|
||||
```
|
||||
|
||||
A VirtualBox [VM
|
||||
description](https://www.virtualbox.org/manual/ch09.html#vboxmanage-export-ovf)
|
||||
may contain arbitrary strings; the GUI interprets HTML formatting. However,
|
||||
the JSON format does not allow arbitrary newlines within a value. Add a
|
||||
multi-line description by preparing the string in the shell before the
|
||||
packer call like this (shell `>` continuation character snipped for easier
|
||||
copy & paste):
|
||||
|
||||
```shell
|
||||
vm_description='some
|
||||
multiline
|
||||
description'
|
||||
|
||||
vm_version='0.2.0'
|
||||
|
||||
packer build \
|
||||
-var "vm_description=${vm_description}" \
|
||||
-var "vm_version=${vm_version}" \
|
||||
"packer_conf.json"
|
||||
```
|
||||
|
||||
<!-- End of code generated from the comments of the ExportConfig struct in builder/virtualbox/common/export_config.go; -->
|
|
@ -1,34 +0,0 @@
|
|||
<!-- Code generated from the comments of the GuestAdditionsConfig struct in builder/virtualbox/common/guest_additions_config.go; DO NOT EDIT MANUALLY -->
|
||||
|
||||
- `guest_additions_mode` (string) - The method by which guest additions are
|
||||
made available to the guest for installation. Valid options are `upload`,
|
||||
`attach`, or `disable`. If the mode is `attach` the guest additions ISO will
|
||||
be attached as a CD device to the virtual machine. If the mode is `upload`
|
||||
the guest additions ISO will be uploaded to the path specified by
|
||||
`guest_additions_path`. The default value is `upload`. If `disable` is used,
|
||||
guest additions won't be downloaded, either.
|
||||
|
||||
- `guest_additions_interface` (string) - The interface type to use to mount guest additions when
|
||||
guest_additions_mode is set to attach. Will default to the value set in
|
||||
iso_interface, if iso_interface is set. Will default to "ide", if
|
||||
iso_interface is not set. Options are "ide" and "sata".
|
||||
|
||||
- `guest_additions_path` (string) - The path on the guest virtual machine
|
||||
where the VirtualBox guest additions ISO will be uploaded. By default this
|
||||
is `VBoxGuestAdditions.iso` which should upload into the login directory of
|
||||
the user. This is a [configuration
|
||||
template](/docs/templates/legacy_json_templates/engine) where the `Version`
|
||||
variable is replaced with the VirtualBox version.
|
||||
|
||||
- `guest_additions_sha256` (string) - The SHA256 checksum of the guest
|
||||
additions ISO that will be uploaded to the guest VM. By default the
|
||||
checksums will be downloaded from the VirtualBox website, so this only needs
|
||||
to be set if you want to be explicit about the checksum.
|
||||
|
||||
- `guest_additions_url` (string) - The URL of the guest additions ISO
|
||||
to upload. This can also be a file URL if the ISO is at a local path. By
|
||||
default, the VirtualBox builder will attempt to find the guest additions ISO
|
||||
on the local file system. If it is not available locally, the builder will
|
||||
download the proper guest additions ISO from the internet.
|
||||
|
||||
<!-- End of code generated from the comments of the GuestAdditionsConfig struct in builder/virtualbox/common/guest_additions_config.go; -->
|
|
@ -1,16 +0,0 @@
|
|||
<!-- Code generated from the comments of the HWConfig struct in builder/virtualbox/common/hw_config.go; DO NOT EDIT MANUALLY -->
|
||||
|
||||
- `cpus` (int) - The number of cpus to use for building the VM.
|
||||
Defaults to 1.
|
||||
|
||||
- `memory` (int) - The amount of memory to use for building the VM
|
||||
in megabytes. Defaults to 512 megabytes.
|
||||
|
||||
- `sound` (string) - Defaults to none. The type of audio device to use for
|
||||
sound when building the VM. Some of the options that are available are
|
||||
dsound, oss, alsa, pulse, coreaudio, null.
|
||||
|
||||
- `usb` (bool) - Specifies whether or not to enable the USB bus when
|
||||
building the VM. Defaults to false.
|
||||
|
||||
<!-- End of code generated from the comments of the HWConfig struct in builder/virtualbox/common/hw_config.go; -->
|
|
@ -1,14 +0,0 @@
|
|||
<!-- Code generated from the comments of the OutputConfig struct in builder/virtualbox/common/output_config.go; DO NOT EDIT MANUALLY -->
|
||||
|
||||
- `output_directory` (string) - This is the path to the directory where the
|
||||
resulting virtual machine will be created. This may be relative or absolute.
|
||||
If relative, the path is relative to the working directory when packer
|
||||
is executed. This directory must not exist or be empty prior to running
|
||||
the builder. By default this is output-BUILDNAME where "BUILDNAME" is the
|
||||
name of the build.
|
||||
|
||||
- `output_filename` (string) - This is the base name of the file (excluding the file extension) where
|
||||
the resulting virtual machine will be created. By default this is the
|
||||
`vm_name`.
|
||||
|
||||
<!-- End of code generated from the comments of the OutputConfig struct in builder/virtualbox/common/output_config.go; -->
|
|
@ -1,19 +0,0 @@
|
|||
<!-- Code generated from the comments of the RunConfig struct in builder/virtualbox/common/run_config.go; DO NOT EDIT MANUALLY -->
|
||||
|
||||
- `headless` (bool) - Packer defaults to building VirtualBox virtual
|
||||
machines by launching a GUI that shows the console of the machine
|
||||
being built. When this value is set to true, the machine will start
|
||||
without a console.
|
||||
|
||||
- `vrdp_bind_address` (string) - The IP address that should be
|
||||
binded to for VRDP. By default packer will use 127.0.0.1 for this. If you
|
||||
wish to bind to all interfaces use 0.0.0.0.
|
||||
|
||||
- `vrdp_port_min` (int) - The minimum and maximum port
|
||||
to use for VRDP access to the virtual machine. Packer uses a randomly chosen
|
||||
port in this range that appears available. By default this is 5900 to
|
||||
6000. The minimum and maximum ports are inclusive.
|
||||
|
||||
- `vrdp_port_max` (int) - VRDP Port Max
|
||||
|
||||
<!-- End of code generated from the comments of the RunConfig struct in builder/virtualbox/common/run_config.go; -->
|
|
@ -1,31 +0,0 @@
|
|||
<!-- Code generated from the comments of the ShutdownConfig struct in builder/virtualbox/common/shutdown_config.go; DO NOT EDIT MANUALLY -->
|
||||
|
||||
- `shutdown_command` (string) - The command to use to gracefully shut down the
|
||||
machine once all the provisioning is done. By default this is an empty
|
||||
string, which tells Packer to just forcefully shut down the machine unless a
|
||||
shutdown command takes place inside script so this may safely be omitted. If
|
||||
one or more scripts require a reboot it is suggested to leave this blank
|
||||
since reboots may fail and specify the final shutdown command in your
|
||||
last script.
|
||||
|
||||
- `shutdown_timeout` (duration string | ex: "1h5m2s") - The amount of time to wait after executing the
|
||||
shutdown_command for the virtual machine to actually shut down. If it
|
||||
doesn't shut down in this time, it is an error. By default, the timeout is
|
||||
5m or five minutes.
|
||||
|
||||
- `post_shutdown_delay` (duration string | ex: "1h5m2s") - The amount of time to wait after shutting
|
||||
down the virtual machine. If you get the error
|
||||
Error removing floppy controller, you might need to set this to 5m
|
||||
or so. By default, the delay is 0s or disabled.
|
||||
|
||||
- `disable_shutdown` (bool) - Packer normally halts the virtual machine after all provisioners have
|
||||
run when no `shutdown_command` is defined. If this is set to `true`, Packer
|
||||
*will not* halt the virtual machine but will assume that you will send the stop
|
||||
signal yourself through the preseed.cfg or your final provisioner.
|
||||
Packer will wait for a default of 5 minutes until the virtual machine is shutdown.
|
||||
The timeout can be changed using `shutdown_timeout` option.
|
||||
|
||||
- `acpi_shutdown` (bool) - If it's set to true, it will shutdown the VM via power button. It could be a good option
|
||||
when keeping the machine state is necessary after shutting it down.
|
||||
|
||||
<!-- End of code generated from the comments of the ShutdownConfig struct in builder/virtualbox/common/shutdown_config.go; -->
|
|
@ -1,8 +0,0 @@
|
|||
<!-- Code generated from the comments of the VBoxBundleConfig struct in builder/virtualbox/common/vboxbundle_config.go; DO NOT EDIT MANUALLY -->
|
||||
|
||||
- `bundle_iso` (bool) - Defaults to false. When enabled, Packer includes
|
||||
any attached ISO disc devices into the final virtual machine. Useful for
|
||||
some live distributions that require installation media to continue to be
|
||||
attached after installation.
|
||||
|
||||
<!-- End of code generated from the comments of the VBoxBundleConfig struct in builder/virtualbox/common/vboxbundle_config.go; -->
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue