-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
chore(external docs): generate global option configuration automatically from Rust code #22345
Merged
pront
merged 18 commits into
vectordotdev:master
from
titaneric:feat/global-options-auto-docs
Feb 8, 2025
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
978c945
try add new `global_options` component type
titaneric d03d46b
Generate enrichment tables global options docs
titaneric 7b40be9
Remove plural form for global option component
titaneric 57978bb
Re-generate the doc for enrichment table
titaneric 6502d80
Generate schema by each field of global option
titaneric d29dda4
Generate schema for secrets
titaneric a74c0fa
Remove second option for configurable component
titaneric 9da15aa
Fix description for schema defined in file
titaneric 68080bd
Remove redundant enrichment table doc
titaneric ccfb2af
Reference base enrichment table and secret type in global configuration
titaneric 281f2ee
Move `common` and `required` fields from base to overlay config
titaneric b7c9767
Refactor ruby code to generate the global option base schema
titaneric b62e85b
Fix reference global schema
titaneric 5fdf5e4
Fix URL link in markdown
titaneric 200b9a2
Rename secrets to secret (follow the config)
titaneric b1606c7
Fix script check
titaneric 23d488c
make cue format
titaneric 8d46c37
Fix links
titaneric 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 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 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 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 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 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 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 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 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 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 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 |
---|---|---|
@@ -1,10 +1,10 @@ | ||
//! Functionality to handle enrichment tables. | ||
use crate::sinks::prelude::SinkConfig; | ||
use enum_dispatch::enum_dispatch; | ||
use vector_lib::configurable::{configurable_component, NamedComponent}; | ||
use vector_lib::configurable::configurable_component; | ||
pub use vector_lib::enrichment::{Condition, IndexHandle, Table}; | ||
|
||
use crate::config::{EnrichmentTableConfig, GlobalOptions}; | ||
use crate::config::{EnrichmentTableConfig, GenerateConfig, GlobalOptions}; | ||
|
||
pub mod file; | ||
|
||
|
@@ -17,11 +17,26 @@ pub mod geoip; | |
#[cfg(feature = "enrichment-tables-mmdb")] | ||
pub mod mmdb; | ||
|
||
/// Configurable enrichment tables. | ||
#[configurable_component] | ||
/// Configuration options for an [enrichment table](https://vector.dev/docs/reference/glossary/#enrichment-tables) to be used in a | ||
/// [`remap`](https://vector.dev/docs/reference/configuration/transforms/remap/) transform. Currently supported are: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I notice that there are some links error in the generated CUE when we want to reference pre-defined URL such as |
||
/// | ||
/// * [CSV](https://en.wikipedia.org/wiki/Comma-separated_values) files | ||
/// * [MaxMind](https://www.maxmind.com/en/home) databases | ||
/// * In-memory storage | ||
/// | ||
/// For the lookup in the enrichment tables to be as performant as possible, the data is indexed according | ||
/// to the fields that are used in the search. Note that indices can only be created for fields for which an | ||
/// exact match is used in the condition. For range searches, an index isn't used and the enrichment table | ||
/// drops back to a sequential scan of the data. A sequential scan shouldn't impact performance | ||
/// significantly provided that there are only a few possible rows returned by the exact matches in the | ||
/// condition. We don't recommend using a condition that uses only date range searches. | ||
/// | ||
/// | ||
#[configurable_component(global_option("enrichment_tables"))] | ||
#[derive(Clone, Debug)] | ||
#[serde(tag = "type", rename_all = "snake_case")] | ||
#[enum_dispatch(EnrichmentTableConfig)] | ||
#[configurable(metadata(docs::enum_tag_description = "enrichment table type"))] | ||
pub enum EnrichmentTables { | ||
/// Exposes data from a static file as an enrichment table. | ||
File(file::FileConfig), | ||
|
@@ -45,19 +60,15 @@ pub enum EnrichmentTables { | |
Mmdb(mmdb::MmdbConfig), | ||
} | ||
|
||
// TODO: Use `enum_dispatch` here. | ||
impl NamedComponent for EnrichmentTables { | ||
fn get_component_name(&self) -> &'static str { | ||
match self { | ||
Self::File(config) => config.get_component_name(), | ||
#[cfg(feature = "enrichment-tables-memory")] | ||
Self::Memory(config) => config.get_component_name(), | ||
#[cfg(feature = "enrichment-tables-geoip")] | ||
Self::Geoip(config) => config.get_component_name(), | ||
#[cfg(feature = "enrichment-tables-mmdb")] | ||
Self::Mmdb(config) => config.get_component_name(), | ||
#[allow(unreachable_patterns)] | ||
_ => unimplemented!(), | ||
} | ||
impl GenerateConfig for EnrichmentTables { | ||
fn generate_config() -> toml::Value { | ||
toml::Value::try_from(Self::File(file::FileConfig { | ||
file: file::FileSettings { | ||
path: "path/to/file".into(), | ||
encoding: file::Encoding::default(), | ||
}, | ||
schema: Default::default(), | ||
})) | ||
.unwrap() | ||
} | ||
} |
Oops, something went wrong.
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.
I removed the header here since it would be displayed on the right side
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.
Interesting, yeah it might better without that header.