Skip to content

[Feat]: Support version ranges in dependency matrix by reading Chart.lock #285

@ominiet

Description

@ominiet

General Summary

The helm doc tool should represent exact versions of dependencies in addition to the raw dependency string value present in Chart.yaml for clarity

Is your feature request related to a problem? Please describe and/or link to a bug issue.

N/A

Expected Behavior

Add in Chart.lock's metadata reading to retrieve an exact version packaged with a chart when present. It seems this could be roughly similar to the existing pkg/helm/chart_info.go file's parseChartRequirementsFile()

Once read, the requirements table could render into something like:

| Repository | Name | Version | Locked Version |
|------------|------|---------|----------------|
| @stable | nginx-ingress | ~0.22.1 | 0.22.6 |

Current Behavior

Currently, when helm docs reads a chart's metadata, it appears to do so only by reading Chart.yaml. It is capable of rendering a requirements section that looks like the following:

## Requirements

| Repository | Name | Version |
|------------|------|---------|
| @stable | nginx-ingress | 0.22.1 |

This is appropriate when exact versions are used in a helm chart's definition. However, helm supports version ranges, and locking a particular version by generating a lock file using helm dependency update. In those cases, we might see a version that looks like ~0.22.1 which represents a statement like 0.22.1 <= x < 0.23.0. Therefore, a dependency packaged with the chart could be a number of different versions.

Possible Solution

Add a parseChartLockFile function to ParseChartInformation

func ParseChartInformation(chartDirectory string, documentationParsingConfig ChartValuesDocumentationParsingConfig) (ChartDocumentationInfo, error) {
	var chartDocInfo ChartDocumentationInfo
	var err error

	chartDocInfo.ChartDirectory = chartDirectory
	chartDocInfo.ChartMeta, err = parseChartFile(chartDirectory)
	if err != nil {
		return chartDocInfo, err
	}

	chartDocInfo.ChartRequirements, err = parseChartRequirementsFile(chartDirectory, chartDocInfo.ApiVersion)
	if err != nil {
		return chartDocInfo, err
	}

        chartDocInfo.ChartRequirements, err = parseChartLockFile(chartDirectory)
        if err != nil {
          return chartDocInfo, err
        }

	chartValues, err := parseChartValuesFile(chartDirectory)
	if err != nil {
		return chartDocInfo, err
	}

	chartDocInfo.ChartValues = &chartValues
	chartDocInfo.ChartValuesDescriptions, err = parseChartValuesFileComments(chartDirectory, &chartValues, documentationParsingConfig)
	if err != nil {
		return chartDocInfo, err
	}

	return chartDocInfo, nil
}

Alternatives you've considered

It seems that the helm-docs tool does not read the Chart.lock file at all. I am not sure there is another alternative

Further Information

No response

Metadata

Metadata

Labels

enhancementNew feature or requesttriageIssues that need to be triaged and categorized

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions