diff --git a/cmd/helmpush/main.go b/cmd/helmpush/main.go index 40801ab..1864180 100644 --- a/cmd/helmpush/main.go +++ b/cmd/helmpush/main.go @@ -32,6 +32,7 @@ import ( type ( pushCmd struct { chartName string + appVersion string chartVersion string repoName string username string @@ -110,6 +111,7 @@ func newPushCmd(args []string) *cobra.Command { } f := cmd.Flags() f.StringVarP(&p.chartVersion, "version", "v", "", "Override chart version pre-push") + f.StringVarP(&p.appVersion, "app-version", "a", "", "Override app version pre-push") f.StringVarP(&p.username, "username", "u", "", "Override HTTP basic auth username [$HELM_REPO_USERNAME]") f.StringVarP(&p.password, "password", "p", "", "Override HTTP basic auth password [$HELM_REPO_PASSWORD]") f.StringVarP(&p.accessToken, "access-token", "", "", "Send token in Authorization header [$HELM_REPO_ACCESS_TOKEN]") @@ -262,6 +264,11 @@ func (p *pushCmd) push() error { chart.SetVersion(p.chartVersion) } + // app version override + if p.appVersion != "" { + chart.SetAppVersion(p.appVersion) + } + // username/password override(s) username := repo.Config.Username password := repo.Config.Password diff --git a/pkg/helm/chart.go b/pkg/helm/chart.go index 847dd29..2c406de 100644 --- a/pkg/helm/chart.go +++ b/pkg/helm/chart.go @@ -18,6 +18,15 @@ func (c *Chart) SetVersion(version string) { c.Metadata.Version = version } +// SetAppVersion overrides the app version +func (c *Chart) SetAppVersion(appVersion string) { + if c.V2 != nil { + c.V2.Metadata.AppVersion = appVersion + } else { + c.V3.Metadata.AppVersion = appVersion + } +} + // GetChartByName returns a chart by "name", which can be // either a directory or .tgz package func GetChartByName(name string) (*Chart, error) {