Skip to content

Commit 110ef94

Browse files
authored
fix: Update error messages when working with OpenTofu (#4996)
1 parent c13a42d commit 110ef94

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

server/core/terraform/terraform_client.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func NewClientWithDefaultVersion(
125125
return nil, fmt.Errorf("%s not found in $PATH. Set --%s or download terraform from https://developer.hashicorp.com/terraform/downloads", distribution.BinName(), defaultVersionFlagName)
126126
}
127127
if err == nil {
128-
localVersion, err = getVersion(localPath)
128+
localVersion, err = getVersion(localPath, distribution.BinName())
129129
if err != nil {
130130
return nil, err
131131
}
@@ -529,7 +529,7 @@ func ensureVersion(
529529
execPath, err := dist.Downloader().Install(context.Background(), binDir, downloadURL, v)
530530

531531
if err != nil {
532-
return "", errors.Wrapf(err, "error downloading terraform version %s", v.String())
532+
return "", errors.Wrapf(err, "error downloading %s version %s", dist.BinName(), v.String())
533533
}
534534

535535
log.Info("Downloaded %s %s to %s", dist.BinName(), v.String(), execPath)
@@ -576,15 +576,15 @@ func isAsyncEligibleCommand(cmd string) bool {
576576
return false
577577
}
578578

579-
func getVersion(tfBinary string) (*version.Version, error) {
579+
func getVersion(tfBinary string, binName string) (*version.Version, error) {
580580
versionOutBytes, err := exec.Command(tfBinary, "version").Output() // #nosec
581581
versionOutput := string(versionOutBytes)
582582
if err != nil {
583-
return nil, errors.Wrapf(err, "running terraform version: %s", versionOutput)
583+
return nil, errors.Wrapf(err, "running %s version: %s", binName, versionOutput)
584584
}
585585
match := versionRegex.FindStringSubmatch(versionOutput)
586586
if len(match) <= 1 {
587-
return nil, fmt.Errorf("could not parse terraform version from %s", versionOutput)
587+
return nil, fmt.Errorf("could not parse %s version from %s", binName, versionOutput)
588588
}
589589
return version.NewVersion(match[1])
590590
}

0 commit comments

Comments
 (0)