Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 fix platform id for git clone tf assets #1840

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions motor/providers/terraform/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@ func New(tc *providers.Config) (*Provider, error) {
// Terraform from git, temporary before v9
var err error
var closer func()
var clonepath string
path := tc.Options["path"]
if strings.HasPrefix(path, "git+https://") || strings.HasPrefix(path, "git+ssh://") {
path, closer, err = processGitForTerraform(path, tc.Credentials)
clonepath, closer, err = processGitForTerraform(path, tc.Credentials)
if err != nil {
return nil, err
}
tc.Options["original-path"] = path
tc.Options["asset-type"] = "hcl"
tc.Options["path"] = path
tc.Options["path"] = clonepath
}

projectPath := ""
Expand Down Expand Up @@ -93,7 +95,6 @@ func New(tc *providers.Config) (*Provider, error) {
} else if tc.Options["path"] != "" {
assetType = configurationfiles
path := tc.Options["path"]
projectPath = path
stat, err := os.Stat(path)
if os.IsNotExist(err) {
return nil, errors.New("path '" + path + "' is not a valid file or directory")
Expand Down Expand Up @@ -154,6 +155,11 @@ func New(tc *providers.Config) (*Provider, error) {
}

// build project hash to identify the project
projectPath = path
if tc.Options["original-path"] != "" { // override path for when files have been copied over
projectPath = tc.Options["original-path"]
}
log.Debug().Str("projectPath", projectPath).Msg("creating terraform id hash")
absPath, _ := filepath.Abs(projectPath)
h := sha256.New()
h.Write([]byte(absPath))
Expand Down