Skip to content

Commit

Permalink
Code review changes
Browse files Browse the repository at this point in the history
emove check on installed plugin and use %q and errors.New
  • Loading branch information
chriskim06 committed Dec 10, 2019
1 parent 150d007 commit 6700aa0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 15 deletions.
15 changes: 1 addition & 14 deletions cmd/krew/cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,12 @@ Remarks:
return errors.New("--archive can be specified only with --manifest")
}

installed, err := installation.ListInstalledPlugins(paths.InstallReceiptsPath())
if err != nil {
return errors.Wrap(err, "failed to find all installed versions")
}
skipped := false
var install []index.Plugin
for _, name := range pluginNames {
if _, ok := installed[name]; ok {
fmt.Fprintf(os.Stderr, "plugin \"%s\" is already installed\n", name)
skipped = true
continue
}
plugin, err := indexscanner.LoadPluginFileFromFS(paths.IndexPluginsPath(), name)
if err != nil {
if os.IsNotExist(err) {
return fmt.Errorf("plugin \"%s\" does not exist in the plugin index", name)
return errors.New(fmt.Sprintf("plugin %q does not exist in the plugin index", name))
}
return errors.Wrapf(err, "failed to load plugin %q from the index", name)
}
Expand All @@ -119,9 +109,6 @@ Remarks:
}

if len(install) == 0 {
if skipped {
return nil
}
return cmd.Help()
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/krew/cmd/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ kubectl krew upgrade foo bar"`,
plugin, err := indexscanner.LoadPluginFileFromFS(paths.IndexPluginsPath(), name)
if err != nil {
if os.IsNotExist(err) {
return fmt.Errorf("plugin \"%s\" does not exist in the plugin index", name)
return errors.New(fmt.Sprintf("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

0 comments on commit 6700aa0

Please sign in to comment.