Skip to content

Commit

Permalink
Add headless option (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
fkorotkov committed May 25, 2022
1 parent 04871cc commit a1d9ba8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions builder/tart/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ type Config struct {
MemoryGb uint16 `mapstructure:"memory_gb" required:"false"`
Display string `mapstructure:"display" required:"false"`
DiskSizeGb uint16 `mapstructure:"disk_size_gb" required:"false"`
Headless bool `mapstructure:"headless" required:"false"`
Comm communicator.Config `mapstructure:",squash"`

ctx interpolate.Context
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.

6 changes: 5 additions & 1 deletion builder/tart/step_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ func (s *stepRun) Run(ctx context.Context, state multistep.StateBag) multistep.S
ui := state.Get("ui").(packersdk.Ui)

ui.Say("Starting the virtual machine...")
cmd := exec.Command("tart", "run", "--no-graphics", config.VMName)
runArgs := []string{"run", config.VMName}
if config.Headless {
runArgs = append(runArgs, "--no-graphics")
}
cmd := exec.Command("tart", runArgs...)
writer := uiWriter{ui: ui}
cmd.Stdout = writer
cmd.Stderr = writer
Expand Down
1 change: 1 addition & 0 deletions docs/builders/tart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Here is a basic example:
"vm_base_name": "latest",
"ssh_username": "admin",
"ssh_password": "admin",
"headless": "true",
}
```

Expand Down

0 comments on commit a1d9ba8

Please sign in to comment.