Skip to content

Commit 8d99cc4

Browse files
authored
Add flag to override appVersion (#87)
1 parent 985cc78 commit 8d99cc4

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

cmd/helmpush/main.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import (
3232
type (
3333
pushCmd struct {
3434
chartName string
35+
appVersion string
3536
chartVersion string
3637
repoName string
3738
username string
@@ -110,6 +111,7 @@ func newPushCmd(args []string) *cobra.Command {
110111
}
111112
f := cmd.Flags()
112113
f.StringVarP(&p.chartVersion, "version", "v", "", "Override chart version pre-push")
114+
f.StringVarP(&p.appVersion, "app-version", "a", "", "Override app version pre-push")
113115
f.StringVarP(&p.username, "username", "u", "", "Override HTTP basic auth username [$HELM_REPO_USERNAME]")
114116
f.StringVarP(&p.password, "password", "p", "", "Override HTTP basic auth password [$HELM_REPO_PASSWORD]")
115117
f.StringVarP(&p.accessToken, "access-token", "", "", "Send token in Authorization header [$HELM_REPO_ACCESS_TOKEN]")
@@ -262,6 +264,11 @@ func (p *pushCmd) push() error {
262264
chart.SetVersion(p.chartVersion)
263265
}
264266

267+
// app version override
268+
if p.appVersion != "" {
269+
chart.SetAppVersion(p.appVersion)
270+
}
271+
265272
// username/password override(s)
266273
username := repo.Config.Username
267274
password := repo.Config.Password

pkg/helm/chart.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ func (c *Chart) SetVersion(version string) {
1818
c.Metadata.Version = version
1919
}
2020

21+
// SetAppVersion overrides the app version
22+
func (c *Chart) SetAppVersion(appVersion string) {
23+
if c.V2 != nil {
24+
c.V2.Metadata.AppVersion = appVersion
25+
} else {
26+
c.V3.Metadata.AppVersion = appVersion
27+
}
28+
}
29+
2130
// GetChartByName returns a chart by "name", which can be
2231
// either a directory or .tgz package
2332
func GetChartByName(name string) (*Chart, error) {

0 commit comments

Comments
 (0)