Skip to content

Commit

Permalink
refactor(plugins): Improved and simplified verifier and plugin list
Browse files Browse the repository at this point in the history
* Added proper executable check for current user
* Refactor plugin_list to make it more straightforward
* Seperate errors and warnings
* Don't return an error when no plugin is installed and `plugin list` is called
* Simplified tests
* Check assumption that a prefix is given in verify()
  • Loading branch information
rhuss committed Jul 27, 2019
1 parent 34f123c commit c2bd8d2
Show file tree
Hide file tree
Showing 12 changed files with 471 additions and 428 deletions.
2 changes: 1 addition & 1 deletion docs/cmd/kn_plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ kn plugin [flags]
### SEE ALSO

* [kn](kn.md) - Knative client
* [kn plugin list](kn_plugin_list.md) - List all visible plugin executables
* [kn plugin list](kn_plugin_list.md) - List plugins

13 changes: 7 additions & 6 deletions docs/cmd/kn_plugin_list.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
## kn plugin list

List all visible plugin executables
List plugins

### Synopsis

List all visible plugin executables.
List all installed plugins.

Available plugin files are those that are:
Available plugins are those that are:
- executable
- begin with "kn-
- anywhere on the path specified in Kn's config pluginDir variable, which:
* can be overridden with the --plugin-dir flag
- begin with "kn-"
- Kn's plugin directory ~/.kn/plugins
- Anywhere in the execution $PATH (if lookupInPath config variable is enabled)

```
kn plugin list [flags]
Expand All @@ -23,6 +23,7 @@ kn plugin list [flags]
--lookup-plugins-in-path look for kn plugins in $PATH
--name-only If true, display only the binary name of each plugin, rather than its full path
--plugins-dir string kn plugins directory (default "~/.kn/plugins")
--verbose verbose output
```

### Options inherited from parent commands
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ require (
github.com/mitchellh/go-homedir v1.1.0
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pkg/errors v0.8.1 // indirect
github.com/pkg/errors v0.8.1
github.com/spf13/cobra v0.0.3
github.com/spf13/pflag v1.0.3
github.com/spf13/viper v1.3.1
Expand Down
102 changes: 0 additions & 102 deletions pkg/kn/commands/plugin/path_verifier.go

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/kn/commands/plugin/plugin_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (h *DefaultPluginHandler) Lookup(name string) (string, bool) {
pluginPath := fmt.Sprintf("%s-%s", prefix, name)

// Try to find plugin in pluginsDir
pluginDir, err := ExpandPath(h.PluginsDir)
pluginDir, err := expandPath(h.PluginsDir)
if err != nil {
return "", false
}
Expand Down
Loading

0 comments on commit c2bd8d2

Please sign in to comment.