Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flag to override appVersion #87

Merged
merged 1 commit into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -25,6 +25,15 @@ func (c *Chart) SetVersion(version string) {
}
}

// 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