@@ -125,7 +125,7 @@ func NewClientWithDefaultVersion(
125
125
return nil , fmt .Errorf ("%s not found in $PATH. Set --%s or download terraform from https://developer.hashicorp.com/terraform/downloads" , distribution .BinName (), defaultVersionFlagName )
126
126
}
127
127
if err == nil {
128
- localVersion , err = getVersion (localPath )
128
+ localVersion , err = getVersion (localPath , distribution . BinName () )
129
129
if err != nil {
130
130
return nil , err
131
131
}
@@ -529,7 +529,7 @@ func ensureVersion(
529
529
execPath , err := dist .Downloader ().Install (context .Background (), binDir , downloadURL , v )
530
530
531
531
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 ())
533
533
}
534
534
535
535
log .Info ("Downloaded %s %s to %s" , dist .BinName (), v .String (), execPath )
@@ -576,15 +576,15 @@ func isAsyncEligibleCommand(cmd string) bool {
576
576
return false
577
577
}
578
578
579
- func getVersion (tfBinary string ) (* version.Version , error ) {
579
+ func getVersion (tfBinary string , binName string ) (* version.Version , error ) {
580
580
versionOutBytes , err := exec .Command (tfBinary , "version" ).Output () // #nosec
581
581
versionOutput := string (versionOutBytes )
582
582
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 )
584
584
}
585
585
match := versionRegex .FindStringSubmatch (versionOutput )
586
586
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 )
588
588
}
589
589
return version .NewVersion (match [1 ])
590
590
}
0 commit comments