Commit graph

44 commits

Author SHA1 Message Date
Pier-Hugues Pellerin
db0ded3d60 Make sure prepare_offline_pack command only accept a filename
This PR changes the behavior of the command when you were specify a directory
instead of a filename, if the directory exists it would have deleted the
directory and the files in it.

The new flow and validation is now safer, if you specify a directory
Logstash will tell you to specify a complete filename.

If the ZIP extension is missing, the command line will ask you to make
sure you target a right filename.

If the output file already exist it will *not* delete it but instead
will return a warning message, you can force a delete by using the
`--overwrite` option.

Fixes: #6862

Fixes #6861
2017-03-31 11:05:17 -04:00
Jordan Sissel
282156b240 Open file in binary mode.
Fixes #6640
2017-02-06 00:03:00 -05:00
Pier-Hugues Pellerin
fdd73e0cfc Ignore NIL/EMPTY values for LOGSTASH_PACK_URL environment variable
Fixes #6611
2017-02-02 09:15:42 -05:00
Pier-Hugues Pellerin
034b15d905 Allow to run the bin/logstash-plugin install <pack> outside of the Logstash directory
Fixes: #6599

Fixes #6602
2017-01-31 13:33:31 -05:00
Pier-Hugues Pellerin
1b812af23c Add bin/logstash-plugin prepare-offline-pack command
This new command replace the old workflow of `pack`, `unpack` and the `install --local`, and wrap all the logic into one uniform way of installing plugins.
The work is based on the flow developed for installing an x-pack inside Logstash, when you call prepare-offline-pack, the specified plugins and their dependencies will be packaged in a zip.
And this zip can be installed with the same flow as the pack.

Definition:

Source Logstash: Where you run the prepare-offline-pack.
Target Logstash: Where you install the offline package.

PROS:
- If you install a .gem in the source logstash, the .gem and his dependencies will be bundled.
- The install flow doesn't need to have access to the internet.
- Nothing special need to be setup in the target logstash environment.

CONS:
- The is one minor drawback, the plugins need to have their JARS bundled with them for this flow to work, this is currently the case for all the official plugins.
- The source Logstash need to have access to the internet when you install plugins before packaging them.

Usage examples:
bin/logstash-plugin prepare-offline-pack logstash-input-beats
bin/logstash-plugin prepare-offline-pack logstash-filter-jdbc logstash-input-beats
bin/logstash-plugin prepare-offline-pack logstash-filter-*
bin/logstash-plugin prepare-offline-pack logstash-filter-* logstash-input-beats

How to install:
bin/logstash-plugin install file:///tmp/logstash-offline-plugins-XXXX.zip

Fixes #6404
2017-01-03 13:59:51 -05:00
Pier-Hugues Pellerin
c749d16bd4 Make it work with update too
Fixes #6410
2016-12-16 10:27:33 -05:00
Pier-Hugues Pellerin
14ff5f98a3 Turn off any jar-dependencies lookup when running install command with --local
Fixes: #6386

Fixes #6410
2016-12-16 10:27:33 -05:00
Pier-Hugues Pellerin
0b881c78a6 Explicitely require LogStash::Bundler.setup! make the plugin install process to require internet access
Fixes: #6386

Fixes #6388
2016-12-13 09:43:57 -05:00
Pier-Hugues Pellerin
f42807518f Do not clean unused gems after updating gems
The are a difference between the gems installed and the available spec
loaded in memory making bundler remove the gem that we have just
updated.

Fixes: #6339

Fixes #6340
2016-12-01 18:57:07 -05:00
Pier-Hugues Pellerin
fe8c438b24 Logstash-docgen tool v2
**Motivation**: We have decided to rewrite the documentation generator to add more features
to our documentation and to fix some outstanding bugs.

This PR addresses the following problem:
- Hard to add new features to the code base.
- The code was tied with Logstash.
- No easy way to publish the doc for a single plugin
- The plugin author was not able to test their documentation changes
- The reported errors were hard to understand.
- No easy way to automate it.
- the minimal requirement on base classes.

