Files
atlantis/server/core/runtime/version_step_runner.go
Gabriel Martinez 56e38b4151 chore(atlantis): fix linter errors (#3690)
* chore(atlantis): fix linter errors

* fix superfluous-else

* revert gitlab check

* ignore stub funcs on azuredevops_client

* remove fetch-depth

* remove fail_on_error

* fix plan_step_runner_test.go

* more lint fixes

---------

Co-authored-by: Dylan Page <dylan.page@autodesk.com>
2023-12-11 19:02:16 +00:00

26 lines
828 B
Go

package runtime
import (
"path/filepath"
"github.com/hashicorp/go-version"
"github.com/runatlantis/atlantis/server/events/command"
)
// VersionStepRunner runs a version command given a ctx
type VersionStepRunner struct {
TerraformExecutor TerraformExec
DefaultTFVersion *version.Version
}
// Run ensures a given version for the executable, builds the args from the project context and then runs executable returning the result
func (v *VersionStepRunner) Run(ctx command.ProjectContext, _ []string, path string, envs map[string]string) (string, error) {
tfVersion := v.DefaultTFVersion
if ctx.TerraformVersion != nil {
tfVersion = ctx.TerraformVersion
}
versionCmd := []string{"version"}
return v.TerraformExecutor.RunCommandWithVersion(ctx, filepath.Clean(path), versionCmd, envs, tfVersion, ctx.Workspace)
}