Skip to content

v3: fix(completion): --flag=val breaks zsh completion - #6389

Merged
mattfarina merged 1 commit into
helm:dev-v3from
VilledeMontreal:fix-v3/zshFlagBug
Sep 20, 2019
Merged

mattfarina merged 1 commit into
helm:dev-v3from
VilledeMontreal:fix-v3/zshFlagBug

Conversation

@marckhouzam

@marckhouzam marckhouzam commented Sep 8, 2019 •

Copy link
Copy Markdown
Member

What this PR does / why we need it:

This is a bug I ran into when working on Helm completion. I was surprised that it didn't happen when I was using kubectl, so I investigated and found a PR that fixed this bug in kubectl:
kubernetes/kubernetes#48553

I duplicated the code in this commit which:

Removes __helm_declare, which is safe to do since declare -F is already replaced by whence -w by __helm_convert_bash_to_zsh().

The problem was that calling "declare" from inside a function scopes the declaration to that function only. So "declare" should not be called through __helm_declare() but instead directly.

To reproduce:
1- setup helm completion in zsh
2- helm --kubeconfig=$HOME/.kube/config statu<TAB>

you will get the error:
__helm_handle_flag:27: bad math expression: operand expected at end of string

Co-authored-by: Kazuki Suda [email protected]
Signed-off-by: Marc Khouzam [email protected]

Special notes for your reviewer:

I'm working on adding dynamic completion for flags and this fix is required for completion to work with the --kube-context flag.

The acceptance-testing repo has a test for this bug (which is currently marked as a known failure to allow the tests to show as passed).
Once this PR is applied, the tests will pass (but be marked as failed due to an Unexpected Success. helm/acceptance-testing#35 is ready to update the test as expected to pass).

This is a bug I ran into when working on Helm completion.
I was surprised that it didn't happen when I was using
kubectl, so I investigated and found a PR that fixed this
bug in kubectl:
kubernetes/kubernetes#48553

I duplicated the code in this commit which:

Removes __helm_declare, which is safe to do since
`declare -F` is already replaced to `whence -w` by
__helm_convert_bash_to_zsh().

The problem was that calling "declare" from inside a function
scopes the declaration to that function only.  So "declare"
should not be called through __helm_declare() but instead
directly.

To reproduce:
1- setup helm completion in zsh
2- helm --kubeconfig=$HOME/.kube/config statu<TAB>

you will get the error:
__helm_handle_flag:27: bad math expression: operand expected at end of string

Co-authored-by: Kazuki Suda <[email protected]>
Signed-off-by: Marc Khouzam <[email protected]>
@helm-bot helm-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Sep 8, 2019
@mattfarina
mattfarina merged commit 251a423 into helm:dev-v3 Sep 20, 2019
@marckhouzam
marckhouzam deleted the fix-v3/zshFlagBug branch September 20, 2019 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants