-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow setting the prerelease and metadata version
- Loading branch information
Mehdi BEN ABDALLAH
committed
Feb 28, 2018
1 parent
856bcbd
commit 4c217e5
Showing
5 changed files
with
108 additions
and
46 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,23 @@ | ||
package chartfile | ||
|
||
import ( | ||
"path/filepath" | ||
|
||
"k8s.io/helm/pkg/chartutil" | ||
"k8s.io/helm/pkg/proto/hapi/chart" | ||
) | ||
|
||
// Save a chart's manifest file | ||
func Save(cm *chart.Metadata, chartDir string) error { | ||
return chartutil.SaveChartfile(Path(chartDir), cm) | ||
} | ||
|
||
// Path of a chart's manifest file | ||
func Path(chartDir string) string { | ||
return filepath.Join(chartDir, "Chart.yaml") | ||
} | ||
|
||
// Load a chart's manifest file | ||
func Load(chartDir string) (*chart.Metadata, error) { | ||
return chartutil.LoadChartfile(Path(chartDir)) | ||
} |
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,55 @@ | ||
package version | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/Masterminds/semver" | ||
) | ||
|
||
// Increment a version's semver segment | ||
func Increment(version string, segment string) (string, error) { | ||
v1, err := semver.NewVersion(version) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
var v2 semver.Version | ||
switch segment { | ||
case "patch": | ||
v2 = v1.IncPatch() | ||
case "minor": | ||
v2 = v1.IncMinor() | ||
case "major": | ||
v2 = v1.IncMajor() | ||
default: | ||
return "", fmt.Errorf("Unknown version segment %s", segment) | ||
} | ||
|
||
return v2.String(), nil | ||
} | ||
|
||
// Assemble a semver version from its parts | ||
func Assemble(version string, prerelease string, metadata string) (string, error) { | ||
v, err := semver.NewVersion(version) | ||
if err != nil { | ||
return "", err | ||
} | ||
|
||
if prerelease != "" { | ||
withPrerelease, err := v.SetPrerelease(prerelease) | ||
if err != nil { | ||
return "", err | ||
} | ||
v = &withPrerelease | ||
} | ||
|
||
if metadata != "" { | ||
withMetadata, err := v.SetMetadata(metadata) | ||
if err != nil { | ||
return "", err | ||
} | ||
v = &withMetadata | ||
} | ||
|
||
return v.String(), nil | ||
} |
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