Skip to content

Commit

Permalink
cmd: Friendly error messages when plugin not found (#432)
Browse files Browse the repository at this point in the history
* Update error message when upgrading plugin that isn't in the manifest

Also remove line from run-tests.sh for file that was deleted in e37ee1d#diff-d78b6f30225cdc811adfe8d4e7c9fd34

* Update messaging when installing non-existent plugin

* Skip installing plugins that are already installed

* Use os.IsNotExist

* Code review changes

emove check on installed plugin and use %q and errors.New

* Use errors.Errorf
  • Loading branch information
chriskim06 authored and k8s-ci-robot committed Dec 10, 2019
1 parent acc43bf commit 3b343e8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions cmd/krew/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ Remarks:
for _, name := range pluginNames {
plugin, err := indexscanner.LoadPluginFileFromFS(paths.IndexPluginsPath(), name)
if err != nil {
if os.IsNotExist(err) {
return errors.Errorf("plugin %q does not exist in the plugin index", name)
}
return errors.Wrapf(err, "failed to load plugin %q from the index", name)
}
install = append(install, plugin)
Expand Down
3 changes: 3 additions & 0 deletions cmd/krew/cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ kubectl krew upgrade foo bar"`,
for _, name := range pluginNames {
plugin, err := indexscanner.LoadPluginFileFromFS(paths.IndexPluginsPath(), name)
if err != nil {
if os.IsNotExist(err) {
return errors.Errorf("plugin %q does not exist in the plugin index", name)
}
return errors.Wrapf(err, "failed to load the plugin manifest for plugin %s", name)
}

Expand Down
3 changes: 0 additions & 3 deletions hack/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ trap print_status EXIT
print_with_color "$color_blue" 'Checking boilerplate'
"$SCRIPTDIR"/verify-boilerplate.sh

print_with_color "$color_blue" 'Running gofmt'
"$SCRIPTDIR"/verify-gofmt.sh

print_with_color "$color_blue" 'Running tests'
go test -short -race sigs.k8s.io/krew/...

Expand Down

0 comments on commit 3b343e8

Please sign in to comment.