[plugin] shorten plugin names
We don't need to prefix anymore plugin names with `elasticsearch-` or `es-`.
This commit is contained in:
parent
2c902a4d2f
commit
33e8fae824
|
@ -75,19 +75,19 @@ public class PluginManager {
|
|||
|
||||
static final ImmutableSet<String> OFFICIAL_PLUGINS = ImmutableSet.<String>builder()
|
||||
.add(
|
||||
"elasticsearch-analysis-icu",
|
||||
"elasticsearch-analysis-kuromoji",
|
||||
"elasticsearch-analysis-phonetic",
|
||||
"elasticsearch-analysis-smartcn",
|
||||
"elasticsearch-analysis-stempel",
|
||||
"elasticsearch-cloud-aws",
|
||||
"elasticsearch-cloud-azure",
|
||||
"elasticsearch-cloud-gce",
|
||||
"elasticsearch-delete-by-query",
|
||||
"elasticsearch-lang-javascript",
|
||||
"elasticsearch-lang-python",
|
||||
"elasticsearch-mapper-murmur3",
|
||||
"elasticsearch-mapper-size"
|
||||
"analysis-icu",
|
||||
"analysis-kuromoji",
|
||||
"analysis-phonetic",
|
||||
"analysis-smartcn",
|
||||
"analysis-stempel",
|
||||
"cloud-aws",
|
||||
"cloud-azure",
|
||||
"cloud-gce",
|
||||
"delete-by-query",
|
||||
"lang-javascript",
|
||||
"lang-python",
|
||||
"mapper-murmur3",
|
||||
"mapper-size"
|
||||
).build();
|
||||
|
||||
private final Environment environment;
|
||||
|
@ -457,9 +457,9 @@ public class PluginManager {
|
|||
if (user == null) {
|
||||
// TODO Update to https
|
||||
if (!Strings.isNullOrEmpty(System.getProperty(PROPERTY_SUPPORT_STAGING_URLS))) {
|
||||
addUrl(urls, String.format(Locale.ROOT, "http://download.elastic.co/elasticsearch/staging/elasticsearch-%s-%s/org/elasticsearch/plugin/elasticsearch-%s/%s/elasticsearch-%s-%s.zip", version, Build.CURRENT.hashShort(), repo, version, repo, version));
|
||||
addUrl(urls, String.format(Locale.ROOT, "http://download.elastic.co/elasticsearch/staging/%s-%s/org/elasticsearch/plugin/%s/%s/%s-%s.zip", version, Build.CURRENT.hashShort(), repo, version, repo, version));
|
||||
}
|
||||
addUrl(urls, String.format(Locale.ROOT, "http://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/elasticsearch-%s/%s/elasticsearch-%s-%s.zip", repo, version, repo, version));
|
||||
addUrl(urls, String.format(Locale.ROOT, "http://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/%s/%s/%s-%s.zip", repo, version, repo, version));
|
||||
} else {
|
||||
// Elasticsearch old download service
|
||||
// TODO Update to https
|
||||
|
@ -526,20 +526,11 @@ 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)) {
|
||||
return new PluginHandle(endname, Version.CURRENT.number(), null, repo);
|
||||
return new PluginHandle(repo, Version.CURRENT.number(), null, repo);
|
||||
}
|
||||
|
||||
return new PluginHandle(endname, version, user, repo);
|
||||
return new PluginHandle(repo, version, user, repo);
|
||||
}
|
||||
|
||||
static boolean isOfficialPlugin(String repo, String user, String version) {
|
||||
|
|
|
@ -22,7 +22,7 @@ DESCRIPTION
|
|||
|
||||
EXAMPLES
|
||||
|
||||
plugin install elasticsearch-analysis-kuromoji
|
||||
plugin install analysis-kuromoji
|
||||
|
||||
plugin install elasticsearch/shield/latest
|
||||
|
||||
|
@ -32,24 +32,24 @@ OFFICIAL PLUGINS
|
|||
|
||||
The following plugins are officially supported and can be installed by just referring to their name
|
||||
|
||||
- elasticsearch-analysis-icu
|
||||
- elasticsearch-analysis-kuromoji
|
||||
- elasticsearch-analysis-phonetic
|
||||
- elasticsearch-analysis-smartcn
|
||||
- elasticsearch-analysis-stempel
|
||||
- elasticsearch-cloud-aws
|
||||
- elasticsearch-cloud-azure
|
||||
- elasticsearch-cloud-gce
|
||||
- elasticsearch-delete-by-query
|
||||
- elasticsearch-lang-javascript
|
||||
- elasticsearch-lang-python
|
||||
- elasticsearch-mapper-murmur3
|
||||
- elasticsearch-mapper-size
|
||||
- analysis-icu
|
||||
- analysis-kuromoji
|
||||
- analysis-phonetic
|
||||
- analysis-smartcn
|
||||
- analysis-stempel
|
||||
- cloud-aws
|
||||
- cloud-azure
|
||||
- cloud-gce
|
||||
- delete-by-query
|
||||
- lang-javascript
|
||||
- lang-python
|
||||
- mapper-murmur3
|
||||
- mapper-size
|
||||
|
||||
|
||||
OPTIONS
|
||||
|
||||
-u,--url URL to retrive the plugin from
|
||||
-u,--url URL to retrieve the plugin from
|
||||
|
||||
-t,--timeout Timeout until the plugin download is abort
|
||||
|
||||
|
|
|
@ -52,9 +52,7 @@ import javax.net.ssl.HttpsURLConnection;
|
|||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.FileVisitResult;
|
||||
|
@ -539,18 +537,19 @@ public class PluginManagerIT extends ESIntegTestCase {
|
|||
|
||||
@Test
|
||||
public void testOfficialPluginName_ThrowsException() throws IOException {
|
||||
PluginManager.checkForOfficialPlugins("elasticsearch-analysis-icu");
|
||||
PluginManager.checkForOfficialPlugins("elasticsearch-analysis-kuromoji");
|
||||
PluginManager.checkForOfficialPlugins("elasticsearch-analysis-phonetic");
|
||||
PluginManager.checkForOfficialPlugins("elasticsearch-analysis-smartcn");
|
||||
PluginManager.checkForOfficialPlugins("elasticsearch-analysis-stempel");
|
||||
PluginManager.checkForOfficialPlugins("elasticsearch-cloud-aws");
|
||||
PluginManager.checkForOfficialPlugins("elasticsearch-cloud-azure");
|
||||
PluginManager.checkForOfficialPlugins("elasticsearch-cloud-gce");
|
||||
PluginManager.checkForOfficialPlugins("elasticsearch-delete-by-query");
|
||||
PluginManager.checkForOfficialPlugins("elasticsearch-lang-javascript");
|
||||
PluginManager.checkForOfficialPlugins("elasticsearch-lang-python");
|
||||
PluginManager.checkForOfficialPlugins("elasticsearch-mapper-murmur3");
|
||||
PluginManager.checkForOfficialPlugins("analysis-icu");
|
||||
PluginManager.checkForOfficialPlugins("analysis-kuromoji");
|
||||
PluginManager.checkForOfficialPlugins("analysis-phonetic");
|
||||
PluginManager.checkForOfficialPlugins("analysis-smartcn");
|
||||
PluginManager.checkForOfficialPlugins("analysis-stempel");
|
||||
PluginManager.checkForOfficialPlugins("cloud-aws");
|
||||
PluginManager.checkForOfficialPlugins("cloud-azure");
|
||||
PluginManager.checkForOfficialPlugins("cloud-gce");
|
||||
PluginManager.checkForOfficialPlugins("delete-by-query");
|
||||
PluginManager.checkForOfficialPlugins("lang-javascript");
|
||||
PluginManager.checkForOfficialPlugins("lang-python");
|
||||
PluginManager.checkForOfficialPlugins("mapper-murmur3");
|
||||
PluginManager.checkForOfficialPlugins("mapper-size");
|
||||
|
||||
try {
|
||||
PluginManager.checkForOfficialPlugins("elasticsearch-mapper-attachment");
|
||||
|
|
|
@ -82,12 +82,12 @@ public class PluginManagerUnitTests extends ESTestCase {
|
|||
Iterator<URL> iterator = handle.urls().iterator();
|
||||
|
||||
if (supportStagingUrls) {
|
||||
String expectedStagingURL = String.format(Locale.ROOT, "http://download.elastic.co/elasticsearch/staging/elasticsearch-%s-%s/org/elasticsearch/plugin/elasticsearch-%s/%s/elasticsearch-%s-%s.zip",
|
||||
String expectedStagingURL = String.format(Locale.ROOT, "http://download.elastic.co/elasticsearch/staging/%s-%s/org/elasticsearch/plugin/%s/%s/%s-%s.zip",
|
||||
Version.CURRENT.number(), Build.CURRENT.hashShort(), pluginName, Version.CURRENT.number(), pluginName, Version.CURRENT.number());
|
||||
assertThat(iterator.next().toExternalForm(), is(expectedStagingURL));
|
||||
}
|
||||
|
||||
URL expected = new URL("http", "download.elastic.co", "/elasticsearch/release/org/elasticsearch/plugin/elasticsearch-" + pluginName + "/" + Version.CURRENT.number() + "/elasticsearch-" +
|
||||
URL expected = new URL("http", "download.elastic.co", "/elasticsearch/release/org/elasticsearch/plugin/" + pluginName + "/" + Version.CURRENT.number() + "/" +
|
||||
pluginName + "-" + Version.CURRENT.number() + ".zip");
|
||||
assertThat(iterator.next().toExternalForm(), is(expected.toExternalForm()));
|
||||
|
||||
|
@ -95,10 +95,10 @@ public class PluginManagerUnitTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testTrimmingElasticsearchFromOfficialPluginName() throws IOException {
|
||||
String randomPluginName = randomFrom(PluginManager.OFFICIAL_PLUGINS.asList()).replaceFirst("elasticsearch-", "");
|
||||
public void testOfficialPluginName() throws IOException {
|
||||
String randomPluginName = randomFrom(PluginManager.OFFICIAL_PLUGINS.asList());
|
||||
PluginManager.PluginHandle handle = PluginManager.PluginHandle.parse(randomPluginName);
|
||||
assertThat(handle.name, is(randomPluginName.replaceAll("^elasticsearch-", "")));
|
||||
assertThat(handle.name, is(randomPluginName));
|
||||
|
||||
boolean supportStagingUrls = randomBoolean();
|
||||
if (supportStagingUrls) {
|
||||
|
@ -108,12 +108,12 @@ public class PluginManagerUnitTests extends ESTestCase {
|
|||
Iterator<URL> iterator = handle.urls().iterator();
|
||||
|
||||
if (supportStagingUrls) {
|
||||
String expectedStagingUrl = String.format(Locale.ROOT, "http://download.elastic.co/elasticsearch/staging/elasticsearch-%s-%s/org/elasticsearch/plugin/elasticsearch-%s/%s/elasticsearch-%s-%s.zip",
|
||||
String expectedStagingUrl = String.format(Locale.ROOT, "http://download.elastic.co/elasticsearch/staging/%s-%s/org/elasticsearch/plugin/%s/%s/%s-%s.zip",
|
||||
Version.CURRENT.number(), Build.CURRENT.hashShort(), randomPluginName, Version.CURRENT.number(), randomPluginName, Version.CURRENT.number());
|
||||
assertThat(iterator.next().toExternalForm(), is(expectedStagingUrl));
|
||||
}
|
||||
|
||||
String releaseUrl = String.format(Locale.ROOT, "http://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/elasticsearch-%s/%s/elasticsearch-%s-%s.zip",
|
||||
String releaseUrl = String.format(Locale.ROOT, "http://download.elastic.co/elasticsearch/release/org/elasticsearch/plugin/%s/%s/%s-%s.zip",
|
||||
randomPluginName, Version.CURRENT.number(), randomPluginName, Version.CURRENT.number());
|
||||
assertThat(iterator.next().toExternalForm(), is(releaseUrl));
|
||||
|
||||
|
@ -121,12 +121,11 @@ public class PluginManagerUnitTests extends ESTestCase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testTrimmingElasticsearchFromGithubPluginName() throws IOException {
|
||||
public void testGithubPluginName() throws IOException {
|
||||
String user = randomAsciiOfLength(6);
|
||||
String randomName = randomAsciiOfLength(10);
|
||||
String pluginName = randomFrom("elasticsearch-", "es-") + randomName;
|
||||
String pluginName = randomAsciiOfLength(10);
|
||||
PluginManager.PluginHandle handle = PluginManager.PluginHandle.parse(user + "/" + pluginName);
|
||||
assertThat(handle.name, is(randomName));
|
||||
assertThat(handle.name, is(pluginName));
|
||||
assertThat(handle.urls(), hasSize(1));
|
||||
assertThat(handle.urls().get(0).toExternalForm(), is(new URL("https", "github.com", "/" + user + "/" + pluginName + "/" + "archive/master.zip").toExternalForm()));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue