Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ominiet opened this issue Feb 11, 2025 · 0 comments
Open
Assignees
Labels
enhancement New feature or request triage Issues that need to be triaged and categorized

Comments

@ominiet
Copy link

ominiet commented Feb 11, 2025

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

@ominiet ominiet added enhancement New feature or request triage Issues that need to be triaged and categorized labels Feb 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage Issues that need to be triaged and categorized
Projects
None yet
Development

No branches or pull requests

3 participants