Skip to content

Commit

Permalink
Allow to specify extra arguments for tart run (#60)
Browse files Browse the repository at this point in the history
Fixes #59
Fixes #15
  • Loading branch information
fkorotkov authored Apr 20, 2023
1 parent 0c52831 commit eb96164
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 83 deletions.
1 change: 1 addition & 0 deletions builder/tart/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type Config struct {
Display string `mapstructure:"display" required:"false"`
DiskSizeGb uint16 `mapstructure:"disk_size_gb" required:"false"`
Headless bool `mapstructure:"headless" required:"false"`
RunExtraArgs []string `mapstructure:"run_extra_args" required:"false"`
CreateGraceTime time.Duration `mapstructure:"create_grace_time" required:"false"`
Comm communicator.Config `mapstructure:",squash"`

Expand Down
2 changes: 2 additions & 0 deletions builder/tart/builder.hcl2spec.go

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

3 changes: 3 additions & 0 deletions builder/tart/step_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ func (s *stepRun) Run(ctx context.Context, state multistep.StateBag) multistep.S
if config.Rosetta != "" {
runArgs = append(runArgs, fmt.Sprintf("--rosetta=%s", config.Rosetta))
}
if len(config.RunExtraArgs) > 0 {
runArgs = append(runArgs, config.RunExtraArgs...)
}
cmd := exec.Command("tart", runArgs...)
stdout := bytes.NewBufferString("")
cmd.Stdout = stdout
Expand Down
1 change: 1 addition & 0 deletions docs/builders/tart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ Below we'll go through available options of this Packer plugin
- `headless` (boolean) - Whether to show graphics interface of a VM. Useful for debugging `boot_command`.
- `rosetta` (string) - Whether to enable Rosetta support of a Linux guest VM. Useful for running non arm64 programs in the guest VM. A common used value is `rosetta`. For further details and explanation run `tart run --help`
- `boot_command` (array of strings) - This is an array of commands to type when the virtual machine is first booted. The goal of these commands should be to type just enough to initialize the operating system installer.
- `run_extra_args` (array of strings) - Extra arguments to pass to `tart run` command. For example, pass a bridged network via `--net-bridged=en0`.

### Example Usage

Expand Down
59 changes: 30 additions & 29 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ go 1.19
require (
github.com/apparentlymart/go-cidr v1.1.0
github.com/diskfs/go-diskfs v1.3.0
github.com/hashicorp/hcl/v2 v2.14.1
github.com/hashicorp/packer-plugin-sdk v0.3.4
github.com/hashicorp/hcl/v2 v2.13.0
github.com/hashicorp/packer-plugin-sdk v0.4.0
github.com/mitchellh/go-vnc v0.0.0-20150629162542-723ed9867aed
github.com/stretchr/testify v1.8.2
github.com/zclconf/go-cty v1.10.0
Expand All @@ -15,36 +15,37 @@ require (

require (
cloud.google.com/go v0.110.0 // indirect
cloud.google.com/go/compute v1.18.0 // indirect
cloud.google.com/go/compute v1.19.1 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
cloud.google.com/go/iam v0.12.0 // indirect
cloud.google.com/go/storage v1.29.0 // indirect
cloud.google.com/go/iam v1.0.0 // indirect
cloud.google.com/go/storage v1.30.1 // indirect
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358 // indirect
github.com/ChrisTrenkamp/goxpath v0.0.0-20210404020558-97928f7e12b6 // indirect
github.com/agext/levenshtein v1.2.3 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/armon/go-metrics v0.4.1 // indirect
github.com/aws/aws-sdk-go v1.44.209 // indirect
github.com/aws/aws-sdk-go v1.44.246 // indirect
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dylanmei/iso8601 v0.1.0 // indirect
github.com/fatih/color v1.14.1 // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gofrs/uuid v4.4.0+incompatible // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/s2a-go v0.1.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.3 // indirect
github.com/googleapis/gax-go/v2 v2.7.0 // indirect
github.com/hashicorp/consul/api v1.19.1 // indirect
github.com/googleapis/gax-go/v2 v2.8.0 // indirect
github.com/hashicorp/consul/api v1.20.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-getter/gcs/v2 v2.2.0 // indirect
github.com/hashicorp/go-getter/s3/v2 v2.2.0 // indirect
github.com/hashicorp/go-getter/v2 v2.2.0 // indirect
github.com/hashicorp/go-hclog v1.4.0 // indirect
github.com/hashicorp/go-getter/gcs/v2 v2.2.1 // indirect
github.com/hashicorp/go-getter/s3/v2 v2.2.1 // indirect
github.com/hashicorp/go-getter/v2 v2.2.1 // indirect
github.com/hashicorp/go-hclog v1.5.0 // indirect
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-retryablehttp v0.7.2 // indirect
Expand All @@ -58,7 +59,7 @@ require (
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/serf v0.10.1 // indirect
github.com/hashicorp/vault/api v1.9.0 // indirect
github.com/hashicorp/vault/api v1.9.1 // indirect
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
Expand All @@ -68,12 +69,12 @@ require (
github.com/jcmturner/rpc/v2 v2.0.3 // indirect
github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/klauspost/compress v1.15.15 // indirect
github.com/klauspost/compress v1.16.5 // indirect
github.com/kr/fs v0.1.0 // indirect
github.com/masterzen/simplexml v0.0.0-20190410153822-31eea3082786 // indirect
github.com/masterzen/winrm v0.0.0-20220917170901-b07f6cb0598d // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/mitchellh/go-fs v0.0.0-20180402235330-b7b9ca407fff // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
Expand All @@ -89,23 +90,23 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/ryanuber/go-glob v1.0.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/ugorji/go/codec v1.2.10 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
github.com/ulikunitz/xz v0.5.11 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/crypto v0.6.0 // indirect
golang.org/x/mobile v0.0.0-20221110043201-43a038452099 // indirect
golang.org/x/net v0.7.0 // indirect
golang.org/x/oauth2 v0.5.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/term v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
golang.org/x/crypto v0.8.0 // indirect
golang.org/x/mobile v0.0.0-20230301163155-e0f57694e12c // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/oauth2 v0.7.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/term v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
google.golang.org/api v0.110.0 // indirect
google.golang.org/api v0.119.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230223222841-637eb2293923 // indirect
google.golang.org/grpc v1.53.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
google.golang.org/grpc v1.54.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/djherbis/times.v1 v1.3.0 // indirect
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
gopkg.in/yaml.v2 v2.3.0 // indirect
Expand Down
Loading

0 comments on commit eb96164

Please sign in to comment.