Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add --preserve option to plugin install #5224

Conversation

colinsurprenant
Copy link
Contributor

@colinsurprenant colinsurprenant commented Apr 29, 2016

Allow using the --preserve option to the plugin install command to preserve any current gem options in the Gemfile for the installation of a plugin gem which is already in the Gemfile.

This is required by #5170 to support specifying plugin gems from a github repo/branch in the Gemfile. I believe this will also help avoiding the unnecessary publication of core plugins snapshots.

Ultimately this allows running the rake test:install* command by keeping current Gemfile gems options, for example a custom in-dev :path option, instead of overwriting them and forcing the use of the published gem.

@@ -90,7 +91,13 @@ def install_gems_list!(install_list)

# Add plugins/gems to the current gemfile
puts("Installing" + (install_list.empty? ? "..." : " " + install_list.collect(&:first).join(", ")))
install_list.each { |plugin, version, options| gemfile.update(plugin, version, options) }
install_list.each do |plugin, version, options|
if preserve?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add a debug log message here to make the behavior known on a per plugin basis?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yap, added!

@purbon
Copy link
Contributor

purbon commented Apr 29, 2016

what about having a few test for this in the great integration test that @ph created? or might be add some checkups as unit test in https://github.com/elastic/logstash/tree/master/spec/pluginmanager ? what do you think?

@purbon
Copy link
Contributor

purbon commented Apr 29, 2016

but in general I do like this option!!! good work!

@colinsurprenant colinsurprenant force-pushed the feature/plugin_install_preserve branch from c4dd96a to 8905840 Compare April 29, 2016 17:49
@colinsurprenant
Copy link
Contributor Author

@purbon the integration tests in place for the end-user usage should be sufficient since the --preserve option is off by default. We could add integration tests for the behaviour of the option but since this is typically a development option I'm good in doing that in another PR.

install_list.each do |plugin, version, options|
if preserve?
plugin_gem = gemfile.find(plugin)
puts("Preserving Gemfile gem options for plugin #{plugin}") if plugin_gem && !plugin_gem.options.empty?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its would be cool to report the options in the logger.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is not logger instance in the plugin manager

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err I should have said, it would be cool to report what the options this plugins is currently using the the puts output.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh yes. I'd prefer not too because the installed gem option are not just discarded in favour of the options in the Gemfile, they are actually merged in the Gemfile options but at this layer, we don't know yet the result of that merge. Very practically, I don't think the plugins manager ever pass options to install just yet so it can be assumed today that the current options in the Gemfile will be the final options but that could eventually not be the case ... so I don't think it's really worth investing too much time on this now, if we think it's really valuable we can take another look at that point?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we agreed on zoom to not add this.

@ph
Copy link
Contributor

ph commented Apr 29, 2016

OK, I did some initial testing with the command line with this PR, work great so far.
I think we have a lot of collateral tests that will actually check the install command.

I would still prefer to have specific test for it like @purbon mentioned but they can be done in another PR.

Code LGTM.

@colinsurprenant
Copy link
Contributor Author

ok, will open followup issue for integration tests.

add missing overwrite method and preserve @gems_by_name when updating

log options preservation

discards no constrains constrains

rewording
@colinsurprenant colinsurprenant force-pushed the feature/plugin_install_preserve branch from 40089b3 to ccefeae Compare April 29, 2016 20:10
@colinsurprenant colinsurprenant merged commit ccefeae into elastic:master Apr 29, 2016
@colinsurprenant
Copy link
Contributor Author

rebased and merged into master, 5.0 and 2.x

mmguero added a commit to mmguero-dev/Malcolm that referenced this pull request Feb 17, 2022
… logstash will start up up; use --preserve flag implemented in elastic/logstash#5224
mmguero added a commit to cisagov/Malcolm that referenced this pull request Feb 24, 2022
… logstash will start up up; use --preserve flag implemented in elastic/logstash#5224
mmguero added a commit to idaholab/Malcolm that referenced this pull request Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants