Skip to content

Commit

Permalink
fix: terraform installation (#971)
Browse files Browse the repository at this point in the history
  • Loading branch information
liu-hm19 committed Mar 28, 2024
1 parent 9d94eb0 commit b9cf0ae
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pkg/cmd/build/util.go
Expand Up @@ -22,10 +22,10 @@ import (
func IntentWithSpinner(o *builders.Options, proj *v1.Project, stack *v1.Stack, ws *v1.Workspace) (*v1.Intent, error) {
var sp *pterm.SpinnerPrinter
if o.NoStyle {
fmt.Printf("Generating Intent in the Stack %s...\n", stack.Name)
fmt.Printf("Generating Spec in the Stack %s...\n", stack.Name)
} else {
sp = &pretty.SpinnerT
sp, _ = sp.Start(fmt.Sprintf("Generating Intent in the Stack %s...", stack.Name))
sp, _ = sp.Start(fmt.Sprintf("Generating Spec in the Stack %s...", stack.Name))
}

// style means color and prompt here. Currently, sp will be nil only when o.NoStyle is true
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/init/init.go
Expand Up @@ -43,7 +43,7 @@ func NewCmd() *cobra.Command {
}

cmd.Flags().StringVarP(&o.ProjectDir, "target", "t", "",
i18n.T("specify the target direcotry"))
i18n.T("specify the target directory"))

return cmd
}
14 changes: 11 additions & 3 deletions pkg/engine/runtime/terraform/install.go
Expand Up @@ -36,7 +36,7 @@ func (installer *CLIInstaller) CheckAndInstall() error {
break
}

if i == installer.Intent.Resources.Len() {
if i == installer.Intent.Resources.Len()-1 {
return nil
}
}
Expand All @@ -56,7 +56,15 @@ func (installer *CLIInstaller) CheckAndInstall() error {

// check whether the terraform executable binary has been installed.
func checkTerraformExecutable() error {
if err := exec.Command("terraform", "--version").Run(); err == nil {
// select the executable file name according to the operating system.
var executable string
if runtime.GOOS == "windows" {
executable = "terraform.exe"
} else {
executable = "terraform"
}

if err := exec.Command(executable, "--version").Run(); err == nil {
return nil
}

Expand All @@ -65,7 +73,7 @@ func checkTerraformExecutable() error {
return err
}

execPath := filepath.Join(installDir, "terraform")
execPath := filepath.Join(installDir, executable)
if err := exec.Command(execPath, "--version").Run(); err != nil {
return err
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/kusionctl_test.go
Expand Up @@ -12,7 +12,7 @@ import (
path := filepath.Join(GetWorkDir(), "konfig", "example", "service-multi-stack", "dev")
output, err := ExecKusionWithWorkDir("kusion build", path)
gomega.Expect(err).ShouldNot(gomega.HaveOccurred())
gomega.Expect(output).To(gomega.ContainSubstring("Generating Intent"))
gomega.Expect(output).To(gomega.ContainSubstring("Generating Spec"))
})
})
})*/
Expand Down

0 comments on commit b9cf0ae

Please sign in to comment.