From 420567d5320e878e3c8a453dec1af926e0ad4fa1 Mon Sep 17 00:00:00 2001 From: Thomas Vendetta Date: Tue, 2 Apr 2019 10:14:09 -0400 Subject: [PATCH] Add `--print-computed-version` flag to write version to STDOUT. Closes #2 --- README.md | 1 + cmd/root.go | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index c6b90d7..3d92cce 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/cmd/root.go b/cmd/root.go index f272805..d29aea7 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -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{ @@ -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) @@ -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.