Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add support to define_tedge_config for (optionally) multi-value fields #3126

Merged
merged 32 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
a9aad21
Start PoC for named c8ys in tedge config
jarhodes314 Sep 18, 2024
1517688
Generate enums that mostly work with multi keys
jarhodes314 Sep 19, 2024
5e50c0e
Fix the remaining new compiler errors
jarhodes314 Sep 19, 2024
0efaa46
Replace HashMap with Multi enum, to allow unnamed c8ys to persist
jarhodes314 Sep 19, 2024
d3ea36e
Add another .get call to fix a compiler error message
jarhodes314 Sep 20, 2024
7eb7515
Make multi example compile
jarhodes314 Sep 20, 2024
5dcdfaf
Update tedge config API usage so the existing tedge config works
jarhodes314 Sep 20, 2024
a879f50
Run formatter and fix some remaining errors
jarhodes314 Sep 20, 2024
56525cc
Add a proper example for multi c8y config
jarhodes314 Sep 20, 2024
0baeb4c
Refactor some of the ID generation logic
jarhodes314 Sep 20, 2024
10ccd17
Refactor reader ID generation
jarhodes314 Sep 20, 2024
7d4745e
Rename `get` to `try_get`
jarhodes314 Sep 20, 2024
b962d72
Fix clippy and test errors
jarhodes314 Sep 20, 2024
66ea8c7
Update `FromStr` implementation to cope with multi-value fields
jarhodes314 Sep 23, 2024
e3ee82a
Add support for iterating over readable keys
jarhodes314 Sep 24, 2024
8666582
Add support for stringifying multi-value fields correctly
jarhodes314 Sep 25, 2024
9c816da
Tidy up code following the new multi-value logic
jarhodes314 Sep 25, 2024
615d0f8
Remove dead code
jarhodes314 Sep 25, 2024
d923fc3
Tidy up most of the remaining TODOs
jarhodes314 Sep 25, 2024
c786ae2
Run formatter
jarhodes314 Sep 25, 2024
3860292
Fix doc test
jarhodes314 Sep 26, 2024
fdc4751
Fix imports in docs
jarhodes314 Sep 26, 2024
d508c90
Run formatter
jarhodes314 Sep 26, 2024
edc2d61
Rename map -> map_keys
jarhodes314 Sep 30, 2024
acdd944
Improve error messages for multi fields
jarhodes314 Oct 1, 2024
582f1f6
Use named fields inside the multi
jarhodes314 Oct 1, 2024
63fee73
Allow writing to novel tedge config multi keys
jarhodes314 Oct 1, 2024
8bbf918
Update crates/common/tedge_config_macros/src/multi.rs
jarhodes314 Oct 2, 2024
64ddb22
Fix tests and add more tests around multi
jarhodes314 Oct 2, 2024
85b30f8
Fix issues with normal groups inside multi-value groups
jarhodes314 Oct 2, 2024
87da9c3
Refactoring
jarhodes314 Oct 2, 2024
3936b7d
Support converting between single and multi fields
jarhodes314 Oct 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 63 additions & 31 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ pem = "1.0"
pin-project = { version = "1.1.3", features = [] }
plugin_sm = { path = "crates/core/plugin_sm" }
predicates = "2.1"
pretty_assertions = "1.4.1"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will have to give a try to that one! This looks pretty helpful!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it would be essentially impossible to assert eq for large blocks of code without a line-by-line comparison.

prettyplease = "0.2.22"
proc-macro2 = "1"
proptest = "1.0"
quote = "1"
Expand Down
6 changes: 3 additions & 3 deletions crates/common/axum_tls/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn load_ssl_config(
let cert_key = cert_path.key();
let key_key = key_path.key();
let ca_key = ca_path.key();
if let Some((cert, key)) = load_certificate_and_key(cert_path, key_path)? {
if let Some((cert, key)) = load_certificate_and_key(&cert_path, &key_path)? {
let trust_store = match ca_path.or_none() {
Some(path) => path
.load_trust_store()
Expand All @@ -103,8 +103,8 @@ pub fn load_ssl_config(
type CertKeyPair = (Vec<Vec<u8>>, Vec<u8>);

fn load_certificate_and_key(
cert_path: OptionalConfig<impl PemReader>,
key_path: OptionalConfig<impl PemReader>,
cert_path: &OptionalConfig<impl PemReader>,
key_path: &OptionalConfig<impl PemReader>,
) -> anyhow::Result<Option<CertKeyPair>> {
let paths = tedge_config::all_or_nothing((cert_path.as_ref(), key_path.as_ref()))
.map_err(|e| anyhow!("{e}"))?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ impl TEdgeEnv {
tracing::subscriber::NoSubscriber::default(),
|| lowercase_name.parse::<crate::WritableKey>(),
)
.map(|key| key.as_str().to_owned())
.map(|key| key.to_string())
.map_err(|err| {
let is_read_only_key = matches!(err, crate::ParseKeyError::ReadOnly(_));
if is_read_only_key && !WARNINGS.lock().unwrap().insert(lowercase_name.clone()) {
Expand Down
Loading
Loading