Repository: roboll/helmfile
Pull request #1731 (2021-03-19 18:39:03)

(feat) Add chart & version to list cmd
Please squash.

Motivation:
I want to make a command to `helm pull` all charts to have a local version to debug.
```
for row in $(helm list --output json | jq -r '.[] | {chart: .chart, version: .version} | @base64' | uniq); do
	   chart=$(echo ${row} | base64 -d | jq -r '.chart');
	   version=$(echo ${row} | base64 -d | jq -r '.version');
	   echo "Downloading ${chart} ${version}";
	   helm pull ${chart} --version ${version} --untar --untardir debug/charts/${chart}/${version} || :;
done
```


Patch:
diff --git a/USERS.md b/USERS.md
index e6ad54c..6963279 100644
--- a/USERS.md
+++ b/USERS.md
@@ -28,4 +28,5 @@ information to this file.
 | [SettleMint](https://settlemint.com) | production | The SettleMint platform allows enterprises to spin up k8s clusters and deploy production grade blockchain networks and additional services. Helmfile is in charge of deploying these networks and services on demand out of the self service management ui. | Belgium, Singapore, UAE, India | October 2020 |
 | [AutoTrader (UK)](https://www.autotrader.co.uk) | production | We've used Helmfile for 2+ years to deploy 400+ services | UK | October 2020 |
 | [Trend Micro](https://www.trendmicro.com) | production | We manage 9 k8s clusters in a mono git repository with Helmfile | Taipei, Taiwan |  December 2019 |
+| [William Hill](https://www.williamhill.com) | production | We have standardised on Helmfile for managing both our application services and our Kubernetes platform components. | International |  March 2021 |
 <!-- TABLE_END -->
diff --git a/pkg/app/app.go b/pkg/app/app.go
index b935b7d..d1e043d 100644
--- a/pkg/app/app.go
+++ b/pkg/app/app.go
@@ -61,6 +61,8 @@ type HelmRelease struct {
 	Namespace string `json:"namespace"`
 	Enabled   bool   `json:"enabled"`
 	Labels    string `json:"labels"`
+	Chart     string `json:"chart"`
+	Version   string `json:"version"`
 }
 
 func New(conf ConfigProvider) *App {
@@ -509,6 +511,8 @@ func (a *App) ListReleases(c ListConfigProvider) error {
 					Namespace: r.Namespace,
 					Enabled:   installed,
 					Labels:    labels,
+					Chart:     r.Chart,
+					Version:   r.Version,
 				})
 			}
 		})
@@ -1027,7 +1031,7 @@ func (a *App) findDesiredStateFiles(specifiedPath string, opts LoadOpts) ([]stri
 		} else if defaultFile != "" {
 			return []string{defaultFile}, nil
 		} else {
-			return []string{}, fmt.Errorf("no state file found. It must be named %s/*.{yaml,yml}, %s, or %s, or otherwise specified with the --file flag", DefaultHelmfileDirectory, DefaultHelmfile, DeprecatedHelmfile)
+			return []string{}, fmt.Errorf("no state file found. It must be named %s/*.{yaml,yml} or %s, otherwise specified with the --file flag", DefaultHelmfileDirectory, DefaultHelmfile)
 		}
 	}
 
diff --git a/pkg/app/formatters.go b/pkg/app/formatters.go
index c60c6c6..b285a1f 100644
--- a/pkg/app/formatters.go
+++ b/pkg/app/formatters.go
@@ -9,10 +9,10 @@ import (
 
 func FormatAsTable(releases []*HelmRelease) error {
 	table := uitable.New()
-	table.AddRow("NAME", "NAMESPACE", "ENABLED", "LABELS")
+	table.AddRow("NAME", "NAMESPACE", "ENABLED", "LABELS", "CHART", "VERSION")
 
 	for _, r := range releases {
-		table.AddRow(r.Name, r.Namespace, fmt.Sprintf("%t", r.Enabled), r.Labels)
+		table.AddRow(r.Name, r.Namespace, fmt.Sprintf("%t", r.Enabled), r.Labels, r.Chart, r.Version)
 	}
 
 	fmt.Println(table.String())


Test patch:
diff --git a/pkg/app/app_test.go b/pkg/app/app_test.go
index 110b9c2..5935cf9 100644
--- a/pkg/app/app_test.go
+++ b/pkg/app/app_test.go
@@ -4519,11 +4519,11 @@ releases:
 		assert.NilError(t, err)
 	})
 
-	expected := `NAME      	NAMESPACE	ENABLED	LABELS                    
-myrelease1	         	false  	common:label,id:myrelease1
-myrelease2	         	true   	common:label              
-myrelease3	         	true   	                          
-myrelease4	         	true   	id:myrelease1             
+	expected := `NAME      	NAMESPACE	ENABLED	LABELS                    	CHART   	VERSION
+myrelease1	         	false  	common:label,id:myrelease1	mychart1	       
+myrelease2	         	true   	common:label              	mychart1	       
+myrelease3	         	true   	                          	mychart1	       
+myrelease4	         	true   	id:myrelease1             	mychart1	       
 `
 	assert.Equal(t, expected, out)
 }
@@ -4576,7 +4576,7 @@ releases:
 		assert.NilError(t, err)
 	})
 
-	expected := `[{"name":"myrelease1","namespace":"","enabled":false,"labels":"id:myrelease1"},{"name":"myrelease2","namespace":"","enabled":true,"labels":""},{"name":"myrelease3","namespace":"","enabled":true,"labels":""},{"name":"myrelease4","namespace":"","enabled":true,"labels":"id:myrelease1"}]
+	expected := `[{"name":"myrelease1","namespace":"","enabled":false,"labels":"id:myrelease1","chart":"mychart1","version":""},{"name":"myrelease2","namespace":"","enabled":true,"labels":"","chart":"mychart1","version":""},{"name":"myrelease3","namespace":"","enabled":true,"labels":"","chart":"mychart1","version":""},{"name":"myrelease4","namespace":"","enabled":true,"labels":"id:myrelease1","chart":"mychart1","version":""}]
 `
 	assert.Equal(t, expected, out)
 }