strip elasticsearch- and es- from any plugin name
#12158 only partially fixed #12143 by removing the prefix from official plugin names. This change removes the prefixes from any plugin names.
This commit is contained in:
parent
a821c558d3
commit
ee30cf32ab
|
@ -758,19 +758,20 @@ public class PluginManager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String endname = repo;
|
||||||
|
if (repo.startsWith("elasticsearch-")) {
|
||||||
|
// remove elasticsearch- prefix
|
||||||
|
endname = repo.substring("elasticsearch-".length());
|
||||||
|
} else if (repo.startsWith("es-")) {
|
||||||
|
// remove es- prefix
|
||||||
|
endname = repo.substring("es-".length());
|
||||||
|
}
|
||||||
|
|
||||||
if (isOfficialPlugin(repo, user, version)) {
|
if (isOfficialPlugin(repo, user, version)) {
|
||||||
String endname = repo;
|
|
||||||
if (repo.startsWith("elasticsearch-")) {
|
|
||||||
// remove elasticsearch- prefix
|
|
||||||
endname = repo.substring("elasticsearch-".length());
|
|
||||||
} else if (name.startsWith("es-")) {
|
|
||||||
// remove es- prefix
|
|
||||||
endname = repo.substring("es-".length());
|
|
||||||
}
|
|
||||||
return new PluginHandle(endname, Version.CURRENT.number(), null, repo);
|
return new PluginHandle(endname, Version.CURRENT.number(), null, repo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new PluginHandle(repo, version, user, repo);
|
return new PluginHandle(endname, version, user, repo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isOfficialPlugin(String repo, String user, String version) {
|
static boolean isOfficialPlugin(String repo, String user, String version) {
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class PluginManagerUnitTests extends ElasticsearchTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTrimmingElasticsearchFromPluginName() throws IOException {
|
public void testTrimmingElasticsearchFromOfficialPluginName() throws IOException {
|
||||||
String randomName = randomAsciiOfLength(10);
|
String randomName = randomAsciiOfLength(10);
|
||||||
String pluginName = randomFrom("elasticsearch-", "es-") + randomName;
|
String pluginName = randomFrom("elasticsearch-", "es-") + randomName;
|
||||||
PluginManager.PluginHandle handle = PluginManager.PluginHandle.parse(pluginName);
|
PluginManager.PluginHandle handle = PluginManager.PluginHandle.parse(pluginName);
|
||||||
|
@ -79,4 +79,16 @@ public class PluginManagerUnitTests extends ElasticsearchTestCase {
|
||||||
pluginName + "-" + Version.CURRENT.number() + ".zip");
|
pluginName + "-" + Version.CURRENT.number() + ".zip");
|
||||||
assertThat(handle.urls().get(0), is(expected));
|
assertThat(handle.urls().get(0), is(expected));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testTrimmingElasticsearchFromGithubPluginName() throws IOException {
|
||||||
|
String user = randomAsciiOfLength(6);
|
||||||
|
String randomName = randomAsciiOfLength(10);
|
||||||
|
String pluginName = randomFrom("elasticsearch-", "es-") + randomName;
|
||||||
|
PluginManager.PluginHandle handle = PluginManager.PluginHandle.parse(user + "/" + pluginName);
|
||||||
|
assertThat(handle.name, is(randomName));
|
||||||
|
assertThat(handle.urls(), hasSize(1));
|
||||||
|
URL expected = new URL("https", "github.com", "/" + user + "/" + pluginName + "/" + "archive/master.zip");
|
||||||
|
assertThat(handle.urls().get(0), is(expected));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue