Skip to content

Commit

Permalink
Add env-var override for HELM_VERSION
Browse files Browse the repository at this point in the history
HELM_VERSION env-var can be used with k3sup app install to
set a custom version of helm.

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <[email protected]>
  • Loading branch information
alexellis committed Nov 10, 2019
1 parent 1670103 commit a4d7c05
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ All commits must be signed-off as part of the [Developer Certificate of Origin (

MIT


## 📢 What are people saying about `k3sup`?

* [Multi-node Kubernetes on Civo in 5 minutes flat with k3sup!](https://www.civo.com/learn/kubernetes-on-civo-in-5-minutes-flat) - Civo Learn guide
Expand Down
15 changes: 10 additions & 5 deletions pkg/cmd/kubernetes_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
execute "github.com/alexellis/go-execute/pkg/v1"
)

const helmVersion = "v2.15.2"
const helmVersion = "v2.16.0"

func fetchChart(path, chart string) error {
mkErr := os.MkdirAll(path, 0700)
Expand Down Expand Up @@ -97,7 +97,7 @@ func templateChart(basePath, chart, namespace, outputPath, values string, overri

func localBinary(name string) string {
home := os.Getenv("HOME")
return path.Join(path.Join(home, ".k3sup/.bin/"), name)
return path.Join(path.Join(home, ".k3sup/bin/"), name)
}

func addHelmRepo(name, url string) error {
Expand Down Expand Up @@ -194,7 +194,7 @@ func getDefaultKubeconfig() string {
}

func tryDownloadHelm(userPath, clientArch, clientOS string) (string, error) {
helmBinaryPath := path.Join(path.Join(userPath, ".bin"), "helm")
helmBinaryPath := path.Join(path.Join(userPath, "bin"), "helm")
if _, statErr := os.Stat(helmBinaryPath); statErr != nil {
downloadHelm(userPath, clientArch, clientOS)

Expand Down Expand Up @@ -241,7 +241,12 @@ func getHelmURL(arch, os, version string) string {
}

func downloadHelm(userPath, clientArch, clientOS string) error {
helmURL := getHelmURL(clientArch, clientOS, helmVersion)
useHelmVersion := helmVersion
if val, ok := os.LookupEnv("HELM_VERSION"); ok && len(val) > 0 {
useHelmVersion = val
}

helmURL := getHelmURL(clientArch, clientOS, useHelmVersion)
fmt.Println(helmURL)
parsedURL, _ := url.Parse(helmURL)

Expand All @@ -252,7 +257,7 @@ func downloadHelm(userPath, clientArch, clientOS string) error {

defer res.Body.Close()
r := ioutil.NopCloser(res.Body)
untarErr := Untar(r, path.Join(userPath, ".bin"))
untarErr := Untar(r, path.Join(userPath, "bin"))
if untarErr != nil {
return untarErr
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/tiller_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func makeInstallTiller() *cobra.Command {
}
fmt.Println(task.Stdout, task.Stderr)

k3supBin := path.Join(userPath, ".bin")
k3supBin := path.Join(userPath, "bin")
helmInit := execute.ExecTask{
Command: path.Join(k3supBin, "helm"),
Args: []string{
Expand Down
2 changes: 1 addition & 1 deletion pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func InitUserDir() (string, error) {
return home, fmt.Errorf("env-var HOME, not set")
}

binPath := path.Join(root, "/.bin/")
binPath := path.Join(root, "/bin/")
err := os.MkdirAll(binPath, 0700)
if err != nil {
return binPath, err
Expand Down

0 comments on commit a4d7c05

Please sign in to comment.