Skip to content

Commit

Permalink
parse command for tfexec
Browse files Browse the repository at this point in the history
  • Loading branch information
speier committed Nov 4, 2024
1 parent 25cacc6 commit 753f213
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/exec/template_funcs_component.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"sync"

"github.com/hashicorp/terraform-exec/tfexec"
"github.com/mattn/go-shellwords"
"github.com/samber/lo"

cfg "github.com/cloudposse/atmos/pkg/config"
Expand Down Expand Up @@ -145,8 +146,16 @@ func componentFunc(cliConfig schema.CliConfiguration, component string, stack st
u.LogTrace(cliConfig, providerOverrideFileName)
}

parsedArgs, err := shellwords.Parse(executable)
if err != nil {
return nil, err
}

// last element should be the command name, terraform, tofu, etc.
cmdName := parsedArgs[len(parsedArgs)-1]

// Initialize Terraform/OpenTofu
tf, err := tfexec.NewTerraform(componentPath, executable)
tf, err := tfexec.NewTerraform(componentPath, cmdName)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 753f213

Please sign in to comment.