Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package helm-docs for openSUSE:Factory checked in at 2022-04-26 20:16:03 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/helm-docs (Old) and /work/SRC/openSUSE:Factory/.helm-docs.new.1538 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "helm-docs" Tue Apr 26 20:16:03 2022 rev:3 rq:972902 version:1.9.1 Changes: -------- --- /work/SRC/openSUSE:Factory/helm-docs/helm-docs.changes 2022-04-04 19:27:08.528021531 +0200 +++ /work/SRC/openSUSE:Factory/.helm-docs.new.1538/helm-docs.changes 2022-04-26 20:17:55.588772151 +0200 @@ -1,0 +2,20 @@ +Tue Apr 26 06:17:04 UTC 2022 - [email protected] + +- Update to version 1.9.1: + * Revert "Add angle brackets around urls in requirementsTable" + * Generated example charts with new version + +------------------------------------------------------------------- +Tue Apr 26 06:15:37 UTC 2022 - [email protected] + +- Update to version 1.9.0: + * Updates alpine docker image to fix issue #124 + * Add angle brackets around urls in requirementsTable + * Fix issue where an empty global object in a child chart would be listed in the root docs + * Warn about remote dependencies without erroring; Parse local file:// repositories + * Fix documented globals prefixed with the sub-chart alias + * Tolerate dependency charts without values.yaml + * New flag --document-dependency-values + * Runs newest helm-docs to update docs for example charts + +------------------------------------------------------------------- Old: ---- helm-docs-1.8.1.tar.gz New: ---- helm-docs-1.9.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ helm-docs.spec ++++++ --- /var/tmp/diff_new_pack.au4lru/_old 2022-04-26 20:17:56.124772799 +0200 +++ /var/tmp/diff_new_pack.au4lru/_new 2022-04-26 20:17:56.128772804 +0200 @@ -19,7 +19,7 @@ %define __arch_install_post export NO_BRP_STRIP_DEBUG=true Name: helm-docs -Version: 1.8.1 +Version: 1.9.1 Release: 0 Summary: A tool for automatically generating markdown documentation for helm charts License: GPL-3.0-only ++++++ _service ++++++ --- /var/tmp/diff_new_pack.au4lru/_old 2022-04-26 20:17:56.160772842 +0200 +++ /var/tmp/diff_new_pack.au4lru/_new 2022-04-26 20:17:56.160772842 +0200 @@ -3,11 +3,11 @@ <param name="url">https://github.com/norwoodj/helm-docs</param> <param name="scm">git</param> <param name="exclude">.git</param> - <param name="revision">v1.8.1</param> + <param name="revision">v1.9.1</param> <param name="versionformat">@PARENT_TAG@</param> <param name="changesgenerate">enable</param> <param name="versionrewrite-pattern">v(.*)</param> - <param name="match-tag">v1.8.1</param> + <param name="match-tag">v1.9.1</param> </service> <service name="set_version" mode="disabled"> <param name="basename">helm-docs</param> @@ -17,7 +17,7 @@ <param name="compression">gz</param> </service> <service name="go_modules" mode="disabled"> - <param name="archive">helm-docs-1.8.1.tar.gz</param> + <param name="archive">helm-docs-1.9.1.tar.gz</param> </service> </services> ++++++ _servicedata ++++++ --- /var/tmp/diff_new_pack.au4lru/_old 2022-04-26 20:17:56.180772867 +0200 +++ /var/tmp/diff_new_pack.au4lru/_new 2022-04-26 20:17:56.180772867 +0200 @@ -1,6 +1,6 @@ <servicedata> <service name="tar_scm"> <param name="url">https://github.com/norwoodj/helm-docs</param> - <param name="changesrevision">e91c4c3337d3bf3fdad8de1763999a5c3325567f</param></service></servicedata> + <param name="changesrevision">02caaaf59223e00c2283d82499831f1e874f9c9b</param></service></servicedata> (No newline at EOF) ++++++ helm-docs-1.8.1.tar.gz -> helm-docs-1.9.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/Dockerfile new/helm-docs-1.9.1/Dockerfile --- old/helm-docs-1.8.1/Dockerfile 2022-04-03 17:31:26.000000000 +0200 +++ new/helm-docs-1.9.1/Dockerfile 2022-04-25 21:01:27.000000000 +0200 @@ -1,4 +1,4 @@ -FROM alpine:3.11.5 +FROM alpine:3.15 COPY helm-docs /usr/bin/ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/cmd/helm-docs/command_line.go new/helm-docs-1.9.1/cmd/helm-docs/command_line.go --- old/helm-docs-1.8.1/cmd/helm-docs/command_line.go 2022-04-03 17:31:26.000000000 +0200 +++ new/helm-docs-1.9.1/cmd/helm-docs/command_line.go 2022-04-25 21:01:27.000000000 +0200 @@ -53,6 +53,7 @@ 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("badge-style", "b", "flat-square", "badge style to use for charts") command.PersistentFlags().StringP("values-file", "f", "values.yaml", "Path to values file") + command.PersistentFlags().BoolP("document-dependency-values", "u", false, "For charts with dependencies, include the dependency values in the chart values documentation") viper.AutomaticEnv() viper.SetEnvPrefix("HELM_DOCS") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/cmd/helm-docs/main.go new/helm-docs-1.9.1/cmd/helm-docs/main.go --- old/helm-docs-1.8.1/cmd/helm-docs/main.go 2022-04-03 17:31:26.000000000 +0200 +++ new/helm-docs-1.9.1/cmd/helm-docs/main.go 2022-04-25 21:01:27.000000000 +0200 @@ -1,8 +1,12 @@ package main import ( + "fmt" "os" "path" + "path/filepath" + "reflect" + "runtime" "strings" "sync" @@ -14,23 +18,42 @@ "github.com/norwoodj/helm-docs/pkg/helm" ) -func retrieveInfoAndPrintDocumentation(chartDirectory string, chartSearchRoot string, templateFiles []string, waitGroup *sync.WaitGroup, badgeStyle string, dryRun bool) { - defer waitGroup.Done() - chartDocumentationInfo, err := helm.ParseChartInformation(path.Join(chartSearchRoot, chartDirectory)) - - if err != nil { - log.Warnf("Error parsing information for chart %s, skipping: %s", chartDirectory, err) - return +// parallelProcessIterable runs the visitFn function on each element of the iterable, using +// parallelism number of worker goroutines. The iterable may be a slice or a map. In the case of a +// map, the argument passed to visitFn will be the key. +func parallelProcessIterable(iterable interface{}, parallelism int, visitFn func(elem interface{})) { + workChan := make(chan interface{}) + + wg := &sync.WaitGroup{} + wg.Add(parallelism) + + for i := 0; i < parallelism; i++ { + go func() { + defer wg.Done() + for elem := range workChan { + visitFn(elem) + } + }() } - document.PrintDocumentation(chartDocumentationInfo, chartSearchRoot, templateFiles, dryRun, version, badgeStyle) + iterableValue := reflect.ValueOf(iterable) -} + if iterableValue.Kind() == reflect.Map { + for _, key := range iterableValue.MapKeys() { + workChan <- key.Interface() + } + } else { + sliceLen := iterableValue.Len() + for i := 0; i < sliceLen; i++ { + workChan <- iterableValue.Index(i).Interface() + } + } -func helmDocs(_ *cobra.Command, _ []string) { - initializeCli() + close(workChan) + wg.Wait() +} - chartSearchRoot := viper.GetString("chart-search-root") +func readDocumentationInfoByChartPath(chartSearchRoot string, parallelism int) (map[string]helm.ChartDocumentationInfo, error) { var fullChartSearchRoot string if path.IsAbs(chartSearchRoot) { @@ -38,17 +61,15 @@ } else { cwd, err := os.Getwd() if err != nil { - log.Warnf("Error getting working directory: %s", err) - return + return nil, fmt.Errorf("error getting working directory: %w", err) } - fullChartSearchRoot = path.Join(cwd, chartSearchRoot) + fullChartSearchRoot = filepath.Join(cwd, chartSearchRoot) } chartDirs, err := helm.FindChartDirectories(fullChartSearchRoot) if err != nil { - log.Errorf("Error finding chart directories: %s", err) - os.Exit(1) + return nil, fmt.Errorf("error finding chart directories: %w", err) } log.Infof("Found Chart directories [%s]", strings.Join(chartDirs, ", ")) @@ -56,23 +77,66 @@ templateFiles := viper.GetStringSlice("template-files") log.Debugf("Rendering from optional template files [%s]", strings.Join(templateFiles, ", ")) + documentationInfoByChartPath := make(map[string]helm.ChartDocumentationInfo, len(chartDirs)) + documentationInfoByChartPathMu := &sync.Mutex{} + + parallelProcessIterable(chartDirs, parallelism, func(elem interface{}) { + chartDir := elem.(string) + info, err := helm.ParseChartInformation(filepath.Join(chartSearchRoot, chartDir)) + if err != nil { + log.Warnf("Error parsing information for chart %s, skipping: %s", chartDir, err) + return + } + documentationInfoByChartPathMu.Lock() + documentationInfoByChartPath[info.ChartDirectory] = info + documentationInfoByChartPathMu.Unlock() + }) + + return documentationInfoByChartPath, nil +} + +func writeDocumentation(chartSearchRoot string, documentationInfoByChartPath map[string]helm.ChartDocumentationInfo, dryRun bool, parallelism int) { + templateFiles := viper.GetStringSlice("template-files") badgeStyle := viper.GetString("badge-style") - dryRun := viper.GetBool("dry-run") - waitGroup := sync.WaitGroup{} + log.Debugf("Rendering from optional template files [%s]", strings.Join(templateFiles, ", ")) - for _, c := range chartDirs { - waitGroup.Add(1) + documentDependencyValues := viper.GetBool("document-dependency-values") - // On dry runs all output goes to stdout, and so as to not jumble things, generate serially - if dryRun { - retrieveInfoAndPrintDocumentation(c, fullChartSearchRoot, templateFiles, &waitGroup, badgeStyle, dryRun) - } else { - go retrieveInfoAndPrintDocumentation(c, fullChartSearchRoot, templateFiles, &waitGroup, badgeStyle, dryRun) + parallelProcessIterable(documentationInfoByChartPath, parallelism, func(elem interface{}) { + info := documentationInfoByChartPath[elem.(string)] + var err error + var dependencyValues []document.DependencyValues + if documentDependencyValues { + dependencyValues, err = document.GetDependencyValues(info, documentationInfoByChartPath) + if err != nil { + log.Warnf("Error evaluating dependency values for chart %s, skipping: %v", info.ChartDirectory, err) + return + } } + document.PrintDocumentation(info, chartSearchRoot, templateFiles, dryRun, version, badgeStyle, dependencyValues) + }) +} + +func helmDocs(_ *cobra.Command, _ []string) { + initializeCli() + + chartSearchRoot := viper.GetString("chart-search-root") + dryRun := viper.GetBool("dry-run") + + parallelism := runtime.NumCPU() * 2 + + // On dry runs all output goes to stdout, and so as to not jumble things, generate serially. + if dryRun { + parallelism = 1 + } + + documentationInfoByChartPath, err := readDocumentationInfoByChartPath(chartSearchRoot, parallelism) + if err != nil { + log.Fatal(err) } - waitGroup.Wait() + writeDocumentation(chartSearchRoot, documentationInfoByChartPath, dryRun, parallelism) } func main() { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/best-values-example/README.md new/helm-docs-1.9.1/example-charts/best-values-example/README.md --- old/helm-docs-1.8.1/example-charts/best-values-example/README.md 2022-04-03 17:31:26.000000000 +0200 +++ new/helm-docs-1.9.1/example-charts/best-values-example/README.md 2022-04-25 21:01:27.000000000 +0200 @@ -10,7 +10,7 @@ | Name | Email | Url | | ---- | ------ | --- | -| John Norwood | [email protected] | | +| John Norwood | <[email protected]> | | ## Source Code @@ -31,4 +31,4 @@ | statefulset.podLabels | object | `{}` | The labels to be applied to instances of the database | ---------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) +Autogenerated from chart metadata using [helm-docs v1.9.0](https://github.com/norwoodj/helm-docs/releases/v1.9.0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/custom-template/README.md new/helm-docs-1.9.1/example-charts/custom-template/README.md --- old/helm-docs-1.8.1/example-charts/custom-template/README.md 2022-04-03 17:31:26.000000000 +0200 +++ new/helm-docs-1.9.1/example-charts/custom-template/README.md 2022-04-25 21:01:27.000000000 +0200 @@ -39,7 +39,7 @@ | Repository | Name | Version | |------------|------|---------| -| @stable | nginx-ingress | 0.22.1 | +| <@stable> | nginx-ingress | 0.22.1 | ## Values @@ -59,4 +59,4 @@ | controller.service.type | string | `"LoadBalancer"` | | ---------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) +Autogenerated from chart metadata using [helm-docs v1.9.0](https://github.com/norwoodj/helm-docs/releases/v1.9.0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/dos-line-endings/README.md new/helm-docs-1.9.1/example-charts/dos-line-endings/README.md --- old/helm-docs-1.8.1/example-charts/dos-line-endings/README.md 2022-04-03 17:31:26.000000000 +0200 +++ new/helm-docs-1.9.1/example-charts/dos-line-endings/README.md 2022-04-25 21:01:27.000000000 +0200 @@ -14,4 +14,4 @@ | livenessProbe.httpGet.port | string | `"http"` | | ---------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) +Autogenerated from chart metadata using [helm-docs v1.9.0](https://github.com/norwoodj/helm-docs/releases/v1.9.0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/full-template/README.md new/helm-docs-1.9.1/example-charts/full-template/README.md --- old/helm-docs-1.8.1/example-charts/full-template/README.md 2022-04-03 17:31:26.000000000 +0200 +++ new/helm-docs-1.9.1/example-charts/full-template/README.md 2022-04-25 21:01:27.000000000 +0200 @@ -70,7 +70,7 @@ | Name | Email | Url | | ---- | ------ | --- | -| John Norwood | [email protected] | | +| John Norwood | <[email protected]> | | ## `chart.maintainersSection` @@ -78,7 +78,7 @@ | Name | Email | Url | | ---- | ------ | --- | -| John Norwood | [email protected] | | +| John Norwood | <[email protected]> | | ## `chart.sourcesHeader` @@ -110,7 +110,7 @@ | Repository | Name | Version | |------------|------|---------| -| @stable | nginx-ingress | 0.22.1 | +| <@stable> | nginx-ingress | 0.22.1 | ## `chart.requirementsSection` @@ -120,7 +120,7 @@ | Repository | Name | Version | |------------|------|---------| -| @stable | nginx-ingress | 0.22.1 | +| <@stable> | nginx-ingress | 0.22.1 | ## `chart.valuesHeader` @@ -163,4 +163,4 @@ | controller.service.type | string | `"LoadBalancer"` | | ---------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) +Autogenerated from chart metadata using [helm-docs v1.9.0](https://github.com/norwoodj/helm-docs/releases/v1.9.0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/funky-version/README.md new/helm-docs-1.9.1/example-charts/funky-version/README.md --- old/helm-docs-1.8.1/example-charts/funky-version/README.md 2022-04-03 17:31:26.000000000 +0200 +++ new/helm-docs-1.9.1/example-charts/funky-version/README.md 2022-04-25 21:01:27.000000000 +0200 @@ -10,11 +10,11 @@ | Name | Email | Url | | ---- | ------ | --- | -| John Norwood | [email protected] | | +| John Norwood | <[email protected]> | | ## Source Code * <https://github.com/norwoodj/helm-docs/tree/master/example-charts/funky-version> ---------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) +Autogenerated from chart metadata using [helm-docs v1.9.0](https://github.com/norwoodj/helm-docs/releases/v1.9.0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/helm-3/README.md new/helm-docs-1.9.1/example-charts/helm-3/README.md --- old/helm-docs-1.8.1/example-charts/helm-3/README.md 2022-04-03 17:31:26.000000000 +0200 +++ new/helm-docs-1.9.1/example-charts/helm-3/README.md 2022-04-25 21:01:27.000000000 +0200 @@ -10,7 +10,7 @@ | Name | Email | Url | | ---- | ------ | --- | -| John Norwood | [email protected] | | +| John Norwood | <[email protected]> | | ## Source Code @@ -20,7 +20,7 @@ | Repository | Name | Version | |------------|------|---------| -| @stable | nginx-ingress | 0.22.1 | +| <@stable> | nginx-ingress | 0.22.1 | ## Values @@ -41,4 +41,4 @@ | controller.service.type | string | `"LoadBalancer"` | | ---------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) +Autogenerated from chart metadata using [helm-docs v1.9.0](https://github.com/norwoodj/helm-docs/releases/v1.9.0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/most-empty/README.md new/helm-docs-1.9.1/example-charts/most-empty/README.md --- old/helm-docs-1.8.1/example-charts/most-empty/README.md 2022-04-03 17:31:26.000000000 +0200 +++ new/helm-docs-1.9.1/example-charts/most-empty/README.md 2022-04-25 21:01:27.000000000 +0200 @@ -21,4 +21,4 @@ ``` ---------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) +Autogenerated from chart metadata using [helm-docs v1.9.0](https://github.com/norwoodj/helm-docs/releases/v1.9.0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/nginx-ingress/README.md new/helm-docs-1.9.1/example-charts/nginx-ingress/README.md --- old/helm-docs-1.8.1/example-charts/nginx-ingress/README.md 2022-04-03 17:31:26.000000000 +0200 +++ new/helm-docs-1.9.1/example-charts/nginx-ingress/README.md 2022-04-25 21:01:27.000000000 +0200 @@ -10,7 +10,7 @@ | Name | Email | Url | | ---- | ------ | --- | -| John Norwood | [email protected] | | +| John Norwood | <[email protected]> | | ## Source Code @@ -20,7 +20,7 @@ | Repository | Name | Version | |------------|------|---------| -| @stable | nginx-ingress | 0.22.1 | +| <@stable> | nginx-ingress | 0.22.1 | ## Values @@ -41,4 +41,4 @@ | controller.service.type | string | `"LoadBalancer"` | | ---------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) +Autogenerated from chart metadata using [helm-docs v1.9.0](https://github.com/norwoodj/helm-docs/releases/v1.9.0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/nginx-ingress-but-auto-comments/README.md new/helm-docs-1.9.1/example-charts/nginx-ingress-but-auto-comments/README.md --- old/helm-docs-1.8.1/example-charts/nginx-ingress-but-auto-comments/README.md 2022-04-03 17:31:26.000000000 +0200 +++ new/helm-docs-1.9.1/example-charts/nginx-ingress-but-auto-comments/README.md 2022-04-25 21:01:27.000000000 +0200 @@ -10,7 +10,7 @@ | Name | Email | Url | | ---- | ------ | --- | -| John Norwood | [email protected] | | +| John Norwood | <[email protected]> | | ## Source Code @@ -20,7 +20,7 @@ | Repository | Name | Version | |------------|------|---------| -| @stable | nginx-ingress | 0.22.1 | +| <@stable> | nginx-ingress | 0.22.1 | ## Values @@ -41,4 +41,4 @@ | controller.service.type | string | `"LoadBalancer"` | | ---------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) +Autogenerated from chart metadata using [helm-docs v1.9.0](https://github.com/norwoodj/helm-docs/releases/v1.9.0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/no-requirements/README.md new/helm-docs-1.9.1/example-charts/no-requirements/README.md --- old/helm-docs-1.8.1/example-charts/no-requirements/README.md 2022-04-03 17:31:26.000000000 +0200 +++ new/helm-docs-1.9.1/example-charts/no-requirements/README.md 2022-04-25 21:01:27.000000000 +0200 @@ -10,7 +10,7 @@ | Name | Email | Url | | ---- | ------ | --- | -| John Norwood | [email protected] | | +| John Norwood | <[email protected]> | | ## Source Code @@ -26,4 +26,4 @@ | rules.statusCodes.codes.5xx.threshold | float | `1.5` | Threshold percentage of 5xx responses above which the alert will fire | ---------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) +Autogenerated from chart metadata using [helm-docs v1.9.0](https://github.com/norwoodj/helm-docs/releases/v1.9.0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/no-values/README.md new/helm-docs-1.9.1/example-charts/no-values/README.md --- old/helm-docs-1.8.1/example-charts/no-values/README.md 2022-04-03 17:31:26.000000000 +0200 +++ new/helm-docs-1.9.1/example-charts/no-values/README.md 2022-04-25 21:01:27.000000000 +0200 @@ -10,11 +10,11 @@ | Name | Email | Url | | ---- | ------ | --- | -| John Norwood | [email protected] | | +| John Norwood | <[email protected]> | | ## Source Code * <https://github.com/norwoodj/helm-docs/tree/master/example-charts/no-values> ---------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) +Autogenerated from chart metadata using [helm-docs v1.9.0](https://github.com/norwoodj/helm-docs/releases/v1.9.0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/special-characters/README.md new/helm-docs-1.9.1/example-charts/special-characters/README.md --- old/helm-docs-1.8.1/example-charts/special-characters/README.md 2022-04-03 17:31:26.000000000 +0200 +++ new/helm-docs-1.9.1/example-charts/special-characters/README.md 2022-04-25 21:01:27.000000000 +0200 @@ -10,7 +10,7 @@ | Name | Email | Url | | ---- | ------ | --- | -| John Norwood | [email protected] | | +| John Norwood | <[email protected]> | | ## Source Code @@ -27,4 +27,4 @@ | htmlSnippets.two | string | `""` | Let's put it in the description <html></html> | ---------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) +Autogenerated from chart metadata using [helm-docs v1.9.0](https://github.com/norwoodj/helm-docs/releases/v1.9.0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/special-characters-but-auto-comments/README.md new/helm-docs-1.9.1/example-charts/special-characters-but-auto-comments/README.md --- old/helm-docs-1.8.1/example-charts/special-characters-but-auto-comments/README.md 2022-04-03 17:31:26.000000000 +0200 +++ new/helm-docs-1.9.1/example-charts/special-characters-but-auto-comments/README.md 2022-04-25 21:01:27.000000000 +0200 @@ -10,7 +10,7 @@ | Name | Email | Url | | ---- | ------ | --- | -| John Norwood | [email protected] | | +| John Norwood | <[email protected]> | | ## Source Code @@ -27,4 +27,4 @@ | htmlSnippets.two | string | `""` | Let's put it in the description <html></html> | ---------------------------------------------- -Autogenerated from chart metadata using [helm-docs v1.5.0](https://github.com/norwoodj/helm-docs/releases/v1.5.0) +Autogenerated from chart metadata using [helm-docs v1.9.0](https://github.com/norwoodj/helm-docs/releases/v1.9.0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/umbrella/Chart.yaml new/helm-docs-1.9.1/example-charts/umbrella/Chart.yaml --- old/helm-docs-1.8.1/example-charts/umbrella/Chart.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/helm-docs-1.9.1/example-charts/umbrella/Chart.yaml 2022-04-25 21:01:27.000000000 +0200 @@ -0,0 +1,14 @@ +apiVersion: v2 +name: umbrella +description: A chart demonstrating that values documentation from child charts are aggregated on the parent chart. +version: "0.1.0" +type: application +dependencies: + - name: sub-a + version: 0.1.0 + - name: sub-b + version: 0.1.0 + - name: sub-c + version: 0.1.0 + - name: library + version: 0.1.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/umbrella/README.md new/helm-docs-1.9.1/example-charts/umbrella/README.md --- old/helm-docs-1.8.1/example-charts/umbrella/README.md 1970-01-01 01:00:00.000000000 +0100 +++ new/helm-docs-1.9.1/example-charts/umbrella/README.md 2022-04-25 21:01:27.000000000 +0200 @@ -0,0 +1,28 @@ +# umbrella + +  + +A chart demonstrating that values documentation from child charts are aggregated on the parent chart. + +## Requirements + +| Repository | Name | Version | +|------------|------|---------| +| <> | library | 0.1.0 | +| <> | sub-a | 0.1.0 | +| <> | sub-b | 0.1.0 | +| <> | sub-c | 0.1.0 | + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| global | object | `{}` | | +| global.myGlobalKey | string | `"my-global-value"` | A global key | +| global.myGlobalSubChartKey | string | `"my-global-sub-chart-value"` | A global key defined in a sub chart | +| myParentKey | string | `"my-parent-value"` | A parent key | +| sub-a.mySubKeyA | string | `"my-sub-value-a"` | Value for sub-chart A | +| sub-b.mySubKeyB | string | `"my-sub-value-b"` | Value for sub-chart B | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.9.0](https://github.com/norwoodj/helm-docs/releases/v1.9.0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/umbrella/charts/library/Chart.yaml new/helm-docs-1.9.1/example-charts/umbrella/charts/library/Chart.yaml --- old/helm-docs-1.8.1/example-charts/umbrella/charts/library/Chart.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/helm-docs-1.9.1/example-charts/umbrella/charts/library/Chart.yaml 2022-04-25 21:01:27.000000000 +0200 @@ -0,0 +1,5 @@ +apiVersion: v2 +name: library +description: An example library sub-chart with no values. +version: "0.1.0" +type: library diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/umbrella/charts/sub-a/Chart.yaml new/helm-docs-1.9.1/example-charts/umbrella/charts/sub-a/Chart.yaml --- old/helm-docs-1.8.1/example-charts/umbrella/charts/sub-a/Chart.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/helm-docs-1.9.1/example-charts/umbrella/charts/sub-a/Chart.yaml 2022-04-25 21:01:27.000000000 +0200 @@ -0,0 +1,9 @@ +apiVersion: v2 +name: sub-a +description: A sub-chart. +version: "0.1.0" +type: application +dependencies: + - name: library + version: 0.1.0 + repository: file://../library diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/umbrella/charts/sub-a/README.md new/helm-docs-1.9.1/example-charts/umbrella/charts/sub-a/README.md --- old/helm-docs-1.8.1/example-charts/umbrella/charts/sub-a/README.md 1970-01-01 01:00:00.000000000 +0100 +++ new/helm-docs-1.9.1/example-charts/umbrella/charts/sub-a/README.md 2022-04-25 21:01:27.000000000 +0200 @@ -0,0 +1,22 @@ +# sub-a + +  + +A sub-chart. + +## Requirements + +| Repository | Name | Version | +|------------|------|---------| +| <file://../library> | library | 0.1.0 | + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| global.myGlobalKey | string | `"my-global-value"` | A global key | +| global.myGlobalSubChartKey | string | `"my-global-sub-chart-value"` | A global key defined in a sub chart | +| mySubKeyA | string | `"my-sub-value-a"` | Value for sub-chart A | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.9.0](https://github.com/norwoodj/helm-docs/releases/v1.9.0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/umbrella/charts/sub-a/values.yaml new/helm-docs-1.9.1/example-charts/umbrella/charts/sub-a/values.yaml --- old/helm-docs-1.8.1/example-charts/umbrella/charts/sub-a/values.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/helm-docs-1.9.1/example-charts/umbrella/charts/sub-a/values.yaml 2022-04-25 21:01:27.000000000 +0200 @@ -0,0 +1,9 @@ +global: + # -- A global key + myGlobalKey: my-global-value + + # -- A global key defined in a sub chart + myGlobalSubChartKey: my-global-sub-chart-value + +# -- Value for sub-chart A +mySubKeyA: my-sub-value-a diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/umbrella/charts/sub-b/Chart.yaml new/helm-docs-1.9.1/example-charts/umbrella/charts/sub-b/Chart.yaml --- old/helm-docs-1.8.1/example-charts/umbrella/charts/sub-b/Chart.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/helm-docs-1.9.1/example-charts/umbrella/charts/sub-b/Chart.yaml 2022-04-25 21:01:27.000000000 +0200 @@ -0,0 +1,9 @@ +apiVersion: v2 +name: sub-b +description: A sub-chart. +version: "0.1.0" +type: application +dependencies: + - name: library + version: 0.1.0 + repository: file://../library diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/umbrella/charts/sub-b/README.md new/helm-docs-1.9.1/example-charts/umbrella/charts/sub-b/README.md --- old/helm-docs-1.8.1/example-charts/umbrella/charts/sub-b/README.md 1970-01-01 01:00:00.000000000 +0100 +++ new/helm-docs-1.9.1/example-charts/umbrella/charts/sub-b/README.md 2022-04-25 21:01:27.000000000 +0200 @@ -0,0 +1,21 @@ +# sub-b + +  + +A sub-chart. + +## Requirements + +| Repository | Name | Version | +|------------|------|---------| +| <file://../library> | library | 0.1.0 | + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| global.myGlobalKey | string | `"my-global-value"` | A global key | +| mySubKeyB | string | `"my-sub-value-b"` | Value for sub-chart B | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.9.0](https://github.com/norwoodj/helm-docs/releases/v1.9.0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/umbrella/charts/sub-b/values.yaml new/helm-docs-1.9.1/example-charts/umbrella/charts/sub-b/values.yaml --- old/helm-docs-1.8.1/example-charts/umbrella/charts/sub-b/values.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/helm-docs-1.9.1/example-charts/umbrella/charts/sub-b/values.yaml 2022-04-25 21:01:27.000000000 +0200 @@ -0,0 +1,6 @@ +global: + # -- A global key + myGlobalKey: my-global-value + +# -- Value for sub-chart B +mySubKeyB: my-sub-value-b diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/umbrella/charts/sub-c/Chart.yaml new/helm-docs-1.9.1/example-charts/umbrella/charts/sub-c/Chart.yaml --- old/helm-docs-1.8.1/example-charts/umbrella/charts/sub-c/Chart.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/helm-docs-1.9.1/example-charts/umbrella/charts/sub-c/Chart.yaml 2022-04-25 21:01:27.000000000 +0200 @@ -0,0 +1,9 @@ +apiVersion: v2 +name: sub-c +description: A sub-chart. +version: "0.1.0" +type: application +dependencies: + - name: library + version: 0.1.0 + repository: file://../library diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/umbrella/charts/sub-c/README.md new/helm-docs-1.9.1/example-charts/umbrella/charts/sub-c/README.md --- old/helm-docs-1.8.1/example-charts/umbrella/charts/sub-c/README.md 1970-01-01 01:00:00.000000000 +0100 +++ new/helm-docs-1.9.1/example-charts/umbrella/charts/sub-c/README.md 2022-04-25 21:01:27.000000000 +0200 @@ -0,0 +1,20 @@ +# sub-c + +  + +A sub-chart. + +## Requirements + +| Repository | Name | Version | +|------------|------|---------| +| <file://../library> | library | 0.1.0 | + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| global | object | `{}` | | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.9.0](https://github.com/norwoodj/helm-docs/releases/v1.9.0) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/umbrella/charts/sub-c/values.yaml new/helm-docs-1.9.1/example-charts/umbrella/charts/sub-c/values.yaml --- old/helm-docs-1.8.1/example-charts/umbrella/charts/sub-c/values.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/helm-docs-1.9.1/example-charts/umbrella/charts/sub-c/values.yaml 2022-04-25 21:01:27.000000000 +0200 @@ -0,0 +1 @@ +global: {} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/example-charts/umbrella/values.yaml new/helm-docs-1.9.1/example-charts/umbrella/values.yaml --- old/helm-docs-1.8.1/example-charts/umbrella/values.yaml 1970-01-01 01:00:00.000000000 +0100 +++ new/helm-docs-1.9.1/example-charts/umbrella/values.yaml 2022-04-25 21:01:27.000000000 +0200 @@ -0,0 +1,6 @@ +global: + # -- A global key + myGlobalKey: my-global-value + +# -- A parent key +myParentKey: my-parent-value diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/pkg/document/dependency_values.go new/helm-docs-1.9.1/pkg/document/dependency_values.go --- old/helm-docs-1.8.1/pkg/document/dependency_values.go 1970-01-01 01:00:00.000000000 +0100 +++ new/helm-docs-1.9.1/pkg/document/dependency_values.go 2022-04-25 21:01:27.000000000 +0200 @@ -0,0 +1,69 @@ +package document + +import ( + "path/filepath" + "strings" + + log "github.com/sirupsen/logrus" + "gopkg.in/yaml.v3" + + "github.com/norwoodj/helm-docs/pkg/helm" +) + +type DependencyValues struct { + Prefix string + ChartValues *yaml.Node + ChartValuesDescriptions map[string]helm.ChartValueDescription +} + +func GetDependencyValues(root helm.ChartDocumentationInfo, allChartInfoByChartPath map[string]helm.ChartDocumentationInfo) ([]DependencyValues, error) { + return getDependencyValuesWithPrefix(root, allChartInfoByChartPath, "") +} + +func getDependencyValuesWithPrefix(root helm.ChartDocumentationInfo, allChartInfoByChartPath map[string]helm.ChartDocumentationInfo, prefix string) ([]DependencyValues, error) { + if len(root.Dependencies) == 0 { + return nil, nil + } + + result := make([]DependencyValues, 0, len(root.Dependencies)) + + for _, dep := range root.Dependencies { + searchPath := "" + + if strings.HasPrefix(dep.Repository, "file://") { + searchPath = filepath.Join(root.ChartDirectory, strings.TrimPrefix(dep.Repository, "file://")) + } else if dep.Repository != "" { + log.Warnf("Chart in %q has a remote dependency %q. Dependency values will not be included.", root.ChartDirectory, dep.Name) + continue + } else { + searchPath = filepath.Join(root.ChartDirectory, "charts", dep.Name) + } + + depInfo, ok := allChartInfoByChartPath[searchPath] + if !ok { + log.Warnf("Dependency with path %q was not found. Dependency values will not be included.", searchPath) + continue + } + + alias := dep.Alias + if alias == "" { + alias = dep.Name + } + depPrefix := prefix + alias + + result = append(result, DependencyValues{ + Prefix: depPrefix, + ChartValues: depInfo.ChartValues, + ChartValuesDescriptions: depInfo.ChartValuesDescriptions, + }) + + children, err := getDependencyValuesWithPrefix(depInfo, allChartInfoByChartPath, depPrefix+".") + if err != nil { + return nil, err + } + + result = append(result, children...) + } + + return result, nil +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/pkg/document/dependency_values_test.go new/helm-docs-1.9.1/pkg/document/dependency_values_test.go --- old/helm-docs-1.8.1/pkg/document/dependency_values_test.go 1970-01-01 01:00:00.000000000 +0100 +++ new/helm-docs-1.9.1/pkg/document/dependency_values_test.go 2022-04-25 21:01:27.000000000 +0200 @@ -0,0 +1,112 @@ +package document_test + +import ( + "path/filepath" + "testing" + + "github.com/norwoodj/helm-docs/pkg/helm" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "gopkg.in/yaml.v3" + + . "github.com/norwoodj/helm-docs/pkg/document" +) + +func TestGetDependencyValues(t *testing.T) { + type args struct { + root helm.ChartDocumentationInfo + all []helm.ChartDocumentationInfo + } + tests := []struct { + name string + args args + want []DependencyValues + wantErr bool + }{ + { + name: "zero dependencies", + }, + { + name: "local dependency with name", + args: args{ + root: info([]helm.ChartRequirementsItem{{Name: "sub-name"}}, "root"), + all: []helm.ChartDocumentationInfo{ + info(nil, "root", "charts", "sub-name"), + }, + }, + want: []DependencyValues{ + values("sub-name", "root", "charts", "sub-name"), + }, + }, + { + name: "local dependency with alias", + args: args{ + root: info([]helm.ChartRequirementsItem{{Name: "sub-name", Alias: "sub-alias"}}, "root"), + all: []helm.ChartDocumentationInfo{ + info(nil, "root", "charts", "sub-name"), + }, + }, + want: []DependencyValues{ + values("sub-alias", "root", "charts", "sub-name"), + }, + }, + { + name: "nested dependencies", + args: args{ + root: info([]helm.ChartRequirementsItem{{Name: "mid-a"}, {Name: "mid-b"}}, "root"), + all: []helm.ChartDocumentationInfo{ + info([]helm.ChartRequirementsItem{{Name: "leaf-c"}, {Name: "leaf-d"}}, "root", "charts", "mid-a"), + info([]helm.ChartRequirementsItem{{Name: "leaf-e"}, {Name: "leaf-f"}}, "root", "charts", "mid-b"), + info(nil, "root", "charts", "mid-a", "charts", "leaf-c"), + info(nil, "root", "charts", "mid-a", "charts", "leaf-d"), + info(nil, "root", "charts", "mid-b", "charts", "leaf-e"), + info(nil, "root", "charts", "mid-b", "charts", "leaf-f"), + }, + }, + want: []DependencyValues{ + values("mid-a", "root", "charts", "mid-a"), + values("mid-b", "root", "charts", "mid-b"), + values("mid-a.leaf-c", "root", "charts", "mid-a", "charts", "leaf-c"), + values("mid-a.leaf-d", "root", "charts", "mid-a", "charts", "leaf-d"), + values("mid-b.leaf-e", "root", "charts", "mid-b", "charts", "leaf-e"), + values("mid-b.leaf-f", "root", "charts", "mid-b", "charts", "leaf-f"), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + infosByChartPath := make(map[string]helm.ChartDocumentationInfo) + for _, info := range tt.args.all { + infosByChartPath[info.ChartDirectory] = info + } + got, err := GetDependencyValues(tt.args.root, infosByChartPath) + if tt.wantErr { + require.Error(t, err) + } else { + require.NoError(t, err) + } + assert.ElementsMatch(t, tt.want, got) + }) + } +} + +func info(dependencies []helm.ChartRequirementsItem, dirParts ...string) helm.ChartDocumentationInfo { + dir := filepath.Join(dirParts...) + return helm.ChartDocumentationInfo{ + ChartDirectory: dir, + ChartValues: &yaml.Node{Value: dir}, + ChartValuesDescriptions: map[string]helm.ChartValueDescription{"value": {Description: dir}}, + ChartRequirements: helm.ChartRequirements{ + Dependencies: dependencies, + }, + } +} + +func values(prefix string, dirParts ...string) DependencyValues { + dir := filepath.Join(dirParts...) + return DependencyValues{ + Prefix: prefix, + ChartValues: &yaml.Node{Value: dir}, + ChartValuesDescriptions: map[string]helm.ChartValueDescription{"value": {Description: dir}}, + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/pkg/document/generate.go new/helm-docs-1.9.1/pkg/document/generate.go --- old/helm-docs-1.8.1/pkg/document/generate.go 2022-04-03 17:31:26.000000000 +0200 +++ new/helm-docs-1.9.1/pkg/document/generate.go 2022-04-25 21:01:27.000000000 +0200 @@ -3,7 +3,6 @@ import ( "bytes" "os" - "path" "path/filepath" "regexp" @@ -18,7 +17,7 @@ } outputFile := viper.GetString("output-file") - f, err := os.Create(path.Join(chartDirectory, outputFile)) + f, err := os.Create(filepath.Join(chartDirectory, outputFile)) if err != nil { return nil, err @@ -27,7 +26,7 @@ return f, err } -func PrintDocumentation(chartDocumentationInfo helm.ChartDocumentationInfo, chartSearchRoot string, templateFiles []string, dryRun bool, helmDocsVersion string, badgeStyle string) { +func PrintDocumentation(chartDocumentationInfo helm.ChartDocumentationInfo, chartSearchRoot string, templateFiles []string, dryRun bool, helmDocsVersion string, badgeStyle string, dependencyValues []DependencyValues) { log.Infof("Generating README Documentation for chart %s", chartDocumentationInfo.ChartDirectory) chartDocumentationTemplate, err := newChartDocumentationTemplate( @@ -42,7 +41,7 @@ return } - chartTemplateDataObject, err := getChartTemplateData(chartDocumentationInfo, helmDocsVersion) + chartTemplateDataObject, err := getChartTemplateData(chartDocumentationInfo, helmDocsVersion, dependencyValues) if err != nil { log.Warnf("Error generating template data for chart %s: %s", chartDocumentationInfo.ChartDirectory, err) return diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/pkg/document/model.go new/helm-docs-1.9.1/pkg/document/model.go --- old/helm-docs-1.8.1/pkg/document/model.go 2022-04-03 17:31:26.000000000 +0200 +++ new/helm-docs-1.9.1/pkg/document/model.go 2022-04-25 21:01:27.000000000 +0200 @@ -3,12 +3,13 @@ import ( "fmt" "sort" - "strconv" + "strings" log "github.com/sirupsen/logrus" - "github.com/norwoodj/helm-docs/pkg/helm" "github.com/spf13/viper" "gopkg.in/yaml.v3" + + "github.com/norwoodj/helm-docs/pkg/helm" ) type valueRow struct { @@ -20,6 +21,8 @@ Description string Column int LineNumber int + Dependency string + IsGlobal bool } type chartTemplateData struct { @@ -28,68 +31,107 @@ Values []valueRow } -func getSortedValuesTableRows(documentRoot *yaml.Node, chartValuesDescriptions map[string]helm.ChartValueDescription) ([]valueRow, error) { - valuesTableRows, err := createValueRowsFromField( - "", - nil, - documentRoot, - chartValuesDescriptions, - true, - ) +func sortValueRows(valueRows []valueRow) { + sortOrder := viper.GetString("sort-values-order") - if err != nil { - return nil, err + if sortOrder != FileSortOrder && sortOrder != AlphaNumSortOrder { + log.Warnf("Invalid sort order provided %s, defaulting to %s", sortOrder, AlphaNumSortOrder) + sortOrder = AlphaNumSortOrder } - sortOrder := viper.GetString("sort-values-order") - if sortOrder == FileSortOrder { - sort.Slice(valuesTableRows, func(i, j int) bool { - if valuesTableRows[i].LineNumber == valuesTableRows[j].LineNumber { - return valuesTableRows[i].Column < valuesTableRows[j].Column + sort.Slice(valueRows, func(i, j int) bool { + // Globals sort above non-globals. + if valueRows[i].IsGlobal != valueRows[j].IsGlobal { + return valueRows[i].IsGlobal + } + + // Group by dependency for non-globals. + if !valueRows[i].IsGlobal && !valueRows[j].IsGlobal { + // Values for the main chart sort above values for dependencies. + if (valueRows[i].Dependency == "") != (valueRows[j].Dependency == "") { + return valueRows[i].Dependency == "" } - return valuesTableRows[i].LineNumber < valuesTableRows[i].LineNumber - }) - } else if sortOrder == AlphaNumSortOrder { - sort.Slice(valuesTableRows, func(i, j int) bool { - return valuesTableRows[i].Key < valuesTableRows[j].Key - }) - } else { - log.Warnf("Invalid sort order provided %s, defaulting to %s", sortOrder, AlphaNumSortOrder) - sort.Slice(valuesTableRows, func(i, j int) bool { - return valuesTableRows[i].Key < valuesTableRows[j].Key - }) - } + // Group dependency values together. + if valueRows[i].Dependency != valueRows[j].Dependency { + return valueRows[i].Dependency < valueRows[j].Dependency + } + } - return valuesTableRows, nil + // Sort the remaining values within the same section using the configured sort order. + switch sortOrder { + case FileSortOrder: + if valueRows[i].LineNumber == valueRows[j].LineNumber { + return valueRows[i].Column < valueRows[j].Column + } + return valueRows[i].LineNumber < valueRows[i].LineNumber + case AlphaNumSortOrder: + return valueRows[i].Key < valueRows[j].Key + default: + panic("cannot get here") + } + }) } - -func getChartTemplateData(chartDocumentationInfo helm.ChartDocumentationInfo, helmDocsVersion string) (chartTemplateData, error) { - // handle empty values file case - if chartDocumentationInfo.ChartValues.Kind == 0 { - return chartTemplateData{ - ChartDocumentationInfo: chartDocumentationInfo, - HelmDocsVersion: helmDocsVersion, - Values: make([]valueRow, 0), - }, nil +func getUnsortedValueRows(document *yaml.Node, descriptions map[string]helm.ChartValueDescription) ([]valueRow, error) { + // Handle empty values file case. + if document.Kind == 0 { + return nil, nil } - if chartDocumentationInfo.ChartValues.Kind != yaml.DocumentNode { - return chartTemplateData{}, fmt.Errorf("invalid node kind supplied: %d", chartDocumentationInfo.ChartValues.Kind) + if document.Kind != yaml.DocumentNode { + return nil, fmt.Errorf("invalid node kind supplied: %d", document.Kind) } - if chartDocumentationInfo.ChartValues.Content[0].Kind != yaml.MappingNode { - return chartTemplateData{}, fmt.Errorf("values file must resolve to a map, not %s", strconv.Itoa(int(chartDocumentationInfo.ChartValues.Kind))) + + if document.Content[0].Kind != yaml.MappingNode { + return nil, fmt.Errorf("values file must resolve to a map (was %d)", document.Content[0].Kind) } - valuesTableRows, err := getSortedValuesTableRows(chartDocumentationInfo.ChartValues.Content[0], chartDocumentationInfo.ChartValuesDescriptions) + return createValueRowsFromField("", nil, document.Content[0], descriptions, true) +} +func getChartTemplateData(info helm.ChartDocumentationInfo, helmDocsVersion string, dependencyValues []DependencyValues) (chartTemplateData, error) { + valuesTableRows, err := getUnsortedValueRows(info.ChartValues, info.ChartValuesDescriptions) if err != nil { return chartTemplateData{}, err } + if len(dependencyValues) > 0 { + seenGlobalKeys := make(map[string]bool) + for i, row := range valuesTableRows { + if strings.HasPrefix(row.Key, "global.") { + valuesTableRows[i].IsGlobal = true + seenGlobalKeys[row.Key] = true + } + } + + for _, dep := range dependencyValues { + depValuesTableRows, err := getUnsortedValueRows(dep.ChartValues, dep.ChartValuesDescriptions) + if err != nil { + return chartTemplateData{}, err + } + + for _, row := range depValuesTableRows { + if row.Key == "global" || strings.HasPrefix(row.Key, "global.") { + if seenGlobalKeys[row.Key] { + continue + } + row.IsGlobal = true + seenGlobalKeys[row.Key] = true + } else { + row.Key = dep.Prefix + "." + row.Key + } + + row.Dependency = dep.Prefix + valuesTableRows = append(valuesTableRows, row) + } + } + } + + sortValueRows(valuesTableRows) + return chartTemplateData{ - ChartDocumentationInfo: chartDocumentationInfo, + ChartDocumentationInfo: info, HelmDocsVersion: helmDocsVersion, Values: valuesTableRows, }, nil diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/pkg/document/template.go new/helm-docs-1.9.1/pkg/document/template.go --- old/helm-docs-1.8.1/pkg/document/template.go 2022-04-03 17:31:26.000000000 +0200 +++ new/helm-docs-1.9.1/pkg/document/template.go 2022-04-25 21:01:27.000000000 +0200 @@ -4,7 +4,7 @@ "fmt" "io/ioutil" "os" - "path" + "path/filepath" "strings" "text/template" @@ -248,9 +248,9 @@ var fullTemplatePath string if util.IsRelativePath(templateFile) { - fullTemplatePath = path.Join(chartSearchRoot, templateFile) + fullTemplatePath = filepath.Join(chartSearchRoot, templateFile) } else if util.IsBaseFilename(templateFile) { - fullTemplatePath = path.Join(chartDirectory, templateFile) + fullTemplatePath = filepath.Join(chartDirectory, templateFile) } else { fullTemplatePath = templateFile } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/pkg/document/values_test.go new/helm-docs-1.9.1/pkg/document/values_test.go --- old/helm-docs-1.8.1/pkg/document/values_test.go 2022-04-03 17:31:26.000000000 +0200 +++ new/helm-docs-1.9.1/pkg/document/values_test.go 2022-04-25 21:01:27.000000000 +0200 @@ -9,6 +9,21 @@ "gopkg.in/yaml.v3" ) +func getSortedValuesTableRows(helmValues *yaml.Node, descriptions map[string]helm.ChartValueDescription) ([]valueRow, error) { + // Note: This getSortedValuesTableRows function was added as a shim when getSortedValuesTableRows + // was removed from the package. In the future it may make sense to rewrite the tests. + + document := &yaml.Node{Kind: yaml.DocumentNode, Content: []*yaml.Node{helmValues}} + valueRows, err := getUnsortedValueRows(document, descriptions) + if err != nil { + return nil, err + } + + sortValueRows(valueRows) + + return valueRows, nil +} + func parseYamlValues(yamlValues string) *yaml.Node { var chartValues yaml.Node err := yaml.Unmarshal([]byte(strings.TrimSpace(yamlValues)), &chartValues) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/helm-docs-1.8.1/pkg/helm/chart_info.go new/helm-docs-1.9.1/pkg/helm/chart_info.go --- old/helm-docs-1.8.1/pkg/helm/chart_info.go 2022-04-03 17:31:26.000000000 +0200 +++ new/helm-docs-1.9.1/pkg/helm/chart_info.go 2022-04-25 21:01:27.000000000 +0200 @@ -5,7 +5,7 @@ "fmt" "io/ioutil" "os" - "path" + "path/filepath" "regexp" "sort" "strings" @@ -93,7 +93,7 @@ } func parseChartFile(chartDirectory string) (ChartMeta, error) { - chartYamlPath := path.Join(chartDirectory, "Chart.yaml") + chartYamlPath := filepath.Join(chartDirectory, "Chart.yaml") chartMeta := ChartMeta{} yamlFileContents, err := getYamlFileContents(chartYamlPath) @@ -113,13 +113,13 @@ var requirementsPath string if apiVersion == "v1" { - requirementsPath = path.Join(chartDirectory, "requirements.yaml") + requirementsPath = filepath.Join(chartDirectory, "requirements.yaml") if _, err := os.Stat(requirementsPath); os.IsNotExist(err) { return ChartRequirements{Dependencies: []ChartRequirementsItem{}}, nil } } else { - requirementsPath = path.Join(chartDirectory, "Chart.yaml") + requirementsPath = filepath.Join(chartDirectory, "Chart.yaml") } chartRequirements := ChartRequirements{} @@ -142,7 +142,7 @@ } func parseChartValuesFile(chartDirectory string) (yaml.Node, error) { - valuesPath := path.Join(chartDirectory, viper.GetString("values-file")) + valuesPath := filepath.Join(chartDirectory, viper.GetString("values-file")) yamlFileContents, err := getYamlFileContents(valuesPath) var values yaml.Node @@ -155,7 +155,7 @@ } func parseChartValuesFileComments(chartDirectory string) (map[string]ChartValueDescription, error) { - valuesPath := path.Join(chartDirectory, viper.GetString("values-file")) + valuesPath := filepath.Join(chartDirectory, viper.GetString("values-file")) valuesFile, err := os.Open(valuesPath) if isErrorInReadingNecessaryFile(valuesPath, err) { ++++++ vendor.tar.gz ++++++
