Skip to content

Commit

Permalink
Add --print-computed-version flag to write version to STDOUT.
Browse files Browse the repository at this point in the history
Closes #2
  • Loading branch information
Thomas Vendetta authored and sstarcher committed Apr 2, 2019
1 parent cb3c538 commit 420567d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ You can install a specific release version:

* helm release CHART - Would determine the next tag for the chart and update the Chart.yaml
* helm release CHART -t 12345 - Would update Chart.yaml and modify values.yaml images.tag to equal 12345
* helm release CHART --print-computed-version - Would determine the next tag and print it to STDOUT

## Release Logic

Expand Down
8 changes: 8 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
var cfgFile string
var tag string
var tagPath string
var printComputedVersion bool

// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Expand All @@ -37,6 +38,12 @@ var rootCmd = &cobra.Command{
if err != nil {
return err
}

if printComputedVersion {
_, err = os.Stdout.WriteString(*version)
return err
}

log.Infof("updating the Chart.yaml to version %s", *version)

chart.UpdateChartVersion(*version)
Expand Down Expand Up @@ -73,6 +80,7 @@ func init() {
// when this action is called directly.
rootCmd.Flags().StringVarP(&tag, "tag", "t", "", "Sets the docker image tag in values.yaml")
rootCmd.Flags().StringVar(&tagPath, "path", helm.DefaultTagPath, "Sets the path to the image tag to modify in values.yaml")
rootCmd.Flags().BoolVar(&printComputedVersion, "print-computed-version", false, "Print the computed version string to stdout")
}

// initConfig reads in config file and ENV variables if set.
Expand Down

0 comments on commit 420567d

Please sign in to comment.