Skip to content

Commit

Permalink
Added Support for 0.13.0 provider binary search
Browse files Browse the repository at this point in the history
  • Loading branch information
juliosueiras committed Jun 4, 2020
1 parent b3dd863 commit cc17add
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tfstructs/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package tfstructs
import (
"fmt"
//log "github.com/sirupsen/logrus"
"encoding/json"
"go/build"
"io/ioutil"
oldLog "log"
Expand Down Expand Up @@ -194,6 +195,21 @@ func pluginDirs(targetDir string) ([]string, error) {

if _, err := os.Stat(filepath.Join(dir, ".terraform")); err == nil {
autoInstalledDir = filepath.Join(dir, ".terraform", "plugins", arch)

if _, err := os.Stat(filepath.Join(dir, ".terraform", "plugins", "selections.json")); err == nil {
selections := make(map[string]interface{})
file, _ := ioutil.ReadFile(filepath.Join(dir, ".terraform", "plugins", "selections.json"))
json.Unmarshal(file, &selections)

for pluginPath, info := range selections {
version := info.(map[string]interface{})["version"]

if _, err := os.Stat(filepath.Join(dir, ".terraform", "plugins", pluginPath, version.(string), arch)); err == nil {
dirs = append(dirs, filepath.Join(dir, ".terraform", "plugins", pluginPath, version.(string), arch))
}
}
}

break
}

Expand Down

0 comments on commit cc17add

Please sign in to comment.