Skip to content

Commit

Permalink
Propagate additional clone and pull environment to "tart clone" too (#…
Browse files Browse the repository at this point in the history
…102)

* Propagate additional clone and pull environment to "tart clone" too

* Fix linter warnings
  • Loading branch information
edigaryev authored Jan 29, 2025
1 parent 9211227 commit e03add8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
5 changes: 0 additions & 5 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ linters:
- dupl
- errcheck
- exhaustive
- exportloopref
- exportloopref
- gochecknoinits
- gocognit
- goconst
Expand Down Expand Up @@ -97,9 +95,6 @@ linters:
# [1]: https://github.com/mgechev/revive/issues/244#issuecomment-560512162
- revive

# Unfortunately too much false-positives, e.g. for a 0700 umask or number 10 when using strconv.FormatInt()
- gomnd

# Needs package whitelists
- depguard

Expand Down
6 changes: 4 additions & 2 deletions internal/commands/prepare/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ func runPrepareVM(cmd *cobra.Command, args []string) error {
return err
}

additionalCloneAndPullEnv := additionalPullEnv(gitLabEnv.Registry)

if config.AlwaysPull {
log.Printf("Pulling the latest version of %s...\n", gitLabEnv.JobImage)

Expand All @@ -115,15 +117,15 @@ func runPrepareVM(cmd *cobra.Command, args []string) error {
strconv.FormatUint(uint64(config.PullConcurrency), 10))
}

_, _, err := tart.TartExecWithEnv(cmd.Context(), additionalPullEnv(gitLabEnv.Registry), pullArgs...)
_, _, err := tart.TartExecWithEnv(cmd.Context(), additionalCloneAndPullEnv, pullArgs...)
if err != nil {
return err
}
}

log.Println("Cloning and configuring a new VM...")
vm, err := tart.CreateNewVM(cmd.Context(), gitLabEnv.VirtualMachineID(), gitLabEnv.JobImage,
config, cpuOverride, memoryOverride)
config, cpuOverride, memoryOverride, additionalCloneAndPullEnv)
if err != nil {
return err
}
Expand Down
7 changes: 5 additions & 2 deletions internal/tart/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ func CreateNewVM(
config Config,
cpuOverride uint64,
memoryOverride uint64,
additionalCloneAndPullEnv map[string]string,
) (*VM, error) {
vm := &VM{
id: name,
}

if err := vm.cloneAndConfigure(ctx, image, config, cpuOverride, memoryOverride); err != nil {
if err := vm.cloneAndConfigure(ctx, image, config, cpuOverride, memoryOverride,
additionalCloneAndPullEnv); err != nil {
return nil, fmt.Errorf("failed to clone the VM: %w", err)
}

Expand All @@ -71,6 +73,7 @@ func (vm *VM) cloneAndConfigure(
config Config,
cpuOverride uint64,
memoryOverride uint64,
additionalCloneAndPullEnv map[string]string,
) error {
cloneArgs := []string{"clone", image, vm.id}

Expand All @@ -83,7 +86,7 @@ func (vm *VM) cloneAndConfigure(
strconv.FormatUint(uint64(config.PullConcurrency), 10))
}

_, _, err := TartExec(ctx, cloneArgs...)
_, _, err := TartExecWithEnv(ctx, additionalCloneAndPullEnv, cloneArgs...)
if err != nil {
return err
}
Expand Down

0 comments on commit e03add8

Please sign in to comment.