Skip to content

Commit

Permalink
chore(vrl): Remove deprecated metadata functions (#14821)
Browse files Browse the repository at this point in the history
  • Loading branch information
fuchsnj authored Feb 10, 2023
1 parent 18fedcf commit f8a0b2a
Show file tree
Hide file tree
Showing 19 changed files with 45 additions and 587 deletions.
75 changes: 0 additions & 75 deletions lib/vector-vrl-functions/src/get_metadata_field.rs

This file was deleted.

34 changes: 0 additions & 34 deletions lib/vector-vrl-functions/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
#![deny(warnings)]

pub mod get_metadata_field;
pub mod get_secret;
pub mod remove_metadata_field;
pub mod remove_secret;
pub mod set_metadata_field;
pub mod set_secret;
pub mod set_semantic_meaning;

use ::value::Value;
use lookup::OwnedTargetPath;
use vrl::prelude::*;

pub(crate) fn legacy_keys() -> Vec<Value> {
LEGACY_METADATA_KEYS
.iter()
.map(|key| (*key).into())
.collect()
}

#[allow(clippy::large_enum_variant)]
#[derive(Clone, Debug)]
Expand All @@ -30,31 +18,9 @@ pub const LEGACY_METADATA_KEYS: [&str; 2] = ["datadog_api_key", "splunk_hec_toke

pub fn vrl_functions() -> Vec<Box<dyn vrl::Function>> {
vec![
Box::new(get_metadata_field::GetMetadataField) as _,
Box::new(remove_metadata_field::RemoveMetadataField) as _,
Box::new(set_metadata_field::SetMetadataField) as _,
Box::new(set_semantic_meaning::SetSemanticMeaning) as _,
Box::new(get_secret::GetSecret) as _,
Box::new(remove_secret::RemoveSecret) as _,
Box::new(set_secret::SetSecret) as _,
]
}

fn get_metadata_key(
arguments: &mut ArgumentList,
) -> std::result::Result<MetadataKey, Box<dyn DiagnosticMessage>> {
if let Ok(Some(query)) = arguments.optional_query("key") {
if let vrl::query::Target::External(_) = query.target() {
// for backwards compatibility reasons, the query is forced to point at metadata
let target_path = OwnedTargetPath::metadata(query.path().clone());
return Ok(MetadataKey::Query(target_path));
}
}

let key = arguments.required_enum("key", &legacy_keys())?;
Ok(MetadataKey::Legacy(
key.try_bytes_utf8_lossy()
.expect("key not bytes")
.to_string(),
))
}
114 changes: 0 additions & 114 deletions lib/vector-vrl-functions/src/set_metadata_field.rs

This file was deleted.

Loading

0 comments on commit f8a0b2a

Please sign in to comment.