|
@@ -73,7 +73,7 @@ public class PluginManager {
|
|
|
// By default timeout is 0 which means no timeout
|
|
|
public static final TimeValue DEFAULT_TIMEOUT = TimeValue.timeValueMillis(0);
|
|
|
|
|
|
- private static final ImmutableSet<Object> BLACKLIST = ImmutableSet.builder()
|
|
|
+ private static final ImmutableSet<String> BLACKLIST = ImmutableSet.<String>builder()
|
|
|
.add("elasticsearch",
|
|
|
"elasticsearch.bat",
|
|
|
"elasticsearch.in.sh",
|
|
@@ -81,6 +81,21 @@ public class PluginManager {
|
|
|
"plugin.bat",
|
|
|
"service.bat").build();
|
|
|
|
|
|
+ private 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"
|
|
|
+ ).build();
|
|
|
+
|
|
|
private final Environment environment;
|
|
|
private String url;
|
|
|
private OutputMode outputMode;
|
|
@@ -133,6 +148,10 @@ public class PluginManager {
|
|
|
// ignore
|
|
|
log("Failed: " + ExceptionsHelper.detailedMessage(e));
|
|
|
}
|
|
|
+ } else {
|
|
|
+ if (PluginHandle.isOfficialPlugin(pluginHandle.repo, pluginHandle.user, pluginHandle.version)) {
|
|
|
+ checkForOfficialPlugins(pluginHandle.name);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (!downloaded) {
|
|
@@ -384,6 +403,15 @@ public class PluginManager {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ protected static void checkForOfficialPlugins(String name) {
|
|
|
+ // We make sure that users can use only new short naming for official plugins only
|
|
|
+ if (!OFFICIAL_PLUGINS.contains(name)) {
|
|
|
+ throw new IllegalArgumentException(name +
|
|
|
+ " is not an official plugin so you should install it using elasticsearch/" +
|
|
|
+ name + "/latest naming form.");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public Path[] getListInstalledPlugins() throws IOException {
|
|
|
try (DirectoryStream<Path> stream = Files.newDirectoryStream(environment.pluginsFile())) {
|
|
|
return Iterators.toArray(stream.iterator(), Path.class);
|
|
@@ -597,9 +625,15 @@ public class PluginManager {
|
|
|
SysOut.println(" -h, --help : Prints this help message");
|
|
|
SysOut.newline();
|
|
|
SysOut.println(" [*] Plugin name could be:");
|
|
|
- SysOut.println(" elasticsearch/plugin/version for official elasticsearch plugins (download from download.elasticsearch.org)");
|
|
|
+ SysOut.println(" elasticsearch-plugin-name for Elasticsearch 2.0 Core plugin (download from download.elastic.co)");
|
|
|
+ SysOut.println(" elasticsearch/plugin/version for elasticsearch commercial plugins (download from download.elastic.co)");
|
|
|
SysOut.println(" groupId/artifactId/version for community plugins (download from maven central or oss sonatype)");
|
|
|
SysOut.println(" username/repository for site plugins (download from github master)");
|
|
|
+ SysOut.newline();
|
|
|
+ SysOut.println("Elasticsearch Core plugins:");
|
|
|
+ for (String o : OFFICIAL_PLUGINS) {
|
|
|
+ SysOut.println(" - " + o);
|
|
|
+ }
|
|
|
|
|
|
if (message != null) {
|
|
|
SysOut.newline();
|
|
@@ -652,17 +686,26 @@ public class PluginManager {
|
|
|
List<URL> urls() {
|
|
|
List<URL> urls = new ArrayList<>();
|
|
|
if (version != null) {
|
|
|
- // Elasticsearch download service
|
|
|
- addUrl(urls, "http://download.elasticsearch.org/" + user + "/" + repo + "/" + repo + "-" + version + ".zip");
|
|
|
- // Maven central repository
|
|
|
- addUrl(urls, "http://search.maven.org/remotecontent?filepath=" + user.replace('.', '/') + "/" + repo + "/" + version + "/" + repo + "-" + version + ".zip");
|
|
|
- // Sonatype repository
|
|
|
- addUrl(urls, "https://oss.sonatype.org/service/local/repositories/releases/content/" + user.replace('.', '/') + "/" + repo + "/" + version + "/" + repo + "-" + version + ".zip");
|
|
|
- // Github repository
|
|
|
- addUrl(urls, "https://github.com/" + user + "/" + repo + "/archive/" + version + ".zip");
|
|
|
+ // Elasticsearch new download service uses groupId org.elasticsearch.plugins from 2.0.0
|
|
|
+ if (user == null) {
|
|
|
+ // TODO Update to https
|
|
|
+ addUrl(urls, String.format(Locale.ROOT, "http://download.elastic.co/org.elasticsearch.plugins/%1$s/%1$s-%2$s.zip", repo, version));
|
|
|
+ } else {
|
|
|
+ // Elasticsearch old download service
|
|
|
+ // TODO Update to https
|
|
|
+ addUrl(urls, String.format(Locale.ROOT, "http://download.elastic.co/%1$s/%2$s/%2$s-%3$s.zip", user, repo, version));
|
|
|
+ // Maven central repository
|
|
|
+ addUrl(urls, String.format(Locale.ROOT, "http://search.maven.org/remotecontent?filepath=%1$s/%2$s/%3$s/%2$s-%3$s.zip", user.replace('.', '/'), repo, version));
|
|
|
+ // Sonatype repository
|
|
|
+ addUrl(urls, String.format(Locale.ROOT, "https://oss.sonatype.org/service/local/repositories/releases/content/%1$s/%2$s/%3$s/%2$s-%3$s.zip", user.replace('.', '/'), repo, version));
|
|
|
+ // Github repository
|
|
|
+ addUrl(urls, String.format(Locale.ROOT, "https://github.com/%1$s/%2$s/archive/%3$s.zip", user, repo, version));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (user != null) {
|
|
|
+ // Github repository for master branch (assume site)
|
|
|
+ addUrl(urls, String.format(Locale.ROOT, "https://github.com/%1$s/%2$s/archive/master.zip", user, repo));
|
|
|
}
|
|
|
- // Github repository for master branch (assume site)
|
|
|
- addUrl(urls, "https://github.com/" + user + "/" + repo + "/archive/master.zip");
|
|
|
return urls;
|
|
|
}
|
|
|
|
|
@@ -708,6 +751,10 @@ public class PluginManager {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ if (isOfficialPlugin(repo, user, version)) {
|
|
|
+ return new PluginHandle(repo, Version.CURRENT.number(), null, repo);
|
|
|
+ }
|
|
|
+
|
|
|
if (repo.startsWith("elasticsearch-")) {
|
|
|
// remove elasticsearch- prefix
|
|
|
String endname = repo.substring("elasticsearch-".length());
|
|
@@ -722,6 +769,10 @@ public class PluginManager {
|
|
|
|
|
|
return new PluginHandle(repo, version, user, repo);
|
|
|
}
|
|
|
+
|
|
|
+ static boolean isOfficialPlugin(String repo, String user, String version) {
|
|
|
+ return version == null && user == null && !Strings.isNullOrEmpty(repo);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|