Skip to content

Commit

Permalink
Add: if the default value is not specified, looks for values.yaml in …
Browse files Browse the repository at this point in the history
…the chart dir
  • Loading branch information
Mostafa Negim committed Mar 10, 2024
1 parent 106b788 commit 125e17e
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"log"
"os"
"path/filepath"
"slices"
"strconv"
"strings"
Expand Down Expand Up @@ -212,6 +213,17 @@ func newChartCommand() *cobra.Command {

diff.release = args[0]
diff.chart = args[1]

// helm by default looks for values.yaml in the chart. See #566
// Looking for chart/values.yaml if valueFiles is empty
if len(diff.valueFiles) == 0 {
defaultValuePath := filepath.Join(diff.chart, "values.yaml")
_, err := os.Stat(defaultValuePath)
if !os.IsNotExist(err) {
diff.valueFiles = append(diff.valueFiles, defaultValuePath)
}
}

return diff.runHelm3()
},
FParseErrWhitelist: cobra.FParseErrWhitelist{
Expand All @@ -234,6 +246,9 @@ func newChartCommand() *cobra.Command {
// Support for kube-version was re-enabled and ported from helm2 to helm3 on https://github.com/helm/helm/pull/9040
f.StringVar(&diff.kubeVersion, "kube-version", "", "Kubernetes version used for Capabilities.KubeVersion")
f.VarP(&diff.valueFiles, "values", "f", "specify values in a YAML file (can specify multiple)")
// Add string for the default value
defaultValueFiles := valueFiles{"CHART/values.yaml"}
f.Lookup("values").DefValue = defaultValueFiles.String()
f.StringArrayVar(&diff.values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)")
f.StringArrayVar(&diff.stringValues, "set-string", []string{}, "set STRING values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)")
f.StringArrayVar(&diff.jsonValues, "set-json", []string{}, "set JSON values on the command line (can specify multiple or separate values with commas: key1=jsonval1,key2=jsonval2)")
Expand Down

0 comments on commit 125e17e

Please # to comment.