-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Pluginmanager clean after mutate #17203
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--- | ||
services: | ||
- logstash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
require 'pathname' | ||
|
||
shared_context "pluginmanager validation helpers" do | ||
|
||
matcher :be_installed_gem do | ||
match do |actual| | ||
common(actual) | ||
@gemspec_present && @gem_installed | ||
end | ||
|
||
match_when_negated do |actual| | ||
common(actual) | ||
!@gemspec_present && !@gem_installed | ||
end | ||
|
||
define_method :common do |actual| | ||
version_suffix = /-[0-9.]+(-java)?$/ | ||
filename_matcher = actual.match?(version_suffix) ? actual : /^#{Regexp.escape(actual)}#{version_suffix}/ | ||
|
||
@gems = (logstash_gemdir / "gems").glob("*-*") | ||
@gemspecs = (logstash_gemdir / "specifications").glob("*-*.gemspec") | ||
|
||
@gem_installed = @gems.find { |gem| gem.basename.to_s.match?(filename_matcher) } | ||
@gemspec_present = @gemspecs.find { |gemspec| gemspec.basename(".gemspec").to_s.match?(filename_matcher) } | ||
end | ||
|
||
failure_message do |actual| | ||
reasons = [] | ||
reasons << "the gem dir could not be found (#{@gems})" unless @gem_installed | ||
reasons << "the gemspec could not be found (#{@gemspecs})" unless @gemspec_present | ||
|
||
"expected that #{actual} would be installed, but #{reasons.join(' and ')}" | ||
end | ||
failure_message_when_negated do |actual| | ||
reasons = [] | ||
reasons << "the gem dir is present (#{@gem_installed})" if @gem_installed | ||
reasons << "the gemspec is present (#{@gemspec_present})" if @gemspec_present | ||
|
||
"expected that #{actual} would not be installed, but #{reasons.join(' and ')}" | ||
end | ||
end | ||
|
||
def logstash_home | ||
return super() if defined?(super) | ||
return @logstash.logstash_home if @logstash | ||
fail("no @logstash, so we can't get logstash_home") | ||
end | ||
|
||
def logstash_gemdir | ||
pathname_base = (Pathname.new(logstash_home) / "vendor" / "bundle" / "jruby") | ||
candidate_dirs = pathname_base.glob("[0-9]*") | ||
case candidate_dirs.size | ||
when 0 then fail("no version dir found in #{pathname_base}") | ||
when 1 then candidate_dirs.first | ||
else | ||
fail("multiple version dirs found in #{pathname_base} (#{candidate_dirs.map(&:basename)}") | ||
end | ||
end | ||
end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this expensive to load on startup? Why do we wait until method is called to load implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there are a couple reasons why I did it this way.
First, it follows the prior art in this source file.
But I think the bigger factor is that the plugin manager is invoked stand-alone, and is not typically a long-running process, so there's less of a stability benefit to eager-loading. I don't believe that having the uninstaller present will have side-effects for the non-mutation
list
command, but I'd rather not take chances.