Skip to content

Commit

Permalink
chore: lint fix for deprecated chrono methods
Browse files Browse the repository at this point in the history
Ref: LOG-19380
  • Loading branch information
c-nixon committed Apr 3, 2024
1 parent 524ddb6 commit aa305f1
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ chrono = { version = "0.4", default-features = false, features = ["clock", "serd
chrono-tz = { version = "0.8.4", default-features = false, optional = true }
cidr-utils = { version = "0.6", optional = true }
csv = { version = "1.3", optional = true }
clap = { version = "4.4.11", features = ["derive"], optional = true }
clap = { version = "4.4.10", features = ["derive"], optional = true }
codespan-reporting = {version = "0.11", optional = true }
data-encoding = { version = "2.5.0", optional = true }
dyn-clone = { version = "1.0.16", default-features = false, optional = true }
Expand Down
5 changes: 3 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ FROM rust:1.72.0 AS base
WORKDIR /opt/app

COPY Cargo.toml /opt/app/
COPY Cargo.lock /opt/app/
COPY build.rs /opt/app/
COPY data /opt/app/data
COPY benches /opt/app/benches
Expand All @@ -12,6 +13,6 @@ COPY src /opt/app/src
COPY tests /opt/app/tests

RUN cargo --version
RUN cargo check
RUN cargo test
RUN cargo check --locked
RUN cargo test --locked

2 changes: 1 addition & 1 deletion lib/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ name = "vrl"
path = "src/main.rs"

[dependencies]
clap = { version = "4.4.11", features = ["derive"] }
clap = { version = "4.4.10", features = ["derive"] }
vrl = { path = "../../", features = ["cli"] }
2 changes: 1 addition & 1 deletion lib/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ publish = false
[dependencies]
vrl = { path = "../../", features = ["test_framework"] }
chrono-tz = "0.8"
clap = { version = "4.4.11", features = ["derive"] }
clap = { version = "4.4.10", features = ["derive"] }
glob = "0.3"
tracing-subscriber = { version = "0.3.18", default-features = false, features = ["fmt"] }

Expand Down
13 changes: 4 additions & 9 deletions src/cli/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,10 @@ fn run(opts: &Opts, stdlib_functions: Vec<Box<dyn Function>>) -> Result<(), Erro
program,
warnings,
config: _,
} = compile_with_state(
&source,
&stdlib_functions,
&state,
CompileConfig::default(),
)
.map_err(|diagnostics| {
Error::Parse(Formatter::new(&source, diagnostics).colored().to_string())
})?;
} = compile_with_state(&source, &stdlib_functions, &state, CompileConfig::default())
.map_err(|diagnostics| {
Error::Parse(Formatter::new(&source, diagnostics).colored().to_string())
})?;

#[allow(clippy::print_stderr)]
if opts.print_warnings {
Expand Down
3 changes: 2 additions & 1 deletion src/datadog/grok/matchers/date.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,14 +311,15 @@ pub fn apply_date_filter(value: &Value, filter: &DateFilter) -> Result<Value, Gr
.timestamp_millis()
.into())
} else {
Ok(dt.timestamp_millis().into())
Ok(dt.and_utc().timestamp_millis().into())
}
} else if let Ok(nt) = NaiveTime::parse_from_str(&value, &filter.strp_format) {
// try parsing as a naive time
Ok(NaiveDateTime::new(
NaiveDate::from_ymd_opt(1970, 1, 1).expect("invalid date"),
nt,
)
.and_utc()
.timestamp_millis()
.into())
} else {
Expand Down
10 changes: 8 additions & 2 deletions src/stdlib/parse_splunk_hec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,19 @@ fn parse_splunk_hec(value: Value) -> Resolved {

match json.get("time") {
Some(JsonValue::Number(time)) => {
object.insert(KeyString::from("time"), Value::Timestamp(to_timestamp(time)?));
object.insert(
KeyString::from("time"),
Value::Timestamp(to_timestamp(time)?),
);
}
Some(JsonValue::String(time)) => {
let time = time
.parse::<serde_json::Number>()
.map_err(|e| format!("invalid time format: {e}"))?;
object.insert(KeyString::from("time"), Value::Timestamp(to_timestamp(&time)?));
object.insert(
KeyString::from("time"),
Value::Timestamp(to_timestamp(&time)?),
);
}
None => (), // "time" is optional
_ => return Err(r#""time" is invalid type"#.into()),
Expand Down

0 comments on commit aa305f1

Please sign in to comment.