Skip to content

Commit

Permalink
Switch to 2 digit patchNum
Browse files Browse the repository at this point in the history
  • Loading branch information
Arvind Iyengar committed May 14, 2021
1 parent 5e9498f commit 44b051e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions pkg/helm/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package helm

import (
"fmt"
"math"
"os"
"path/filepath"

Expand All @@ -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
Expand All @@ -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))
Expand Down

0 comments on commit 44b051e

Please sign in to comment.