-
Notifications
You must be signed in to change notification settings - Fork 12
A doc generator implementation for aliased plugin. #68
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 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
e4df360
A doc generator implementation for aliased plugin.
mashhurs b0cfd4d
Load aliased plugins from truth of source and remove hard coded sources.
mashhurs 0b55def
A doc generator implementation for aliased plugin.
mashhurs af7f804
A doc generator implementation for aliased plugin.
mashhurs c921390
Place alias doc generation logic in reference doc generator.
mashhurs 0bbe879
Load alias doc header and replace when generating a doc for alias plu…
mashhurs 5a846a6
Simplify the logic, cleaning the code.
mashhurs 59e7fb3
Merge branch 'main' into aliased-plugin-doc-generator
mashhurs 284577a
Review feedbacks applied.
mashhurs 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| # encoding: utf-8 | ||
|
|
||
| require_relative 'plugin' | ||
|
|
||
| module LogstashDocket | ||
|
|
||
| class AliasPlugin | ||
|
|
||
| SUPPORTED_TYPES = Set.new(%w(input output filter codec).map(&:freeze)).freeze | ||
|
|
||
| include Plugin | ||
|
|
||
| attr_reader :canonical_plugin, :doc_headers | ||
|
|
||
| def initialize(canonical_plugin:, alias_name:, doc_headers:) | ||
| fail(ArgumentError) unless canonical_plugin.kind_of?(ArtifactPlugin) | ||
|
|
||
| super(type: canonical_plugin.type, name: alias_name) | ||
|
|
||
| fail("#{canonical_plugin.desc} plugin type #{type} not supported as an integration plugin") unless SUPPORTED_TYPES.include?(type) | ||
|
|
||
| @canonical_plugin = canonical_plugin | ||
| @doc_headers = doc_headers | ||
| end | ||
|
|
||
| ## | ||
| # @see Plugin#version | ||
| def version | ||
| @canonical_plugin.version | ||
| end | ||
|
|
||
| def documentation | ||
| content = @canonical_plugin.documentation | ||
| @doc_headers.each { |header| content = content.gsub(header["replace"], header["with"]) } | ||
| content | ||
mashhurs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| end | ||
|
|
||
| ## | ||
| # @see Plugin#release_date | ||
| def release_date | ||
| @canonical_plugin.release_date | ||
| end | ||
|
|
||
| ## | ||
| # @see Plugin#changelog_url | ||
| def changelog_url | ||
| @canonical_plugin.changelog_url | ||
| end | ||
|
|
||
| ## | ||
| # @see Plugin#tag | ||
| def tag | ||
| @canonical_plugin.tag | ||
| end | ||
|
|
||
| ## | ||
| # @see Plugin#desc | ||
| def desc | ||
| @desc ||= "[plugin:#{canonical_name}@#{tag}]" | ||
| end | ||
|
|
||
| ## | ||
| # @see Plugin#== | ||
| def ==(other) | ||
| return false unless super | ||
|
|
||
| return false unless other.kind_of?(AliasPlugin) | ||
| return false unless self.canonical_plugin == other.canonical_plugin | ||
mashhurs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| return true | ||
| end | ||
| end | ||
| end | ||
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,20 @@ | ||
| # encoding: utf-8 | ||
|
|
||
| require "yaml" | ||
| require "net/http" | ||
|
|
||
| module LogstashDocket | ||
| module Util | ||
| ## | ||
| # A util class defines repetitive logics for aliased plugins. | ||
| # | ||
| class AliasPluginUtil | ||
mashhurs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ALIAS_MAPPINGS_URL = 'https://raw.githubusercontent.com/elastic/logstash/master/logstash-core/src/main/resources/org/logstash/plugins/AliasRegistry.yml' | ||
mashhurs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| def fetch_alias_mappings | ||
| YAML::safe_load(Net::HTTP.get(URI(ALIAS_MAPPINGS_URL))) || {} | ||
mashhurs marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| end | ||
| end | ||
| end | ||
| end | ||
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
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.
Uh oh!
There was an error while loading. Please reload this page.