Merge pull request #18876 from rjernst/plugin_install_unknown

Emit nicer error message when trying to install unknown plugin
This commit is contained in:
Ryan Ernst 2016-06-15 09:56:43 -07:00 committed by GitHub
commit 9c65bd4ac4
2 changed files with 10 additions and 0 deletions

View File

@ -237,6 +237,10 @@ class InstallPluginCommand extends SettingCommand {
} }
// fall back to plain old URL // fall back to plain old URL
if (pluginId.contains("://") == false) {
// definitely not a valid url, so assume it is a plugin name
throw new UserError(ExitCodes.USAGE, "Unknown plugin " + pluginId);
}
terminal.println("-> Downloading " + URLDecoder.decode(pluginId, "UTF-8")); terminal.println("-> Downloading " + URLDecoder.decode(pluginId, "UTF-8"));
return downloadZip(terminal, pluginId, tmpDir); return downloadZip(terminal, pluginId, tmpDir);
} }

View File

@ -307,6 +307,12 @@ public class InstallPluginCommandTests extends ESTestCase {
assertTrue(e.getMessage(), e.getMessage().contains("no protocol")); assertTrue(e.getMessage(), e.getMessage().contains("no protocol"));
} }
public void testUnknownPlugin() throws Exception {
Tuple<Path, Environment> env = createEnv(fs, temp);
UserError e = expectThrows(UserError.class, () -> installPlugin("foo", env.v1()));
assertTrue(e.getMessage(), e.getMessage().contains("Unknown plugin foo"));
}
public void testPluginsDirMissing() throws Exception { public void testPluginsDirMissing() throws Exception {
Tuple<Path, Environment> env = createEnv(fs, temp); Tuple<Path, Environment> env = createEnv(fs, temp);
Files.delete(env.v2().pluginsFile()); Files.delete(env.v2().pluginsFile());