Skip to content

Commit

Permalink
chore(remap): move vrl crates to lib/vrl
Browse files Browse the repository at this point in the history
Signed-off-by: Jean Mertz <git@jeanmertz.com>
  • Loading branch information
JeanMertz committed Feb 4, 2021
1 parent 6fca455 commit 65a03c3
Show file tree
Hide file tree
Showing 261 changed files with 253 additions and 252 deletions.
25 changes: 11 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ members = [
"lib/k8s-test-framework",
"lib/portpicker",
"lib/prometheus-parser",
"lib/remap-cli",
"lib/remap-compiler",
"lib/remap-diagnostic",
"lib/remap-functions",
"lib/remap-lang",
"lib/remap-parser",
"lib/remap-tests",
"lib/shared",
"lib/tracing-limit",
"lib/vector-api-client",
"lib/vector-wasm",
"lib/vrl/cli",
"lib/vrl/compiler",
"lib/vrl/core",
"lib/vrl/diagnostic",
"lib/vrl/parser",
"lib/vrl/stdlib",
"lib/vrl/tests",
]

[dependencies]
Expand All @@ -65,7 +65,7 @@ prometheus-parser = { path = "lib/prometheus-parser", optional = true }
shared = { path = "lib/shared" }
tracing-limit = { path = "lib/tracing-limit" }
vector-api-client = { path = "lib/vector-api-client", optional = true }
remap-cli = { path = "lib/remap-cli", optional = true }
vrl-cli = { path = "lib/vrl/cli", optional = true }

# Tokio / Futures
futures01 = { package = "futures", version = "0.1.25" }
Expand Down Expand Up @@ -128,9 +128,9 @@ number_prefix = { version = "0.4", optional = true }
crossterm = { version = "0.19.0", optional = true }
tui = { version = "0.14.0", optional = true, default-features = false, features = ["crossterm"] }

# Remap Lang
remap = { package = "remap-lang", path = "lib/remap-lang" }
remap-functions = { path = "lib/remap-functions" }
# VRL Lang
vrl = { path = "lib/vrl/core" }
vrl-stdlib = { path = "lib/vrl/stdlib" }

# External libs
derivative = "2.1.1"
Expand Down Expand Up @@ -299,9 +299,6 @@ wasm = ["lucetc", "lucet-runtime", "lucet-wasi", "vector-wasm"]
# transforms and sinks should depend on this feature.
kubernetes = ["k8s-openapi", "evmap"]

# VRL
vrl-cli = ["remap-cli"]

