forked from vectordotdev/vector
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(schemas): Dont panic with non object field kinds (vectordotdev#17140
) * Dont panic with non object field kinds Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> * Check remap input definition is never Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> * Spelling Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> * Add enrichment tables to the transform outputs Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> * Handle remap array outputs Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> * Return the panics Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> * Revert "Return the panics" This reverts commit 8ed6528. * Return the panics Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> * Added multiple transform tests Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> * Mild spacing Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> * Mild spacing Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> * Add transport_output_ids to wrap calls to output that don't need definitions Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> * Test even a VRL error results in the correct ports Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> * Test a mix of array and non array results Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> * Error if a returned definition contains never Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> * Remove never check in transform, the framework should handle it Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> * Feedback from Kyle Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> * Feedback from Kyle Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> * Feedback from Spencer Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> * Spelling Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> * Feedback from Nathan Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> * Whitespace Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> * Only use transform definition fields when schema is enabled Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> * Fixed syntax error Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> * Clippy Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> * Fixed test. Non object top level fields need removing Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com> --------- Signed-off-by: Stephen Wakely <fungus.humungus@gmail.com>
- Loading branch information
1 parent
8067f84
commit 1e43208
Showing
29 changed files
with
855 additions
and
119 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
use async_trait::async_trait; | ||
use snafu::Snafu; | ||
use value::Kind; | ||
use vector_config::configurable_component; | ||
use vector_core::{ | ||
config::{DataType, Input, LogNamespace, TransformOutput}, | ||
schema::Definition, | ||
transform::Transform, | ||
}; | ||
|
||
use crate::config::{OutputId, TransformConfig, TransformContext}; | ||
|
||
#[derive(Debug, Snafu)] | ||
enum Error { | ||
#[snafu(display("It all went horribly wrong"))] | ||
ItAllWentHorriblyWrong, | ||
} | ||
|
||
/// Configuration for the `test_error_definition` transform. | ||
#[configurable_component(transform("test_error_definition", "Test (error definition)"))] | ||
#[derive(Clone, Debug, Default)] | ||
pub struct ErrorDefinitionTransformConfig {} | ||
|
||
impl_generate_config_from_default!(ErrorDefinitionTransformConfig); | ||
|
||
#[async_trait] | ||
#[typetag::serde(name = "test_error_definition")] | ||
impl TransformConfig for ErrorDefinitionTransformConfig { | ||
fn input(&self) -> Input { | ||
Input::all() | ||
} | ||
|
||
fn outputs( | ||
&self, | ||
_: enrichment::TableRegistry, | ||
definitions: &[(OutputId, Definition)], | ||
_: LogNamespace, | ||
) -> Vec<TransformOutput> { | ||
vec![TransformOutput::new( | ||
DataType::all(), | ||
definitions | ||
.iter() | ||
.map(|(output, definition)| { | ||
( | ||
output.clone(), | ||
// Return a definition of Kind::never implying that we can never return a value. | ||
Definition::new_with_default_metadata( | ||
Kind::never(), | ||
definition.log_namespaces().clone(), | ||
), | ||
) | ||
}) | ||
.collect(), | ||
)] | ||
} | ||
|
||
async fn build(&self, _: &TransformContext) -> crate::Result<Transform> { | ||
// Even though the definitions returned were `Kind::never`, build needs to be | ||
// called in order to return the Error. | ||
Err(Error::ItAllWentHorriblyWrong.into()) | ||
} | ||
} |
Oops, something went wrong.