forked from norwoodj/helm-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New flag --document-dependency-values
Adds new CLI flag -u/--document-dependency-values. The flag is disabled by default, so it should not affect existing behavior. **This change also includes two drive-by bug fixes!** * Replace usages of `path.Join` with `filepath.Join` when joining directories, for better cross-platform support. * Fix a `FileSortOrder` sorting bug in `model.go` where it would not sort by line due to an incorrect `valuesTableRows[i].LineNumber < valuesTableRows[i].LineNumber` comparison operation.
- Loading branch information
Showing
18 changed files
with
450 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# umbrella | ||
|
||
![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) | ||
|
||
A chart demonstrating that values documentation from child charts are aggregated on the parent chart. | ||
|
||
## Requirements | ||
|
||
| Repository | Name | Version | | ||
|------------|------|---------| | ||
| | sub-a | 0.1.0 | | ||
| | sub-b | 0.1.0 | | ||
|
||
## Values | ||
|
||
| Key | Type | Default | Description | | ||
|-----|------|---------|-------------| | ||
| global.myGlobalKey | string | `"my-global-value"` | A global key | | ||
| 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 | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: v2 | ||
name: sub-a | ||
description: A sub-chart. | ||
version: "0.1.0" | ||
type: application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# sub-a | ||
|
||
![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) | ||
|
||
A sub-chart. | ||
|
||
## Values | ||
|
||
| Key | Type | Default | Description | | ||
|-----|------|---------|-------------| | ||
| global.myGlobalKey | string | `"my-global-value"` | A global key | | ||
| mySubKeyA | string | `"my-sub-value-a"` | Value for sub-chart A | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
global: | ||
# -- A global key | ||
myGlobalKey: my-global-value | ||
|
||
# -- Value for sub-chart A | ||
mySubKeyA: my-sub-value-a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
apiVersion: v2 | ||
name: sub-b | ||
description: A sub-chart. | ||
version: "0.1.0" | ||
type: application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# sub-b | ||
|
||
![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) | ||
|
||
A sub-chart. | ||
|
||
## 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 | | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
global: | ||
# -- A global key | ||
myGlobalKey: my-global-value | ||
|
||
# -- Value for sub-chart B | ||
mySubKeyB: my-sub-value-b |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
global: | ||
# -- A global key | ||
myGlobalKey: my-global-value | ||
|
||
# -- A parent key | ||
myParentKey: my-parent-value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package document | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"path/filepath" | ||
|
||
"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 { | ||
if dep.Repository != "" { | ||
return nil, errors.New("remote dependencies are not yet supported") | ||
} | ||
|
||
searchPath := filepath.Join(root.ChartDirectory, "charts", dep.Name) | ||
depInfo, ok := allChartInfoByChartPath[searchPath] | ||
if !ok { | ||
return nil, fmt.Errorf("dependency with path %q was not found", searchPath) | ||
} | ||
|
||
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 | ||
} |
Oops, something went wrong.