# API
api = [
"async-graphql",
Expand Down
8 changes: 4 additions & 4 deletions benches/remap.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use chrono::{DateTime, Utc};
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
use indexmap::IndexMap;
use remap::prelude::*;
use vrl::prelude::*;
use vector::transforms::{
add_fields::AddFields,
coercer::CoercerConfig,
Expand All @@ -25,7 +25,7 @@ criterion_group!(
criterion_main!(benches);

bench_function! {
upcase => remap_functions::Upcase;
upcase => vrl_stdlib::Upcase;

literal_value {
args: func_args![value: "foo"],
Expand All @@ -34,7 +34,7 @@ bench_function! {
}

bench_function! {
downcase => remap_functions::Downcase;
downcase => vrl_stdlib::Downcase;

literal_value {
args: func_args![value: "FOO"],
Expand All @@ -43,7 +43,7 @@ bench_function! {
}

bench_function! {
parse_json => remap_functions::ParseJson;
parse_json => vrl_stdlib::ParseJson;

literal_value {
args: func_args![value: r#"{"key": "value"}"#],
Expand Down
28 changes: 0 additions & 28 deletions lib/remap-cli/Cargo.toml

This file was deleted.

12 changes: 0 additions & 12 deletions lib/remap-lang/Cargo.toml

This file was deleted.

29 changes: 29 additions & 0 deletions lib/vrl/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "vrl-cli"
version = "0.1.0"
authors = ["Vector Contributors <vector@timber.io>"]
edition = "2018"
publish = false
license = "MPL-2.0"

[[bin]]
name = "vrl"
path = "src/main.rs"

[dependencies]
vrl = { path = "../core" }
stdlib = { package = "vrl-stdlib", path = "../stdlib" }

bytes = "0.5.6"
exitcode = "1"
prettytable-rs = { version = "0.8", default-features = false, optional = true }
regex = { version = "1", default-features = false, optional = true }
rustyline = { version = "7", default-features = false, optional = true }
serde_json = "1"
structopt = { version = "0.3", default-features = false }
thiserror = "1"
webbrowser = { version = "0.5", default-features = false, optional = true }

[features]
default = ["repl"]
repl = ["prettytable-rs", "regex", "rustyline", "webbrowser"]
File renamed without changes.
File renamed without changes.
14 changes: 7 additions & 7 deletions lib/remap-cli/src/cmd.rs → lib/vrl/cli/src/cmd.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{repl, Error};
use remap::{diagnostic::Formatter, state, Program, Runtime, Target, Value};
use vrl::{diagnostic::Formatter, state, Program, Runtime, Target, Value};
use std::collections::BTreeMap;
use std::fs::File;
use std::io::{self, Read};
Expand Down Expand Up @@ -86,7 +86,7 @@ fn repl(_: Vec<Value>) -> Result<(), Error> {
fn execute(object: &mut impl Target, source: String) -> Result<Value, Error> {
let state = state::Runtime::default();
let mut runtime = Runtime::new(state);
let program = remap::compile(&source, &remap_functions::all()).map_err(|diagnostics| {
let program = vrl::compile(&source, &stdlib::all()).map_err(|diagnostics| {
Error::Parse(Formatter::new(&source, diagnostics).colored().to_string())
})?;

Expand Down Expand Up @@ -115,26 +115,26 @@ fn read_into_objects(input: Option<&PathBuf>) -> Result<Vec<Value>, Error> {
"" => Ok(vec![Value::Object(BTreeMap::default())]),
_ => input
.lines()
.map(|line| Ok(serde_to_remap(serde_json::from_str(&line)?)))
.map(|line| Ok(serde_to_vrl(serde_json::from_str(&line)?)))
.collect::<Result<Vec<Value>, Error>>(),
}
}

fn serde_to_remap(value: serde_json::Value) -> Value {
fn serde_to_vrl(value: serde_json::Value) -> Value {
use serde_json::Value;

match value {
Value::Null => remap::Value::Null,
Value::Null => vrl::Value::Null,
Value::Object(v) => v
.into_iter()
.map(|(k, v)| (k, serde_to_remap(v)))
.map(|(k, v)| (k, serde_to_vrl(v)))
.collect::<BTreeMap<_, _>>()
.into(),
Value::Bool(v) => v.into(),
Value::Number(v) if v.is_f64() => v.as_f64().unwrap().into(),
Value::Number(v) => v.as_i64().unwrap_or(i64::MAX).into(),
Value::String(v) => v.into(),
Value::Array(v) => v.into_iter().map(serde_to_remap).collect::<Vec<_>>().into(),
Value::Array(v) => v.into_iter().map(serde_to_vrl).collect::<Vec<_>>().into(),
}
}

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/remap-cli/src/main.rs → lib/vrl/cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extern crate remap_cli;
extern crate vrl_cli;

use remap_cli::{cmd::cmd, Opts};
use vrl_cli::{cmd::cmd, Opts};
use structopt::StructOpt;

fn main() {
Expand Down
9 changes: 4 additions & 5 deletions lib/remap-cli/src/repl.rs → lib/vrl/cli/src/repl.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use crate::Error;
use prettytable::{format, Cell, Row, Table};
use regex::Regex;
use remap::{diagnostic::Formatter, state, Program, Runtime, Target, Value};
use remap_functions::all as funcs;
use vrl::{diagnostic::Formatter, state, Program, Runtime, Target, Value};
use rustyline::completion::Completer;
use rustyline::error::ReadlineError;
use rustyline::highlight::{Highlighter, MatchingBracketHighlighter};
Expand Down Expand Up @@ -145,7 +144,7 @@ fn resolve(
Some(object) => object,
};

let program = match remap::compile_with_state(program, &remap_functions::all(), state) {
let program = match vrl::compile_with_state(program, &stdlib::all(), state) {
Ok(program) => program,
Err(diagnostics) => return Formatter::new(program, diagnostics).colored().to_string(),
};
Expand Down Expand Up @@ -238,7 +237,7 @@ impl Validator for Repl {

fn print_function_list() {
let table_format = *format::consts::FORMAT_NO_LINESEP_WITH_TITLE;
let all_funcs = remap_functions::all();
let all_funcs = stdlib::all();

let num_columns = 3;

Expand Down Expand Up @@ -285,7 +284,7 @@ fn show_func_docs(line: &str, pattern: &Regex) {
let matches = pattern.captures(line).unwrap();
let func_name = matches.get(1).unwrap().as_str();

if funcs().iter().any(|f| f.identifier() == func_name) {
if stdlib::all().iter().any(|f| f.identifier() == func_name) {
let func_url = format!("{}/#{}", DOCS_URL, func_name);
open_url(&func_url);
} else {
Expand Down
File renamed without changes.
7 changes: 4 additions & 3 deletions lib/remap-compiler/Cargo.toml → lib/vrl/compiler/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
[package]
name = "remap-compiler"
name = "vrl-compiler"
version = "0.1.0"
authors = ["Vector Contributors <vector@timber.io>"]
edition = "2018"
publish = false

[dependencies]
diagnostic = { package = "vrl-diagnostic", path = "../diagnostic" }
parser = { package = "vrl-parser", path = "../parser" }

bitflags = "1"
bytes = "0.5.6"
chrono = "0.4"
diagnostic = { package = "remap-diagnostic", path = "../remap-diagnostic" }
lalrpop-util = "0.19"
ngrammatic = "0.3"
ordered-float = "2"
parser = { package = "remap-parser", path = "../remap-parser" }
paste = "1"
regex = "1"
serde = "1"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl Value {
/// value:
///
/// ```rust
/// # use remap_compiler::{Path, Value};
/// # use vrl_compiler::{Path, Value};
/// # use std::str::FromStr;
///
/// let value = Value::Boolean(true);
Expand All @@ -47,7 +47,7 @@ impl Value {
/// `None`:
///
/// ```rust
/// # use remap_compiler::{Path, Value};
/// # use vrl_compiler::{Path, Value};
/// # use std::str::FromStr;
///
/// let value = Value::Array(vec![false.into(), true.into()]);
Expand All @@ -61,7 +61,7 @@ impl Value {
/// exists:
///
/// ```rust
/// # use remap_compiler::{Path, Value};
/// # use vrl_compiler::{Path, Value};
/// # use std::str::FromStr;
/// # use std::collections::BTreeMap;
/// # use std::iter::FromIterator;
Expand Down Expand Up @@ -90,7 +90,7 @@ impl Value {
/// ## Insert At Field
///
/// ```
/// # use remap_compiler::{Path, Value};
/// # use vrl_compiler::{Path, Value};
/// # use std::str::FromStr;
/// # use std::collections::BTreeMap;
/// # use std::iter::FromIterator;
Expand All @@ -112,7 +112,7 @@ impl Value {
/// ## Insert Into Array
///
/// ```
/// # use remap_compiler::{value, Path, Value};
/// # use vrl_compiler::{value, Path, Value};
/// # use std::str::FromStr;
/// # use std::collections::BTreeMap;
/// # use std::iter::FromIterator;
Expand Down
13 changes: 13 additions & 0 deletions lib/vrl/core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[package]
name = "vrl"
version = "0.1.0"
authors = ["Vector Contributors <vector@timber.io>"]
edition = "2018"
publish = false

[dependencies]
compiler = { package = "vrl-compiler", path = "../compiler" }
diagnostic = { package = "vrl-diagnostic", path = "../diagnostic" }
parser = { package = "vrl-parser", path = "../parser" }

thiserror = "1"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "remap-diagnostic"
name = "vrl-diagnostic"
version = "0.1.0"
authors = ["Vector Contributors <vector@timber.io>"]
edition = "2018"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 3 additions & 2 deletions lib/remap-parser/Cargo.toml → lib/vrl/parser/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
[package]
name = "remap-parser"
name = "vrl-parser"
version = "0.1.0"
authors = ["Vector Contributors <vector@timber.io>"]
edition = "2018"
publish = false
build = "build.rs" # LALRPOP preprocessing

[dependencies]
diagnostic = { package = "remap-diagnostic", path = "../remap-diagnostic" }
diagnostic = { package = "vrl-diagnostic", path = "../diagnostic" }

lalrpop-util = "0.19"
ordered-float = "2"
paste = "1"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 65a03c3

Please sign in to comment.