diff --git a/pkg/helm/export.go b/pkg/helm/export.go index d1be8932..d12f9d85 100644 --- a/pkg/helm/export.go +++ b/pkg/helm/export.go @@ -2,6 +2,7 @@ package helm import ( "fmt" + "math" "os" "path/filepath" @@ -13,6 +14,15 @@ import ( helmLoader "helm.sh/helm/v3/pkg/chart/loader" ) +const ( + NumPatchDigits = 2 +) + +var ( + PatchNumMultiplier = uint64(math.Pow10(2)) + MaxPatchNum = PatchNumMultiplier - 1 +) + // ExportHelmChart creates a Helm chart archive and an unarchived Helm chart at RepositoryAssetDirpath and RepositoryChartDirPath // helmChartPath is a relative path (rooted at the package level) that contains the chart. // packageAssetsPath is a relative path (rooted at the repository level) where the generated chart archive will be placed @@ -32,10 +42,10 @@ func ExportHelmChart(rootFs, fs billy.Filesystem, helmChartPath string, packageV return fmt.Errorf("Cannot parse original chart version %s as valid semver", chart.Metadata.Version) } // Add packageVersion as string, preventing errors due to leading 0s - if packageVersion >= 999 { - return fmt.Errorf("Maximum number of packageVersions is 999, found %d", packageVersion) + if uint64(packageVersion) >= MaxPatchNum { + return fmt.Errorf("Maximum number of packageVersions is %d, found %d", MaxPatchNum, packageVersion) } - chartVersionSemver.Patch = 1000*chartVersionSemver.Patch + uint64(packageVersion) + chartVersionSemver.Patch = PatchNumMultiplier*chartVersionSemver.Patch + uint64(packageVersion) if len(upstreamChartVersion) > 0 { // Add buildMetadataFlag for forked charts chartVersionSemver.Build = append(chartVersionSemver.Build, fmt.Sprintf("up%s", upstreamChartVersion))