Fixes #5720
2016-11-30 19:57:40 -05:00
Pier-Hugues Pellerin
4f5f3490aa Relax the acceptance test expectation to match only the exception message
Fixes: #6310

Fixes #6325
2016-11-29 14:24:37 -05:00
Pier-Hugues Pellerin
00e225a849 Feature: A way to install/remove a plugin pack
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
2016-11-17 14:00:02 -05:00
Pier-Hugues Pellerin
ab89a90a4c This PR changes two things:
- Allow plugins author to decide how their plugins are structured
- Allow a new kind of plugin that allow plugins author to add hooks into logstash core.

Fixes #6109
2016-11-11 09:43:44 -05:00
Guillaume Le Floch
1a0fcfd211 remove duplicate list subcommand
When running `./logstash-plugin --help`, there was twice time the list sub command

Fixes #6205
2016-11-07 17:59:38 -05:00
Suyog Rao
9c5e558c5a Deprecate uninstall for Plugin Manager
Adds remove and deprecates uninstall

Fixes #6041

Fixes #6042
2016-10-13 10:12:23 -04:00
Andrew Cholakian
f35c416893 Add new Codec#encode_sync, Codec#multi_encode and Output#multi_receive_encoded methods.
These methods allow outputs to receive their events pre-encoded for them
by the pipeline. This is mostly useful in the context of `#shared` outputs, for whom
encoding a discrete batch in a threadsafe way is not necessarily straightforward.

It would be advised for codecs to prefer `#multi_encode` as the main way of operating
as the standard `#encode` method is not threadsafe.

Fixes #5770
2016-08-22 14:08:04 -04:00
Suyog Rao
47545d6859 Remove use of map
Fixes #5740
2016-08-08 16:33:02 -04:00
Suyog Rao
53bd15e1f4 Fix warning when no local plugins are found
Fixes #5740
2016-08-08 16:33:02 -04:00
Suyog Rao
6437ce9931 Remove validate warning because its useless
Fixes #5686

Fixes #5729
2016-08-04 17:31:37 -04:00
Pere Urbon-Bayes
76c901cceb wrap usage of Gems.versions withing a patch that forces UTF-8 encoding
locate the patch to his own location

rename patches directory

Fixes #5486
2016-06-15 06:45:44 -04:00
Pere Urbon-Bayes
d249bd1705 add codec as a new kind of templates in the plugin generator
Fixes #5421
2016-06-01 16:15:37 +00:00
Pere Urbon-Bayes
f5cc745be7 add more control on valid arguments for codecs in the generator command
Fixes #5419
2016-06-01 16:06:19 +00:00
Philippe Weber
be9bac9ec5 fix config_name for generated input plugin
Fixes #5355
2016-05-24 22:00:38 +00:00
Philippe Weber
4f96f235e2 use new event api in generator filter template
Fixes #5355
2016-05-24 22:00:38 +00:00
Philippe Weber
dafe75d89e display correct path of created files
Fixes #5355
2016-05-24 22:00:38 +00:00
Philippe Weber
e2b5c873e6 make plugin name parameter required
Fixes #5355
2016-05-24 22:00:38 +00:00
Philippe Weber
464bdcabb5 fix to allow direct execution of 'bundle install'
Fixes #5355
2016-05-24 22:00:38 +00:00
Pere Urbon-Bayes
6c92fa9f58 Add a new command that generate a plugin skeleton that can be used to create a new plugin
Fixes #4190
2016-05-24 16:14:46 +00:00
Colin Surprenant
b0e2c7621b add --preserve option to plugin install
add missing overwrite method and preserve @gems_by_name when updating

log options preservation

discards no constrains constrains

rewording
2016-04-29 16:11:51 -04:00
Suyog Rao
683302e26d Rename bin/plugin to bin/logstash-plugin
This adds support for packs and fixes the problem where bin/plugin
pollutes the PATH namespace

Fixes #4871

Fixes #4874
2016-03-24 00:23:15 +00:00
Pere Urbon-Bayes
2195f145b2 This adds a feature to let users dump all their installed plugins,
including dependencies, and reuse them in an offline installation by
providing an package for it. It adds two important commands to the
plugin manager, the pack and upack, to handle package creation and
installation and adds the --local flag to install and update to pull
plugins from the installed local packages.

