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 issue with new version of go-execute #980

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
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
9 changes: 7 additions & 2 deletions pkg/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,20 @@ import (

// GetClientArch returns a pair of arch and os
func GetClientArch() (arch string, os string) {
task := execute.ExecTask{Command: "uname", Args: []string{"-m"}, StreamStdio: false}
task := execute.ExecTask{
Command: "uname",
Args: []string{"-m"},
StreamStdio: false}
res, err := task.Execute(context.Background())
if err != nil {
log.Println(err)
}

archResult := strings.TrimSpace(res.Stdout)

taskOS := execute.ExecTask{Command: "uname", Args: []string{"-s"}, StreamStdio: false}
taskOS := execute.ExecTask{Command: "uname",
Args: []string{"-s"},
StreamStdio: false}
resOS, errOS := taskOS.Execute(context.Background())
if errOS != nil {
log.Println(errOS)
Expand Down
35 changes: 8 additions & 27 deletions pkg/helm/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,34 +71,12 @@ func DownloadHelm(userPath, clientArch, clientOS, subdir string) error {
return nil
}

func HelmInit() error {
fmt.Println("Running \"helm init\".")
subdir := ""

task := execute.ExecTask{
Command: env.LocalBinary("helm", subdir),
Env: os.Environ(),
Args: []string{"init", "--client-only"},
StreamStdio: true,
}

res, err := task.Execute(context.Background())

if err != nil {
return err
}

if res.ExitCode != 0 {
return fmt.Errorf("exit code %d", res.ExitCode)
}
return nil
}

func UpdateHelmRepos(helm3 bool) error {
subdir := ""

task := execute.ExecTask{
Command: fmt.Sprintf("%s repo update", env.LocalBinary("helm", subdir)),
Command: env.LocalBinary("helm", subdir),
Args: []string{"repo", "update"},
Env: os.Environ(),
StreamStdio: true,
}
Expand All @@ -123,7 +101,8 @@ func AddHelmRepo(name, url string, update bool) error {
}

task := execute.ExecTask{
Command: fmt.Sprintf("%s repo add %s %s --force-update", env.LocalBinary("helm", subdir), name, url),
Command: env.LocalBinary("helm", subdir),
Args: []string{"repo", "add", name, url, "--force-update"},
Env: os.Environ(),
StreamStdio: true,
}
Expand All @@ -140,7 +119,8 @@ func AddHelmRepo(name, url string, update bool) error {

if update {
task := execute.ExecTask{
Command: fmt.Sprintf("%s repo update", env.LocalBinary("helm", subdir)),
Command: env.LocalBinary("helm", subdir),
Args: []string{"repo", "update"},
Env: os.Environ(),
StreamStdio: true,
}
Expand Down Expand Up @@ -180,7 +160,8 @@ func FetchChart(chart, version string) error {
return mkErr
}
task := execute.ExecTask{
Command: fmt.Sprintf("%s fetch %s --untar=true --untardir %s%s", env.LocalBinary("helm", subdir), chart, chartsPath, versionStr),
Command: env.LocalBinary("helm", subdir),
Args: []string{"fetch", chart, "--untar=true", "--untardir", chartsPath + versionStr},
Env: os.Environ(),
StreamStdio: true,
}
Expand Down