Skip to content

Commit

Permalink
Merge branch 'master' into kn-plugins4
Browse files Browse the repository at this point in the history
  • Loading branch information
maximilien committed Jul 12, 2019
2 parents a4c94ae + 9e29ce8 commit 1819e52
Show file tree
Hide file tree
Showing 29 changed files with 507 additions and 87 deletions.
4 changes: 2 additions & 2 deletions docs/cmd/kn.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ Eventing: Manage event subscriptions and channels. Connect up event sources.
### Options

```
--config string config file (default is $HOME/.kn/config.yaml)
--config string kn config file (default is $HOME/.kn/config.yaml)
-h, --help help for kn
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
--plugin-dir string kn plugin directory (default is value in kn config or $PATH) (default "$PATH")
--plugin-dir string kn plugin directory also stored in kn config (default "$PATH")
```

### SEE ALSO
Expand Down
4 changes: 2 additions & 2 deletions docs/cmd/kn_completion.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ kn completion [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn/config.yaml)
--config string kn config file (default is $HOME/.kn/config.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
--plugin-dir string kn plugin directory (default is value in kn config or $PATH) (default "$PATH")
--plugin-dir string kn plugin directory also stored in kn config (default "$PATH")
```

### SEE ALSO
Expand Down
8 changes: 4 additions & 4 deletions docs/cmd/kn_plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Plugin command group

### Synopsis

Provides utilities for interacting with kn plugins.
Provides utilities for interacting and managing with kn plugins.

Plugins provide extended functionality that is not part of the major kn command-line distribution.
Plugins provide extended functionality that is not part of the core kn command-line distribution.
Please refer to the documentation and examples for more information about how write your own plugins.

```
Expand All @@ -22,9 +22,9 @@ kn plugin [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn/config.yaml)
--config string kn config file (default is $HOME/.kn/config.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
--plugin-dir string kn plugin directory (default is value in kn config or $PATH) (default "$PATH")
--plugin-dir string kn plugin directory also stored in kn config (default "$PATH")
```

### SEE ALSO
Expand Down
16 changes: 8 additions & 8 deletions docs/cmd/kn_plugin_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ List all visible plugin executables

List all visible plugin executables.

Available plugin files are those that are:
- executable
- begin with "kn-
- anywhere on the path specfied in Kn's config pluginDir variable, which:
* defaults to $PATH if not specified
* can be overridden with the --plugin-dir flag
Available plugin files are those that are:
- executable
- begin with "kn-
- anywhere on the path specfied in Kn's config pluginDir variable, which:
* defaults to $PATH if not specified
* can be overridden with the --plugin-dir flag

```
kn plugin list [flags]
Expand All @@ -27,9 +27,9 @@ kn plugin list [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn/config.yaml)
--config string kn config file (default is $HOME/.kn/config.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
--plugin-dir string kn plugin directory (default is value in kn config or $PATH) (default "$PATH")
--plugin-dir string kn plugin directory also stored in kn config (default "$PATH")
```

### SEE ALSO
Expand Down
4 changes: 2 additions & 2 deletions docs/cmd/kn_revision.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ kn revision [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn/config.yaml)
--config string kn config file (default is $HOME/.kn/config.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
--plugin-dir string kn plugin directory (default is value in kn config or $PATH) (default "$PATH")
--plugin-dir string kn plugin directory also stored in kn config (default "$PATH")
```

### SEE ALSO
Expand Down
4 changes: 2 additions & 2 deletions docs/cmd/kn_revision_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ kn revision delete NAME [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn/config.yaml)
--config string kn config file (default is $HOME/.kn/config.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
--plugin-dir string kn plugin directory (default is value in kn config or $PATH) (default "$PATH")
--plugin-dir string kn plugin directory also stored in kn config (default "$PATH")
```

### SEE ALSO
Expand Down
4 changes: 2 additions & 2 deletions docs/cmd/kn_revision_describe.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ kn revision describe NAME [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn/config.yaml)
--config string kn config file (default is $HOME/.kn/config.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
--plugin-dir string kn plugin directory (default is value in kn config or $PATH) (default "$PATH")
--plugin-dir string kn plugin directory also stored in kn config (default "$PATH")
```

### SEE ALSO
Expand Down
4 changes: 2 additions & 2 deletions docs/cmd/kn_revision_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ kn revision list [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn/config.yaml)
--config string kn config file (default is $HOME/.kn/config.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
--plugin-dir string kn plugin directory (default is value in kn config or $PATH) (default "$PATH")
--plugin-dir string kn plugin directory also stored in kn config (default "$PATH")
```

### SEE ALSO
Expand Down
4 changes: 2 additions & 2 deletions docs/cmd/kn_route.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ kn route [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn/config.yaml)
--config string kn config file (default is $HOME/.kn/config.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
--plugin-dir string kn plugin directory (default is value in kn config or $PATH) (default "$PATH")
--plugin-dir string kn plugin directory also stored in kn config (default "$PATH")
```

### SEE ALSO
Expand Down
4 changes: 2 additions & 2 deletions docs/cmd/kn_route_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ kn route list NAME [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn/config.yaml)
--config string kn config file (default is $HOME/.kn/config.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
--plugin-dir string kn plugin directory (default is value in kn config or $PATH) (default "$PATH")
--plugin-dir string kn plugin directory also stored in kn config (default "$PATH")
```

### SEE ALSO
Expand Down
4 changes: 2 additions & 2 deletions docs/cmd/kn_service.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ kn service [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn/config.yaml)
--config string kn config file (default is $HOME/.kn/config.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
--plugin-dir string kn plugin directory (default is value in kn config or $PATH) (default "$PATH")
--plugin-dir string kn plugin directory also stored in kn config (default "$PATH")
```

### SEE ALSO
Expand Down
4 changes: 2 additions & 2 deletions docs/cmd/kn_service_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ kn service create NAME --image IMAGE [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn/config.yaml)
--config string kn config file (default is $HOME/.kn/config.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
--plugin-dir string kn plugin directory (default is value in kn config or $PATH) (default "$PATH")
--plugin-dir string kn plugin directory also stored in kn config (default "$PATH")
```

### SEE ALSO
Expand Down
4 changes: 2 additions & 2 deletions docs/cmd/kn_service_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ kn service delete NAME [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn/config.yaml)
--config string kn config file (default is $HOME/.kn/config.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
--plugin-dir string kn plugin directory (default is value in kn config or $PATH) (default "$PATH")
--plugin-dir string kn plugin directory also stored in kn config (default "$PATH")
```

### SEE ALSO
Expand Down
4 changes: 2 additions & 2 deletions docs/cmd/kn_service_describe.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ kn service describe NAME [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn/config.yaml)
--config string kn config file (default is $HOME/.kn/config.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
--plugin-dir string kn plugin directory (default is value in kn config or $PATH) (default "$PATH")
--plugin-dir string kn plugin directory also stored in kn config (default "$PATH")
```

### SEE ALSO
Expand Down
4 changes: 2 additions & 2 deletions docs/cmd/kn_service_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ kn service list [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn/config.yaml)
--config string kn config file (default is $HOME/.kn/config.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
--plugin-dir string kn plugin directory (default is value in kn config or $PATH) (default "$PATH")
--plugin-dir string kn plugin directory also stored in kn config (default "$PATH")
```

### SEE ALSO
Expand Down
4 changes: 2 additions & 2 deletions docs/cmd/kn_service_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ kn service update NAME [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn/config.yaml)
--config string kn config file (default is $HOME/.kn/config.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
--plugin-dir string kn plugin directory (default is value in kn config or $PATH) (default "$PATH")
--plugin-dir string kn plugin directory also stored in kn config (default "$PATH")
```

### SEE ALSO
Expand Down
4 changes: 2 additions & 2 deletions docs/cmd/kn_version.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ kn version [flags]
### Options inherited from parent commands

```
--config string config file (default is $HOME/.kn/config.yaml)
--config string kn config file (default is $HOME/.kn/config.yaml)
--kubeconfig string kubectl config file (default is $HOME/.kube/config)
--plugin-dir string kn plugin directory (default is value in kn config or $PATH) (default "$PATH")
--plugin-dir string kn plugin directory also stored in kn config (default "$PATH")
```

### SEE ALSO
Expand Down
62 changes: 62 additions & 0 deletions pkg/kn/commands/completion_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright © 2018 The Knative Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package commands

import (
"testing"

"github.com/spf13/cobra"
"gotest.tools/assert"
)

func TestCompletion(t *testing.T) {
var (
fakeRootCmd, completionCmd *cobra.Command
knParams *KnParams
)

setup := func() {
knParams = &KnParams{}
completionCmd = NewCompletionCommand(knParams)

fakeRootCmd = &cobra.Command{}
fakeRootCmd.AddCommand(completionCmd)
}

t.Run("creates a CompletionCommand", func(t *testing.T) {
setup()
assert.Equal(t, completionCmd.Use, "completion")
assert.Equal(t, completionCmd.Short, "Output shell completion code (default Bash)")
assert.Assert(t, completionCmd.RunE == nil)
})

t.Run("returns completion code for BASH", func(t *testing.T) {
setup()
CaptureStdout(t)
defer ReleaseStdout(t)

completionCmd.Run(fakeRootCmd, []string{})
assert.Assert(t, ReadStdout(t) != "")
})

t.Run("returns completion code for ZSH", func(t *testing.T) {
setup()
CaptureStdout(t)
defer ReleaseStdout(t)

completionCmd.Run(fakeRootCmd, []string{"--zsh"})
assert.Assert(t, ReadStdout(t) != "")
})
}
10 changes: 5 additions & 5 deletions pkg/kn/commands/plugin/path_verifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var (
verifier *CommandOverrideVerifier
)

var setup = func() {
var setup = func(t *testing.T) {
knParams := &commands.KnParams{}
rootCmd, _, _ = commands.CreateTestKnCommand(NewPluginCommand(knParams), knParams)
verifier = &CommandOverrideVerifier{
Expand All @@ -47,7 +47,7 @@ var cleanup = func(t *testing.T) {

func TestCommandOverrideVerifier_Verify_with_nil_root_command(t *testing.T) {
t.Run("returns error verifying path", func(t *testing.T) {
setup()
setup(t)
defer cleanup(t)
verifier.Root = nil

Expand All @@ -60,7 +60,7 @@ func TestCommandOverrideVerifier_Verify_with_nil_root_command(t *testing.T) {

func TestCommandOverrideVerifier_Verify_with_root_command(t *testing.T) {
t.Run("when plugin in path not executable", func(t *testing.T) {
setup()
setup(t)
defer cleanup(t)
pluginPath = CreateTestPlugin(t, KnTestPluginName, KnTestPluginScript, FileModeReadable)

Expand All @@ -74,7 +74,7 @@ func TestCommandOverrideVerifier_Verify_with_root_command(t *testing.T) {
})

t.Run("when kn plugin in path is executable", func(t *testing.T) {
setup()
setup(t)
defer cleanup(t)
pluginPath = CreateTestPlugin(t, KnTestPluginName, KnTestPluginScript, FileModeExecutable)

Expand All @@ -94,7 +94,7 @@ func TestCommandOverrideVerifier_Verify_with_root_command(t *testing.T) {
})

t.Run("when kn plugin in path overwrites existing command", func(t *testing.T) {
setup()
setup(t)
defer cleanup(t)
var overwritingPluginPath = CreateTestPlugin(t, "kn-plugin", KnTestPluginScript, FileModeExecutable)
defer DeleteTestPlugin(t, overwritingPluginPath)
Expand Down
4 changes: 2 additions & 2 deletions pkg/kn/commands/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ func NewPluginCommand(p *commands.KnParams) *cobra.Command {
pluginCmd := &cobra.Command{
Use: "plugin",
Short: "Plugin command group",
Long: `Provides utilities for interacting with kn plugins.
Long: `Provides utilities for interacting and managing with kn plugins.
Plugins provide extended functionality that is not part of the major kn command-line distribution.
Plugins provide extended functionality that is not part of the core kn command-line distribution.
Please refer to the documentation and examples for more information about how write your own plugins.`,
}
pluginCmd.AddCommand(NewPluginListCommand(p))
Expand Down
Loading

0 comments on commit 1819e52

Please sign in to comment.