Skip to content

Commit

Permalink
Re-implement shell expansion with serde_as
Browse files Browse the repository at this point in the history
`serde_with` offers a much more powerful set of tools for modifying
de/serialization behavior, and as a result allows us to collapse a handful of
nearly-identical utility functions into a single `ShellExpand` utility type.
  • Loading branch information
caass committed Aug 23, 2024
1 parent a174fbf commit 1b2d473
Show file tree
Hide file tree
Showing 7 changed files with 387 additions and 224 deletions.
135 changes: 135 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion nativelink-config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ rust_library(
name = "nativelink-config",
srcs = [
"src/cas_server.rs",
"src/deser/mod.rs",
"src/deser/shellexpand.rs",
"src/lib.rs",
"src/schedulers.rs",
"src/serde_utils.rs",
"src/stores.rs",
],
compile_data = [
Expand All @@ -23,6 +24,7 @@ rust_library(
"@crates//:byte-unit",
"@crates//:humantime",
"@crates//:serde",
"@crates//:serde_with",
"@crates//:shellexpand",
],
)
Expand Down
7 changes: 5 additions & 2 deletions nativelink-config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@ edition = "2021"
[dependencies]
byte-unit = { version = "5.1.4", default-features = false, features = ["byte"] }
humantime = "2.1.0"
serde = { version = "1.0.204", default-features = false }
serde = { version = "1.0.204", features = ["derive"] }
serde_json5 = "0.1.0"
shellexpand = { version = "3.1.0", default-features = false, features = ["base-0"] }
shellexpand = { version = "3.1.0", default-features = false, features = [
"base-0",
] }
serde_with = "3.9.0"

[dev-dependencies]
pretty_assertions = { version = "1.4.0", features = ["std"] }
19 changes: 19 additions & 0 deletions nativelink-config/src/deser/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright 2024 The NativeLink Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

//! Deserialization utilities for use in parsing and deserializing nativelink configs.
mod shellexpand;

pub use self::shellexpand::{ShellExpand, ShellExpandBytes, ShellExpandSeconds};
Loading

0 comments on commit 1b2d473

Please sign in to comment.