Skip to content

Commit

Permalink
Allow to configure --concurrency for pulling
Browse files Browse the repository at this point in the history
  • Loading branch information
fkorotkov committed Feb 6, 2024
1 parent fcb9346 commit 8599425
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
11 changes: 6 additions & 5 deletions builder/tart/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ type Config struct {
commonsteps.HTTPConfig `mapstructure:",squash"`
CommunicatorConfig communicator.Config `mapstructure:",squash"`

FromIPSW string `mapstructure:"from_ipsw"`
FromISO []string `mapstructure:"from_iso"`
VMBaseName string `mapstructure:"vm_base_name"`
VMName string `mapstructure:"vm_name"`
AllowInsecure bool `mapstructure:"allow_insecure"`
FromIPSW string `mapstructure:"from_ipsw"`
FromISO []string `mapstructure:"from_iso"`
VMBaseName string `mapstructure:"vm_base_name"`
VMName string `mapstructure:"vm_name"`
AllowInsecure bool `mapstructure:"allow_insecure"`
PullConcurrency uint16 `mapstructure:"pull_concurrency"`

CpuCount uint8 `mapstructure:"cpu_count"`
CreateGraceTime time.Duration `mapstructure:"create_grace_time"`
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.

4 changes: 4 additions & 0 deletions builder/tart/step_clone_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ func (s *stepCloneVM) Run(ctx context.Context, state multistep.StateBag) multist
cmdArgs = append(cmdArgs, "--insecure")
}

if config.PullConcurrency > 0 {
cmdArgs = append(cmdArgs, "--concurrency", fmt.Sprintf("%d", config.PullConcurrency))
}

if _, err := TartExec(ctx, cmdArgs...); err != nil {
err := fmt.Errorf("Error cloning VM: %s", err)
state.Put("error", err)
Expand Down
1 change: 1 addition & 0 deletions docs/builders/tart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Below we'll go through available options of this Packer plugin.
### Optional Configuration

- `allow_insecure` (boolean) When cloning the image, connect to the OCI registry via an insecure HTTP protocol.
- `pull_concurrency` (boolean) Amount of layers to pull concurrently from an OCI registry when pulling the image. Default is 4 for Tart 2.0.0+.
- `cpu_count` (number) - Amount of virtual CPUs to use for the new VM. Overrides `tart create` default value when using `from_ipsw` and `from_iso` and VM settings when using `vm_base_name`.
- `create_grace_time` (duration string | ex: "1h5m2s") Time to wait after finishing the installation process. Can be used to work around the issue when Virtualization.Framework's installation process is still running in the background for some time after `tart create` had already finished.
- `disk_size_gb` Disk size in GB to use for the new VM. Overrides `tart create` default value when using `from_ipsw` and `from_iso` and VM settings when using `vm_base_name`.
Expand Down

0 comments on commit 8599425

Please sign in to comment.