Skip to content

Commit a093cc2

Browse files
author
Saurabh Sharma
committed
Allow chart versioning
We renaming the existing version flag and re-use the existing helm version flag. This allow helm-diff to seamlessly work with other helm tooling such as helmfile
1 parent 1d3b781 commit a093cc2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

main.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ var Version = "HEAD"
2626
type diffCmd struct {
2727
release string
2828
chart string
29+
chartVersion string
2930
client helm.Interface
3031
valueFiles valueFiles
3132
values []string
@@ -42,8 +43,8 @@ func main() {
4243
Short: "Show manifest differences",
4344
Long: globalUsage,
4445
RunE: func(cmd *cobra.Command, args []string) error {
45-
if v, _ := cmd.Flags().GetBool("version"); v {
46-
fmt.Println(Version)
46+
if v, _ := cmd.Flags().GetBool("diff-version"); v {
47+
fmt.Println("Version", Version)
4748
return nil
4849
}
4950

@@ -69,9 +70,10 @@ func main() {
6970
}
7071

7172
f := cmd.Flags()
72-
f.BoolP("version", "v", false, "show version")
73+
f.BoolP("diff-version", "", false, "show diff version")
7374
f.BoolP("suppress-secrets", "q", false, "suppress secrets in the output")
7475
f.Bool("no-color", false, "remove colors from the output")
76+
f.StringVarP(&diff.chartVersion, "version", "v", "", "specify the chart version")
7577
f.VarP(&diff.valueFiles, "values", "f", "specify values in a YAML file (can specify multiple)")
7678
f.StringArrayVar(&diff.values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)")
7779
f.BoolVar(&diff.reuseValues, "reuse-values", false, "reuse the last release's values and merge in any new values")
@@ -84,7 +86,7 @@ func main() {
8486
}
8587

8688
func (d *diffCmd) run() error {
87-
chartPath, err := locateChartPath(d.chart, "", false, "")
89+
chartPath, err := locateChartPath(d.chart, d.chartVersion, false, "")
8890
if err != nil {
8991
return err
9092
}

0 commit comments

Comments
 (0)