Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .web-docs/components/builder/vagrant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ the Compress post-processor will not work with this builder.

- `box_version` (string) - What box version to use when initializing Vagrant.

- `box_architecture` (string) - Architecture of the box to use when initializing Vagrant.

- `template` (string) - a path to a golang template for a vagrantfile. Our default template can
be found [here](https://github.com/hashicorp/packer-plugin-vagrant/blob/main/builder/vagrant/step_create_vagrantfile.go#L39-L54). The template variables available to you are
`{{ .BoxName }}`, `{{ .SyncedFolder }}`, and `{{.InsertKey}}`, which
Expand Down
27 changes: 15 additions & 12 deletions builder/vagrant/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ type Config struct {
TeardownMethod string `mapstructure:"teardown_method" required:"false"`
// What box version to use when initializing Vagrant.
BoxVersion string `mapstructure:"box_version" required:"false"`
// Architecture of the box to use when initializing Vagrant.
BoxArchitecture string `mapstructure:"box_architecture" required:"false"`
// a path to a golang template for a vagrantfile. Our default template can
// be found [here](https://github.com/hashicorp/packer-plugin-vagrant/blob/main/builder/vagrant/step_create_vagrantfile.go#L39-L54). The template variables available to you are
// `{{ .BoxName }}`, `{{ .SyncedFolder }}`, and `{{.InsertKey}}`, which
Expand Down Expand Up @@ -324,18 +326,19 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook)
InsertKey: b.config.InsertKey,
},
&StepAddBox{
BoxVersion: b.config.BoxVersion,
CACert: b.config.AddCACert,
CAPath: b.config.AddCAPath,
DownloadCert: b.config.AddCert,
Clean: b.config.AddClean,
Force: b.config.AddForce,
Insecure: b.config.AddInsecure,
Provider: b.config.Provider,
SourceBox: b.config.SourceBox,
BoxName: b.config.BoxName,
GlobalID: b.config.GlobalID,
SkipAdd: b.config.SkipAdd,
BoxArchitecture: b.config.BoxArchitecture,
BoxVersion: b.config.BoxVersion,
CACert: b.config.AddCACert,
CAPath: b.config.AddCAPath,
DownloadCert: b.config.AddCert,
Clean: b.config.AddClean,
Force: b.config.AddForce,
Insecure: b.config.AddInsecure,
Provider: b.config.Provider,
SourceBox: b.config.SourceBox,
BoxName: b.config.BoxName,
GlobalID: b.config.GlobalID,
SkipAdd: b.config.SkipAdd,
},
&StepUp{
TeardownMethod: b.config.TeardownMethod,
Expand Down
2 changes: 2 additions & 0 deletions builder/vagrant/builder.hcl2spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 17 additions & 12 deletions builder/vagrant/step_add_box.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@ import (
)

type StepAddBox struct {
BoxVersion string
CACert string
CAPath string
DownloadCert string
Clean bool
Force bool
Insecure bool
Provider string
SourceBox string
BoxName string
GlobalID string
SkipAdd bool
BoxArchitecture string
BoxVersion string
CACert string
CAPath string
DownloadCert string
Clean bool
Force bool
Insecure bool
Provider string
SourceBox string
BoxName string
GlobalID string
SkipAdd bool
}

func (s *StepAddBox) generateAddArgs() []string {
Expand All @@ -37,6 +38,10 @@ func (s *StepAddBox) generateAddArgs() []string {

addArgs = append(addArgs, s.SourceBox)

if s.BoxArchitecture != "" {
addArgs = append(addArgs, "--architecture", s.BoxArchitecture)
}

if s.BoxVersion != "" {
addArgs = append(addArgs, "--box-version", s.BoxVersion)
}
Expand Down
8 changes: 8 additions & 0 deletions builder/vagrant/step_add_box_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ func TestPrepAddArgs(t *testing.T) {
},
Expected: []string{"my_source_box"},
},
{
Step: StepAddBox{
SourceBox: "my_source_box",
Provider: "virtualbox",
BoxArchitecture: "amd64",
},
Expected: []string{"my_source_box", "--architecture", "amd64", "--provider", "virtualbox"},
},
{
Step: StepAddBox{
BoxVersion: "eleventyone",
Expand Down
2 changes: 2 additions & 0 deletions docs-partials/builder/vagrant/Config-not-required.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@

- `box_version` (string) - What box version to use when initializing Vagrant.

- `box_architecture` (string) - Architecture of the box to use when initializing Vagrant.

- `template` (string) - a path to a golang template for a vagrantfile. Our default template can
be found [here](https://github.com/hashicorp/packer-plugin-vagrant/blob/main/builder/vagrant/step_create_vagrantfile.go#L39-L54). The template variables available to you are
`{{ .BoxName }}`, `{{ .SyncedFolder }}`, and `{{.InsertKey}}`, which
Expand Down