feat(comp): Add descriptions for --version comp

Ref: HIP 0008

When completing a version, extra information will be shown for
shells that support completions (fish, zsh).  For example:

$ helm upgrade nginx stable/grafana --version <TAB>
0.8.4   -- Created: March 30, 2018
0.8.5   -- App: 5.0.4, Created: April 10, 2018
1.0.0   -- App: 5.0.4, Created: April 11, 2018 (deprecated)
1.10.0  -- App: 5.1.2, Created: June 1, 2018

Signed-off-by: Marc Khouzam <marc.khouzam@montreal.ca>
pull/9243/head
Marc Khouzam 4 years ago
parent 9856f056d4
commit 430709170a

@ -150,7 +150,21 @@ func compVersionFlag(chartRef string, toComplete string) ([]string, cobra.ShellC
for _, details := range indexFile.Entries[chartName] { for _, details := range indexFile.Entries[chartName] {
version := details.Metadata.Version version := details.Metadata.Version
if strings.HasPrefix(version, toComplete) { if strings.HasPrefix(version, toComplete) {
versions = append(versions, version) appVersion := details.Metadata.AppVersion
appVersionDesc := ""
if appVersion != "" {
appVersionDesc = fmt.Sprintf("App: %s, ", appVersion)
}
created := details.Created.Format("January 2, 2006")
createdDesc := ""
if created != "" {
createdDesc = fmt.Sprintf("Created: %s ", created)
}
deprecated := ""
if details.Metadata.Deprecated {
deprecated = "(deprecated)"
}
versions = append(versions, fmt.Sprintf("%s\t%s%s%s", version, appVersionDesc, createdDesc, deprecated))
} }
} }
} }

@ -4,6 +4,8 @@ entries:
- name: alpine - name: alpine
url: https://charts.helm.sh/stable/alpine-0.1.0.tgz url: https://charts.helm.sh/stable/alpine-0.1.0.tgz
checksum: 0e6661f193211d7a5206918d42f5c2a9470b737d checksum: 0e6661f193211d7a5206918d42f5c2a9470b737d
created: "2018-06-27T10:00:18.230700509Z"
deprecated: true
home: https://helm.sh/helm home: https://helm.sh/helm
sources: sources:
- https://github.com/helm/helm - https://github.com/helm/helm
@ -17,6 +19,7 @@ entries:
- name: alpine - name: alpine
url: https://charts.helm.sh/stable/alpine-0.2.0.tgz url: https://charts.helm.sh/stable/alpine-0.2.0.tgz
checksum: 0e6661f193211d7a5206918d42f5c2a9470b737d checksum: 0e6661f193211d7a5206918d42f5c2a9470b737d
created: "2018-07-09T11:34:37.797864902Z"
home: https://helm.sh/helm home: https://helm.sh/helm
sources: sources:
- https://github.com/helm/helm - https://github.com/helm/helm
@ -30,6 +33,7 @@ entries:
- name: alpine - name: alpine
url: https://charts.helm.sh/stable/alpine-0.3.0-rc.1.tgz url: https://charts.helm.sh/stable/alpine-0.3.0-rc.1.tgz
checksum: 0e6661f193211d7a5206918d42f5c2a9470b737d checksum: 0e6661f193211d7a5206918d42f5c2a9470b737d
created: "2020-11-12T08:44:58.872726222Z"
home: https://helm.sh/helm home: https://helm.sh/helm
sources: sources:
- https://github.com/helm/helm - https://github.com/helm/helm
@ -44,6 +48,7 @@ entries:
- name: mariadb - name: mariadb
url: https://charts.helm.sh/stable/mariadb-0.3.0.tgz url: https://charts.helm.sh/stable/mariadb-0.3.0.tgz
checksum: 65229f6de44a2be9f215d11dbff311673fc8ba56 checksum: 65229f6de44a2be9f215d11dbff311673fc8ba56
created: "2018-04-23T08:20:27.160959131Z"
home: https://mariadb.org home: https://mariadb.org
sources: sources:
- https://github.com/bitnami/bitnami-docker-mariadb - https://github.com/bitnami/bitnami-docker-mariadb

@ -1,5 +1,5 @@
0.3.0-rc.1 0.3.0-rc.1 App: 3.0.0, Created: November 12, 2020
0.2.0 0.2.0 App: 2.3.4, Created: July 9, 2018
0.1.0 0.1.0 App: 1.2.3, Created: June 27, 2018 (deprecated)
:4 :4
Completion ended with directive: ShellCompDirectiveNoFileComp Completion ended with directive: ShellCompDirectiveNoFileComp

Loading…
Cancel
Save