Skip to content

Commit

Permalink
Add flag to override appVersion (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
vadasambar authored Jan 11, 2021
1 parent 985cc78 commit 8d99cc4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/helmpush/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
type (
pushCmd struct {
chartName string
appVersion string
chartVersion string
repoName string
username string
Expand Down Expand Up @@ -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]")
Expand Down Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions pkg/helm/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8d99cc4

Please sign in to comment.