Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HIP for descriptions for custom completions #161

Merged
merged 2 commits into from
Feb 18, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
167 changes: 167 additions & 0 deletions hips/hip-9999.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
---
hip: 9999
title: "Add descriptions to custom completions"
authors: [ "Marc Khouzam <marc.khouzam@montreal.ca>" ]
created: "2020-11-14"
type: "feature"
status: "draft"
---

## Abstract

Provide (optional) descriptions for helm's custom completions.

The goal is to help users be more efficient by providing useful information
when doing auto-completion.

## Motivation

Helm currently supports auto-completion for the following shells: `bash`, `zsh`,
`fish`. Both the `zsh` and `fish` shells support descriptions for completions.

For example, in the case of `zsh`:
```
$ helm s<TAB>
search -- search for a keyword in charts
show -- show information of a chart
status -- display the status of the named release
```

Cobra automatically provides completion descriptions when completing commands
marckhouzam marked this conversation as resolved.
Show resolved Hide resolved
and flags, based on the specified usage information. However, custom
completions that are provided by helm currently don't include any descriptions.
For example, when completing `helm status` it is helm that provides the list of
releases, but this list does not include descriptions.
```
$ helm status n<TAB>
nginx nginx-ingress
```

Augmenting helm's custom completions with descriptions allows providing
additional information to help users make their selection from the list of
completions.

## Rationale

The completions for some helm arguments do not always provide sufficient
information for a user to know which value to choose. For instance, the
name of a release is not always informative enough for the user to know
which one to select. For example:
```
$ helm upgrade ngin<TAB>
nginx nginx2
```
Clearly, in this case, the user needs to know the details of each release
in advance as the difference between completion choices is not very helpful.

## Specification

Here are proposed descriptions for the different types of custom completions:
* chart names (for 'install', 'pull', 'show *', 'template', 'upgrade')
* None?

The obvious choice would be to use the description of the chart provided
in the index file of the repository. However, in practice, this description
is often much too long to be usable for completions.

Is there other *useful* information to show? If not, it may be more useful
not to add a description in this case to allow to fit more chart completion
choices on the screen.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I can agree with this point. The description field would be a great first choice. However, I believe there is no "hard" limit on the number of accepted characters in a description field.

What if the description was short-wrapped with ellipsis similar to what we do with helm search repo?

><> helm search repo wordpress
NAME                    CHART VERSION   APP VERSION     DESCRIPTION
stable/wordpress        9.0.3           5.3.2           DEPRECATED Web publishing platform for building...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, the shell does the ellipsis automatically, so I'll give it a try in the reference implementation and we can discuss how it feels during that PR review. I'll update the HIP to propose using the description for now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, fish shell does an ellipsis:

bitnami/cassandra  (Apache Cassandra is a free and open-source distributed database manage…)
bitnami/common  (A Library Helm Chart for grouping common logic between bitnami charts. Th…)
bitnami/consul  (Highly available and distributed service discovery and key-value store de…)
bitnami/contour                                  (Contour Ingress controller for Kubernetes)

while zsh simply truncates:

bitnami/cassandra  -- Apache Cassandra is a free and open-source distributed database ma
bitnami/common     -- A Library Helm Chart for grouping common logic between bitnami cha
bitnami/consul     -- Highly available and distributed service discovery and key-value s
bitnami/contour    -- Contour Ingress controller for Kubernetes

For some chart descriptions, the amount of space available on a single line is not sufficient to convey complete information, as can be seen in the example above, especially for consul.

```
$ helm install myrelease bitnami/c<TAB>
bitnami/cassandra bitnami/common bitnami/consul bitnami/contour
```
* chart version (for '--version')
* App: \<app version>, Created: \<date>
```
$ helm pull bitnami/nginx --version 7.1.<TAB>
7.1.0 -- App: 1.19.2, Created: September 24, 2020
7.1.1 -- App: 1.19.3, Created: September 29, 2020
7.1.2 -- App: 1.19.3, Created: October 2, 2020
```
* kubernetes context (for '--kube-context')
* \<kube cluster name>
```
$ helm --kube-context d<TAB>
default -- k3d-k3s-default
dev -- development
```
* helm environment variables (for 'env')
* \<value> (\<description of variable>)
```
$ helm env HELM_RE<TAB>
HELM_REGISTRY_CONFIG -- /me/Library/Preferences/helm/registry.json (Path to the registry configuration file)
HELM_REPOSITORY_CACHE -- /me/Library/Caches/helm/repository (Path to the file containing cached repository indexes)
HELM_REPOSITORY_CONFIG -- /me/Library/Preferences/helm/repositories.yaml (Path to the file containing repository names and URLs)
```
* plugin names (for 'plugin uninstall', 'plugin update')
* \<plugin description>
```
$ helm plugin uninstall <TAB>
2to3 -- migrate and cleanup Helm v2 configuration and releases in-place to Helm v3
fullstatus -- provide status of resources part of the release
```
* release names (for 'get *', 'history', 'rollback', 'status', 'test', 'upgrade')
* \<chart name>-\<chart version> -> \<release status>
```
$ helm status <TAB>
mynginx -- nginx-6.0.5 -> superseded
nginx-ingress -- nginx-ingress-controller-5.4.4 -> deployed
```
* release revisions (for 'rollback', '--revision')
* App: \<app version>, Chart: \<chart name>-\<chart version>
```
$ helm rollback nginx-ingress <TAB>
1 -- App: 0.34.1, Chart: nginx-ingress-controller-5.4.4
2 -- App: 0.40.2, Chart: nginx-ingress-controller-5.6.10
```
* repo names (for 'repo remove' and completion of chart names)
* \<repo URL>
```
$ helm repo remove <TAB>
bitnami -- https://charts.bitnami.com/bitnami
center -- https://repo.chartcenter.io
stable -- https://charts.helm.sh/stable
```
* output formats (for '--output', '-o')
* \<format description>
```
$ helm status -o <TAB>
json -- Output result in JSON format
table -- Output result in human-readable format
yaml -- Output result in YAML format
```

Note that descriptions can be turned off by the user when generating the shell
completion script using the `--no-descriptions` flag.

## Backwards compatibility

Not applicable to shell auto-completion. In fact, this allows us to implement
some descriptions and still be able to modify them later if different ones are
requested.

## Security implications

None

## How to teach this

The new descriptions will automatically appear when using auto-completion, so no
special effort needs to be made to teach this new feature.

## Reference implementation

A PR will be opened to implement the proposed specification for descriptions of
custom completions.

## Open issues

None.

It is worth clarifying that the bash shell does not support descriptions for
auto-completion, so this feature will not apply to bash. That being said, there
is a [PR open on the Cobra project][cobra pr] that adds descriptions for bash
completions.

[cobra pr]: https://github.com/spf13/cobra/pull/1146