Repository: knative/client (go)

Issue:
Add missing completion support for fish and PowerShell shells
### Feature request

CLI completion support for the Bash and ZSH shell is provided using the underlying [spf13/cobra](https://github.com/spf13/cobra/) library.  Cobra additionally supports fish and PowerShell completion support out of the box, see: [Generating shell completions](https://github.com/spf13/cobra/blob/main/site/content/completions/_index.md)

### Use case

Other than providing the same discoverability and convenience for fish and PowerShell users it will bring the  `kn` client in line with other plugins (e.g. quickstart) that have chosen to enable completion support for all 4 supported shells.

Pull request:
Add completion support for fish and PowerShell shells
## Description

Enable the cobra based completion support for the fish and PowerShell shells.

## Changes

* Add completion support for fish and powershell

## Reference

Fixes #1928 

**Release Note**

```release-note
Add completion support for fish and PowerShell shells
```

Patch:
diff --git a/OWNERS_ALIASES b/OWNERS_ALIASES
index 37d98e76..c42728fd 100644
--- a/OWNERS_ALIASES
+++ b/OWNERS_ALIASES
@@ -14,37 +14,27 @@ aliases:
   - navidshaikh
   - rhuss
   - vyasgun
-  conformance-task-force-leads:
-  - salaboy
-  conformance-writers:
-  - salaboy
   docs-reviewers:
   - nainaz
   - pmbanugo
   - retocode
   - skonto
   - snneji
-  docs-wg-leads:
-  - snneji
   docs-writers:
   - csantanapr
   - retocode
   - skonto
-  - snneji
   eventing-reviewers:
   - Leo6Leo
   - aslom
   - cali0707
   - creydr
-  eventing-triage:
-  - lberk
   eventing-wg-leads:
   - pierDipi
   eventing-writers:
   - aliok
   - cali0707
   - creydr
-  - lberk
   - lionelvillard
   - matzew
   - odacremolbap
diff --git a/docs/cmd/kn_completion.md b/docs/cmd/kn_completion.md
index b543bd29..f174a88f 100644
--- a/docs/cmd/kn_completion.md
+++ b/docs/cmd/kn_completion.md
@@ -10,6 +10,8 @@ to provide interactive completion
 
 Supported Shells:
  - bash
+ - fish
+ - powershell
  - zsh
 
 ```
@@ -23,6 +25,12 @@ kn completion SHELL
  # Generate completion code for bash
  source <(kn completion bash)
 
+ # Generate completion code for fish
+ kn completion fish | source
+
+ # Generate completion code for powershell
+ kn completion powershell | Out-String | Invoke-Expression
+
  # Generate completion code for zsh
  source <(kn completion zsh)
  compdef _kn kn
diff --git a/pkg/kn/commands/completion/completion.go b/pkg/kn/commands/completion/completion.go
index 962f8ce2..39b6b18c 100644
--- a/pkg/kn/commands/completion/completion.go
+++ b/pkg/kn/commands/completion/completion.go
@@ -30,11 +30,19 @@ to provide interactive completion
 
 Supported Shells:
  - bash
+ - fish
+ - powershell
  - zsh`
 	eg = `
  # Generate completion code for bash
  source <(kn completion bash)
 
+ # Generate completion code for fish
+ kn completion fish | source
+
+ # Generate completion code for powershell
+ kn completion powershell | Out-String | Invoke-Expression
+
  # Generate completion code for zsh
  source <(kn completion zsh)
  compdef _kn kn`
@@ -46,20 +54,24 @@ func NewCompletionCommand(p *commands.KnParams) *cobra.Command {
 		Use:       "completion SHELL",
 		Short:     "Output shell completion code",
 		Long:      desc,
-		ValidArgs: []string{"bash", "zsh"},
+		ValidArgs: []string{"bash", "fish", "powershell", "zsh"},
 		Example:   eg,
 		RunE: func(cmd *cobra.Command, args []string) error {
 			if len(args) == 1 {
 				switch args[0] {
 				case "bash":
 					return cmd.Root().GenBashCompletion(os.Stdout)
+				case "fish":
+					return cmd.Root().GenFishCompletion(os.Stdout, true)
+				case "powershell":
+					return cmd.Root().GenPowerShellCompletion(os.Stdout)
 				case "zsh":
 					return cmd.Root().GenZshCompletion(os.Stdout)
 				default:
-					return errors.New("'bash' or 'zsh' shell completion is supported")
+					return errors.New("'bash', 'fish', 'powershell' or 'zsh' shell completion is supported")
 				}
 			} else {
-				return errors.New("Only one argument can be provided, either 'bash' or 'zsh'")
+				return errors.New("Only one argument can be provided, either 'bash', 'fish', 'powershell' or 'zsh'")
 			}
 		},
 	}


Test patch:
diff --git a/pkg/kn/commands/completion/completion_test.go b/pkg/kn/commands/completion/completion_test.go
index 58a6cf65..495f75d9 100644
--- a/pkg/kn/commands/completion/completion_test.go
+++ b/pkg/kn/commands/completion/completion_test.go
@@ -34,7 +34,7 @@ func TestCompletionUsage(t *testing.T) {
 }
 
 func TestCompletionGeneration(t *testing.T) {
-	for _, shell := range []string{"bash", "zsh"} {
+	for _, shell := range []string{"bash", "fish", "powershell", "zsh"} {
 		completionCmd := NewCompletionCommand(&commands.KnParams{})
 		c := test.CaptureOutput(t)
 		err := completionCmd.RunE(&cobra.Command{}, []string{shell})
@@ -48,11 +48,11 @@ func TestCompletionGeneration(t *testing.T) {
 func TestCompletionNoArg(t *testing.T) {
 	completionCmd := NewCompletionCommand(&commands.KnParams{})
 	err := completionCmd.RunE(&cobra.Command{}, []string{})
-	assert.Assert(t, util.ContainsAll(err.Error(), "bash", "zsh", "one", "argument"))
+	assert.Assert(t, util.ContainsAll(err.Error(), "bash", "fish", "powershell", "zsh", "one", "argument"))
 }
 
 func TestCompletionWrongArg(t *testing.T) {
 	completionCmd := NewCompletionCommand(&commands.KnParams{})
 	err := completionCmd.RunE(&cobra.Command{}, []string{"sh"})
-	assert.Assert(t, util.ContainsAll(err.Error(), "bash", "zsh", "support"))
+	assert.Assert(t, util.ContainsAll(err.Error(), "bash", "fish", "powershell", "zsh", "support"))
 }
diff --git a/test/e2e/domain_mapping_test.go b/test/e2e/domain_mapping_test.go
index 0d64c7d7..e6f9f0ef 100644
--- a/test/e2e/domain_mapping_test.go
+++ b/test/e2e/domain_mapping_test.go
@@ -28,6 +28,7 @@ import (
 	"math/big"
 	"os"
 	"path/filepath"
+	"strings"
 	"testing"
 	"time"
 
@@ -137,6 +138,8 @@ func domainDescribe(r *test.KnRunResultCollector, domainName string, tls bool) {
 	for i := 0; i < 20; i++ {
 		out, err := k.Run("get", "domainmapping", domainName, "-o=jsonpath='{.status.url}'")
 		assert.NilError(r.T(), err)
+		// Remove additional spaces and single quotes added to kubectl output
+		out = strings.Trim(strings.TrimSpace(out), "'")
 		if len(out) > 0 {
 			break
 		}