[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()
|
static final ImmutableSet<String> OFFICIAL_PLUGINS = ImmutableSet.<String>builder()
|
||||||
.add(
|
.add(
|
||||||
"elasticsearch-analysis-icu",
|
"analysis-icu",
|
||||||
"elasticsearch-analysis-kuromoji",
|
"analysis-kuromoji",
|
||||||
"elasticsearch-analysis-phonetic",
|
"analysis-phonetic",
|
||||||
"elasticsearch-analysis-smartcn",
|
"analysis-smartcn",
|
||||||
"elasticsearch-analysis-stempel",
|
"analysis-stempel",
|
||||||
"elasticsearch-cloud-aws",
|
"cloud-aws",
|
||||||
"elasticsearch-cloud-azure",
|
"cloud-azure",
|
||||||
"elasticsearch-cloud-gce",
|
"cloud-gce",
|
||||||
"elasticsearch-delete-by-query",
|
"delete-by-query",
|
||||||
"elasticsearch-lang-javascript",
|
"lang-javascript",
|
||||||
"elasticsearch-lang-python",
|
"lang-python",
|
||||||
"elasticsearch-mapper-murmur3",
|
"mapper-murmur3",
|
||||||
"elasticsearch-mapper-size"
|
"mapper-size"
|
||||||
).build();
|
).build();
|
||||||
|
|
||||||
private final Environment environment;
|
private final Environment environment;
|
||||||
|
@ -457,9 +457,9 @@ public class PluginManager {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
// TODO Update to https
|
// TODO Update to https
|
||||||
if (!Strings.isNullOrEmpty(System.getProperty(PROPERTY_SUPPORT_STAGING_URLS))) {
|
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 {
|
} else {
|
||||||
// Elasticsearch old download service
|
// Elasticsearch old download service
|
||||||
// TODO Update to https
|
// 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)) {
|
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) {
|
static boolean isOfficialPlugin(String repo, String user, String version) {
|
||||||
|
|
|
@ -22,7 +22,7 @@ DESCRIPTION
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
|
|
||||||
plugin install elasticsearch-analysis-kuromoji
|
plugin install analysis-kuromoji
|
||||||
|
|
||||||
plugin install elasticsearch/shield/latest
|
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
|
The following plugins are officially supported and can be installed by just referring to their name
|
||||||
|
|
||||||
- elasticsearch-analysis-icu
|
- analysis-icu
|
||||||
- elasticsearch-analysis-kuromoji
|
- analysis-kuromoji
|
||||||
- elasticsearch-analysis-phonetic
|
- analysis-phonetic
|
||||||
- elasticsearch-analysis-smartcn
|
- analysis-smartcn
|
||||||
- elasticsearch-analysis-stempel
|
- analysis-stempel
|
||||||
- elasticsearch-cloud-aws
|
- cloud-aws
|
||||||
- elasticsearch-cloud-azure
|
- cloud-azure
|
||||||
- elasticsearch-cloud-gce
|
- cloud-gce
|
||||||
- elasticsearch-delete-by-query
|
- delete-by-query
|
||||||
- elasticsearch-lang-javascript
|
- lang-javascript
|
||||||
- elasticsearch-lang-python
|
- lang-python
|
||||||
- elasticsearch-mapper-murmur3
|
- mapper-murmur3
|
||||||
- elasticsearch-mapper-size
|
- mapper-size
|
||||||
|
|
||||||
|
|
||||||
OPTIONS
|
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
|
-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.SSLContext;
|
||||||
import javax.net.ssl.SSLSocketFactory;
|
import javax.net.ssl.SSLSocketFactory;
|
||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.FileVisitResult;
|
import java.nio.file.FileVisitResult;
|
||||||
|
@ -539,18 +537,19 @@ public class PluginManagerIT extends ESIntegTestCase {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testOfficialPluginName_ThrowsException() throws IOException {
|
public void testOfficialPluginName_ThrowsException() throws IOException {
|
||||||
PluginManager.checkForOfficialPlugins("elasticsearch-analysis-icu");
|
PluginManager.checkForOfficialPlugins("analysis-icu");
|
||||||
PluginManager.checkForOfficialPlugins("elasticsearch-analysis-kuromoji");
|
PluginManager.checkForOfficialPlugins("analysis-kuromoji");
|
||||||
PluginManager.checkForOfficialPlugins("elasticsearch-analysis-phonetic");
|
PluginManager.checkForOfficialPlugins("analysis-phonetic");
|
||||||
PluginManager.checkForOfficialPlugins("elasticsearch-analysis-smartcn");
|
PluginManager.checkForOfficialPlugins("analysis-smartcn");
|
||||||
PluginManager.checkForOfficialPlugins("elasticsearch-analysis-stempel");
|
PluginManager.checkForOfficialPlugins("analysis-stempel");
|
||||||
PluginManager.checkForOfficialPlugins("elasticsearch-cloud-aws");
|
PluginManager.checkForOfficialPlugins("cloud-aws");
|
||||||
PluginManager.checkForOfficialPlugins("elasticsearch-cloud-azure");
|
PluginManager.checkForOfficialPlugins("cloud-azure");
|
||||||
PluginManager.checkForOfficialPlugins("elasticsearch-cloud-gce");
|
PluginManager.checkForOfficialPlugins("cloud-gce");
|
||||||
PluginManager.checkForOfficialPlugins("elasticsearch-delete-by-query");
|
PluginManager.checkForOfficialPlugins("delete-by-query");
|
||||||
PluginManager.checkForOfficialPlugins("elasticsearch-lang-javascript");
|
PluginManager.checkForOfficialPlugins("lang-javascript");
|
||||||
PluginManager.checkForOfficialPlugins("elasticsearch-lang-python");
|
PluginManager.checkForOfficialPlugins("lang-python");
|
||||||
PluginManager.checkForOfficialPlugins("elasticsearch-mapper-murmur3");
|
PluginManager.checkForOfficialPlugins("mapper-murmur3");
|
||||||
|
PluginManager.checkForOfficialPlugins("mapper-size");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PluginManager.checkForOfficialPlugins("elasticsearch-mapper-attachment");
|
PluginManager.checkForOfficialPlugins("elasticsearch-mapper-attachment");
|
||||||
|
|
|
@ -82,12 +82,12 @@ public class PluginManagerUnitTests extends ESTestCase {
|
||||||
Iterator<URL> iterator = handle.urls().iterator();
|
Iterator<URL> iterator = handle.urls().iterator();
|
||||||
|
|
||||||
if (supportStagingUrls) {
|
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());
|
Version.CURRENT.number(), Build.CURRENT.hashShort(), pluginName, Version.CURRENT.number(), pluginName, Version.CURRENT.number());
|
||||||
assertThat(iterator.next().toExternalForm(), is(expectedStagingURL));
|
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");
|
pluginName + "-" + Version.CURRENT.number() + ".zip");
|
||||||
assertThat(iterator.next().toExternalForm(), is(expected.toExternalForm()));
|
assertThat(iterator.next().toExternalForm(), is(expected.toExternalForm()));
|
||||||
|
|
||||||
|
@ -95,10 +95,10 @@ public class PluginManagerUnitTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTrimmingElasticsearchFromOfficialPluginName() throws IOException {
|
public void testOfficialPluginName() throws IOException {
|
||||||
String randomPluginName = randomFrom(PluginManager.OFFICIAL_PLUGINS.asList()).replaceFirst("elasticsearch-", "");
|
String randomPluginName = randomFrom(PluginManager.OFFICIAL_PLUGINS.asList());
|
||||||
PluginManager.PluginHandle handle = PluginManager.PluginHandle.parse(randomPluginName);
|
PluginManager.PluginHandle handle = PluginManager.PluginHandle.parse(randomPluginName);
|
||||||
assertThat(handle.name, is(randomPluginName.replaceAll("^elasticsearch-", "")));
|
assertThat(handle.name, is(randomPluginName));
|
||||||
|
|
||||||
boolean supportStagingUrls = randomBoolean();
|
boolean supportStagingUrls = randomBoolean();
|
||||||
if (supportStagingUrls) {
|
if (supportStagingUrls) {
|
||||||
|
@ -108,12 +108,12 @@ public class PluginManagerUnitTests extends ESTestCase {
|
||||||
Iterator<URL> iterator = handle.urls().iterator();
|
Iterator<URL> iterator = handle.urls().iterator();
|
||||||
|
|
||||||
if (supportStagingUrls) {
|
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());
|
Version.CURRENT.number(), Build.CURRENT.hashShort(), randomPluginName, Version.CURRENT.number(), randomPluginName, Version.CURRENT.number());
|
||||||
assertThat(iterator.next().toExternalForm(), is(expectedStagingUrl));
|
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());
|
randomPluginName, Version.CURRENT.number(), randomPluginName, Version.CURRENT.number());
|
||||||
assertThat(iterator.next().toExternalForm(), is(releaseUrl));
|
assertThat(iterator.next().toExternalForm(), is(releaseUrl));
|
||||||
|
|
||||||
|
@ -121,12 +121,11 @@ public class PluginManagerUnitTests extends ESTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testTrimmingElasticsearchFromGithubPluginName() throws IOException {
|
public void testGithubPluginName() throws IOException {
|
||||||
String user = randomAsciiOfLength(6);
|
String user = randomAsciiOfLength(6);
|
||||||
String randomName = randomAsciiOfLength(10);
|
String pluginName = randomAsciiOfLength(10);
|
||||||
String pluginName = randomFrom("elasticsearch-", "es-") + randomName;
|
|
||||||
PluginManager.PluginHandle handle = PluginManager.PluginHandle.parse(user + "/" + pluginName);
|
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(), hasSize(1));
|
||||||
assertThat(handle.urls().get(0).toExternalForm(), is(new URL("https", "github.com", "/" + user + "/" + pluginName + "/" + "archive/master.zip").toExternalForm()));
|
assertThat(handle.urls().get(0).toExternalForm(), is(new URL("https", "github.com", "/" + user + "/" + pluginName + "/" + "archive/master.zip").toExternalForm()));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue