evanlucas / fish-kubectl-completions

kubectl completions for fish shell
MIT License
576 stars 42 forks source link

Check for CRDs before listing them #27

Closed femnad closed 3 years ago

femnad commented 3 years ago

Sub-resource completion seems to error with the following output when there are no CRDs defined:

error: error executing jsonpath "{range .items[*]}{.spec.names.plural}{\"\\n\"}{.spec.names.singular}{\"\\n\"}{range .spec.names.shortNames[]}{@}{\"\\n\"}{end}{end}": Error executing template: not in range, nothing to end. Printing more information for debugging the template:
        template was:
                {range .items[*]}{.spec.names.plural}{"\n"}{.spec.names.singular}{"\n"}{range .spec.names.shortNames[]}{@}{"\n"}{end}{end}
        object given to jsonpath engine was:
                map[string]interface {}{"apiVersion":"v1", "items":[]interface {}{}, "kind":"List", "metadata":map[string]interface {}{"resourceVersion":"", "selfLink":""}}

This patch checks if there are CRDs defined and if not, returns early from __fish_kubectl_actually_get_crds