mirror of
https://github.com/elastic/logstash.git
synced 2025-04-25 23:27:19 -04:00
A pack in this context is a *bundle* of plugins that can be distributed outside of rubygems; it is similar to what ES and kibana are doing, and the user interface is modeled after them. See https://www.elastic.co/downloads/x-pack **Do not mix it with the `bin/logstash-plugin pack/unpack` command.** - it contains one or more plugins that need to be installed - it is self-contains with the gems and the needed jars - it is distributed as a zip file - the file structure needs to follow some rules. - As a reserved name name on elastic.co download http server - `bin/plugin install logstash-mypack` will check on the download server if a pack for the current specific logstash version exist and it will be downloaded, if it doesn't exist we fallback on rubygems. - The file on the server will follow this convention `logstash-mypack-{LOGSTASH_VERSION}.zip` - As a fully qualified url - `bin/plugin install http://test.abc/logstash-mypack.zip`, if it exists it will be downloaded and installed if it does not we raise an error. - As a local file - `bin/plugin install file:///tmp/logstash-mypack.zip`, if it exists it will be installed Fixes #6168
44 lines
1.2 KiB
Ruby
44 lines
1.2 KiB
Ruby
# encoding: utf-8
|
|
require "pluginmanager/utils/http_client"
|
|
require "pluginmanager/pack_installer/local"
|
|
require "pluginmanager/pack_installer/remote"
|
|
require "pluginmanager/ui"
|
|
require "net/http"
|
|
require "uri"
|
|
|
|
module LogStash module PluginManager module PackFetchStrategy
|
|
class Uri
|
|
class << self
|
|
def get_installer_for(plugin_name)
|
|
begin
|
|
uri = URI.parse(plugin_name)
|
|
|
|
if local?(uri)
|
|
PluginManager.ui.debug("Local file: #{uri.path}")
|
|
return LogStash::PluginManager::PackInstaller::Local.new(uri.path)
|
|
elsif http?(uri)
|
|
PluginManager.ui.debug("Remote file: #{uri}")
|
|
return LogStash::PluginManager::PackInstaller::Remote.new(uri)
|
|
else
|
|
return nil
|
|
end
|
|
rescue URI::InvalidURIError,
|
|
URI::InvalidComponentError,
|
|
URI::BadURIError => e
|
|
|
|
PluginManager.ui.debug("Invalid URI for pack, uri: #{uri}")
|
|
return nil
|
|
end
|
|
end
|
|
|
|
private
|
|
def http?(uri)
|
|
!uri.scheme.nil? && uri.scheme.match(/^http/)
|
|
end
|
|
|
|
def local?(uri)
|
|
!uri.scheme.nil? && uri.scheme == "file"
|
|
end
|
|
end
|
|
end
|
|
end end end
|