From df0d8d7ccb16bd5e5dac8690d3d1d86816ff2627 Mon Sep 17 00:00:00 2001 From: Victoria Jeffrey Date: Thu, 21 Sep 2023 17:58:04 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20platform=20id=20for=20git?= =?UTF-8?q?=20clone=20tf=20assets?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- motor/providers/terraform/provider.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/motor/providers/terraform/provider.go b/motor/providers/terraform/provider.go index d28a62e5ae..8df108ba82 100644 --- a/motor/providers/terraform/provider.go +++ b/motor/providers/terraform/provider.go @@ -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 := "" @@ -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") @@ -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))