Skip to content

Commit

Permalink
Merge pull request #130 from maybolt/values-file-option-argument
Browse files Browse the repository at this point in the history
Add option for a values file named other than `values.yaml`.
  • Loading branch information
norwoodj authored Apr 3, 2022
2 parents 113c8ed + 18004fe commit 76c2280
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions cmd/helm-docs/command_line.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func newHelmDocsCommand(run func(cmd *cobra.Command, args []string)) (*cobra.Com
command.PersistentFlags().StringP("output-file", "o", "README.md", "markdown file path relative to each chart directory to which rendered documentation will be written")
command.PersistentFlags().StringP("sort-values-order", "s", document.AlphaNumSortOrder, fmt.Sprintf("order in which to sort the values table (\"%s\" or \"%s\")", document.AlphaNumSortOrder, document.FileSortOrder))
command.PersistentFlags().StringSliceP("template-files", "t", []string{"README.md.gotmpl"}, "gotemplate file paths relative to each chart directory from which documentation will be generated")
command.PersistentFlags().StringP("values-file", "f", "values.yaml", "Path to values file")

viper.AutomaticEnv()
viper.SetEnvPrefix("HELM_DOCS")
Expand Down
5 changes: 3 additions & 2 deletions pkg/helm/chart_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"strings"

log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
"gopkg.in/yaml.v3"
)

Expand Down Expand Up @@ -141,7 +142,7 @@ func parseChartRequirementsFile(chartDirectory string, apiVersion string) (Chart
}

func parseChartValuesFile(chartDirectory string) (yaml.Node, error) {
valuesPath := path.Join(chartDirectory, "values.yaml")
valuesPath := path.Join(chartDirectory, viper.GetString("values-file"))
yamlFileContents, err := getYamlFileContents(valuesPath)

var values yaml.Node
Expand All @@ -154,7 +155,7 @@ func parseChartValuesFile(chartDirectory string) (yaml.Node, error) {
}

func parseChartValuesFileComments(chartDirectory string) (map[string]ChartValueDescription, error) {
valuesPath := path.Join(chartDirectory, "values.yaml")
valuesPath := path.Join(chartDirectory, viper.GetString("values-file"))
valuesFile, err := os.Open(valuesPath)

if isErrorInReadingNecessaryFile(valuesPath, err) {
Expand Down

0 comments on commit 76c2280

Please sign in to comment.