Former commits:

add a task to create a bundle, under vendor/cache of the installed gems + their dependencies, this can be used later on to be installed offline

add an option to pass the --local flag to the bin/plugin update task, so it fetch plugins from a local cache, by default under vendor/cache

rename package:build to package:build-cache as is more meaningfull

add a --local flag to bin/plugin install to users can install plugins from the local cache, under the default directory of vendor/cache

add a plugin manager command to build the local cache of installed plugins using bundler package alike command

It adds code for compressing and extracting in zip and tar formats to
the utils module of logstash. The zip module is only jruby dependant as
it uses functions provided by java.
There is also code add in the plugin manager package command to handle
compression of plugins dumping.

Cleanup the custom java code to compress and extract zip files as it has
been known that using rubyzip is good and it has a more ruby like
features so the code is more clean and portable.

set of smallish improvement requested during review

added several options to handle situation when the package of plugins we want to generate is already there

clean up old code

applyed feedback from review, mostly changed in documentating behaviour plus better wording for messages

relocate the Environment.windows? check to the bootstrap side as it's used also in the plugin manager

add an unpack bin/plugin command so users can install packages of plugins throw the plugin manager

document override behaviour in the compress helpers (for zip and tar) plus add a fix for the tar extract when reading entries

made the unpack filename parameter a required one

add a force option to the bin/plugin unpack command

add a notice to that if using a local cache the --local flag should be passed with

Code cleanup and refactor introduced during review

add two wording suggestions comming from review

ammend more wording

skip the major version validation as in situation where there is no internet connection like when using the local vendor/cache to do the update

move compress to the bootstrap environment as being used in the plugin manager means not being loaded with logstash-core

Bring pack cached gems in the vendor directory so they can be used for bundler when packaging dependencies

Revert "Bring pack cached gems in the vendor directory so they can be used for bundler when packaging dependencies"

This reverts commit a9d7f46649932b06efaafebdd0eed2b4c63c2235.

patch the Bundler::Source::Rubygems to fetch only gems from a remote  source

small changes in several parts of the plugin manager and the creation of a common pack command with shared code

change compress to read in chuncks

fix wrong var name in the bootstrap compress utils module

fix namespacing conflicts

add basic test for the compress utility module

ammend more namespace issues

add a comment to the rubygems mockey patch to rebuild the gem cache

apply cosmetic changes

make the compress module raise CompressError

remove vendor_path and pattern_path form environment as they where mix up during rebase

change the bin/pack force option to be force-delete-cache

rename force_delete_cache to overwrite

change force for overwrite in tha pack command

remove the override option for bin/plugin unpack

revert Gemfile and Genfile.lock wrong committed
2015-11-18 12:03:51 +01:00
Pere Urbon-Bayes
ba96b1f0b3 Fix the plugin manager install and update commands to perform the validation properly when a private gem server (not rubygems) has been configured. This basically loads the sources so the system is able to perform the validation with the right destionation and not with the default source (rubygems.org)
Former commits:

add all defined sources to rubygems so verification can talk to all the repositories, even the private ones

added a very simple plugin manager install command spec, to check for properly loading sources when validating

broke long lines into smaller ones in the install command

make sure the update command takes into account all declared sources, plus there is the option to avoid gem validation in case of only having a private gem repo and no internet connection

fix wrong conditional in the validation of plugins

move the Gem.sources loading to a common place, to sources are loaded all at once and we don't need to worry on each call to be sure we do the right thing for other sources different that rubygems

update test to the last changes in the way gemfile is loaded

move Gem::SourceList.from to bundler::invoke! so we use the default gemset.sources array

fix loading path for Gem::SourceList in bundler, so it's not colliding with other classes

Revert "move the Gem.sources loading to a common place, to sources are loaded all at once and we don't need to worry on each call to be sure we do the right thing for other sources different that rubygems"

This reverts commit 6e1c809665d61495b5461e7522a7adc745fe27fc.

Revert "update test to the last changes in the way gemfile is loaded"

This reverts commit dc5f65c2ac5380b1640cb732946f1a8ababcc9dc.

make the Gem.sources load to happen inside the logstash_plugin? call

add the idea of settings to the plugin manager module, like this we can pass throw different stuff usefull to setup dependant components

add the install spec back

remove the PluginManager::Settings concept

change sources for rubygems_sources in the plugin manager options

change rubygems_sources to be rubygems_source

update comments

ammend plugin manager options description in the comments

spaces and new lines cleanup

merged duplicated plugin manager util_spec introduced during rebase

add a check when Gems.versions fail

Add the validation exception for the plugin manager

add better error handling for situation where the validation is not possible due to a connection issue with the remote server

Fixes #3583
2015-11-17 08:38:55 +00:00
Aaron Mildenstein
eb8f6387f3 Replace "Install" with "Update" where appropriate
fixes #4116

Fixes #4117
2015-10-29 18:41:29 +00:00
Pere Urbon-Bayes
a3fc9476cc Fix the update command to only work with installed plugins gems so it's not having problems with not purged plugins
Fixes #3731
2015-09-11 06:49:54 +00:00
Pere Urbon-Bayes
ae4c49be3b Exclude pre releases when checking if the update is targetting a major release in the plugin manager, as bundler is not going to update anyway to this version without an explicit install command.
Fixes #3826
2015-09-02 21:17:02 +00:00
Pere Urbon-Bayes
028d76497c add the missing magic header # encoding: utf-8 so all internal strings are UTF-8 in Ruby < 2.0
Fixes #3723
2015-08-17 13:30:07 +00:00
Pere Urbon-Bayes
a81f0249b1 locate plugin manager command dependencies to the specific commands as it should be
Fixes #3509
2015-07-02 14:17:50 +00:00
Pere Urbon-Bayes
4677f0a54b add a validation fase with a warning in case you're updating plugins to a new major version
Fixes #3423
2015-06-17 10:05:58 +00:00
Jason Woods
93882095e4 Show errors encountered when validating a plugin rather than saying it does not exist
Fixes #3407
2015-06-11 14:17:26 +00:00
Pere Urbon-Bayes
0d82ae87c1 fix the issue caused by jruby-kafka that prevent to run the packaging
Fixes #3393
2015-06-08 17:25:41 +00:00
Pere Urbon-Bayes
d44e6e15a3 fix the uninstall of plugins
Fixes #3362
2015-06-08 13:13:07 +00:00
Pier-Hugues Pellerin
214f3b9e44 Allow to update all the plugins and skip locally defined gems fixes #3157
Review comments

Fixes #3179
2015-05-11 14:15:14 +00:00
Colin Surprenant
7a1ec64c23 use :build dependencies
fix octokit dep

fixes #3171
2015-05-06 08:27:57 -04:00
Colin Surprenant
48bcc5b74d cleanup dependencies and rely on logstash-core gem
remove unused load path

use either local core lib dir or logstash-core gem

include spec in logstash-core

do not include lib, spec and locales dirs in package root

environment bootstrapping in lib/bootstrap.rb

added comments

move pluginmanager out of logstash-core

kafla installation solved by pluginmanager refactor

refactor bootstrap code

refactor shell scripts to simplify and DRY, indirect rspec command to our ruby launcher

add bin/rspec

cut by half the bin/plugin and bin/rspec startup time

fix drip context

use printf instead of tr

updated Windows bin scripts

missing gemspec in gemspec

use gem instead of gemspec so our plugin manager can correctly install logstash-core

generate packages including locally built logstash-core gem

move jenkins developmnent dependencies into Gemfile, they do not belong in logstash-core

path leftover

clean help agent help usage message and remore rspec in available command

comments cosmetics

update Bundler dependency, all recent testing have been made with 1.9.4

updated .lock file with regard to updated Gemfile

cleanup gemspec, Gemfile and regen .lock file

added progress output

avoid dual require on version

closes #3096
2015-05-04 18:17:22 -04:00