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

Config updater improvements #151

Merged
merged 21 commits into from
Sep 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
afd485e
Initial improvements to keep some of the code parsing over
tkmcmaster Sep 21, 2023
877af5e
Finished converting all functions except collect over to the config-u…
tkmcmaster Sep 21, 2023
1cff514
Fixed formatting
tkmcmaster Sep 21, 2023
378f755
Cleaned up the Display Code for Path
tkmcmaster Sep 21, 2023
652098d
Simplified and fixed the converting of Json object queries
tkmcmaster Sep 22, 2023
35c42c7
Fixed the stack overflow bug
tkmcmaster Sep 22, 2023
815d924
Added code to handle parsing of expressions with right hand side
tkmcmaster Sep 22, 2023
ac62a5d
config-updater updates
tkmcmaster Sep 22, 2023
f56530d
Added fix for sting values
tkmcmaster Sep 22, 2023
07d9a0b
Fixed the complex expressions to parse expressions with vars/provider…
tkmcmaster Sep 22, 2023
874a9f8
Fixed Clippy warnings
tkmcmaster Sep 22, 2023
86d26b3
comments and fixes
tkmcmaster Sep 25, 2023
4de0507
cargo fmt
tkmcmaster Sep 25, 2023
2011695
Changed the default order of loggers
tkmcmaster Sep 25, 2023
fb12e63
Added code to handle base expresssions with right hand side operations
tkmcmaster Sep 25, 2023
e5d2923
Removed ignore that we've removed the dependency
tkmcmaster Sep 25, 2023
3523706
Changed npm install in build-guide to npm ci
tkmcmaster Sep 25, 2023
0637034
Updated test for change to logger order
tkmcmaster Sep 25, 2023
d8d886c
Updated README
tkmcmaster Sep 25, 2023
892fafa
Updated bugs in the README
tkmcmaster Sep 26, 2023
2793891
Added an additional bug to README with workaround
tkmcmaster Sep 26, 2023
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
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,15 @@ C:\vcpkg> set VCPKGRS_DYNAMIC=1 (or simply set it as your environment variable)
Changes:
- Major changes: Javascript scripting!
- Updated config-wasm to parse legacy and scripting yaml files
- New binary pewpew-config-updater will attempt to convert legacy config yamls to the new version. If it can't convert the code it will leave in PLACEHOLDERS and TODO
- Known issues:
- Expressions in vars will not wrap environment variables in the expected `${e:VAR}`
- vars in `logs` and `provides` will not have the prepended `_v.` before the var name.

Bugs:
- Collect returns an array of strings regardless of input type
- auto-converter removes code templates. Leave in and TODO
- Collect returns an array of strings regardless of input type. Workaround, use scripting to `.map(parseInt)`.
- Declare expressions that create strings will escape out any json/quotes. No workaround currently.
- Vars cannot be decimal point values. Ex `peakLoad: 0.87`. Workaround: `peakLoad: ${x:0.87}`
- global loggers may not be running in try script

Bug fixes:
Expand Down
2 changes: 1 addition & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ unmaintained = "warn"
yanked = "warn"
notice = "warn"
ignore = [
"RUSTSEC-2020-0071",
# "RUSTSEC-2020-0071",
]

[licenses]
Expand Down
2 changes: 1 addition & 1 deletion guide/build-guide.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ wasm-pack build --release -t bundler -d $CFG_GEN_OUTPUT_REACT_DIR --scope fs

# build the results viewer (which includes putting the output into the book's src)
cd $RESULTS_VIEWER_REACT_DIR
npm install
npm ci
npm run build

# build the book
Expand Down
2 changes: 1 addition & 1 deletion guide/serve-guide.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ wasm-pack build --release -t bundler -d $CFG_GEN_OUTPUT_REACT_DIR --scope fs

# build the results viewer (which includes putting the output into the book's src)
cd $RESULTS_VIEWER_REACT_DIR
npm install
npm ci
npm run build

# build the book
Expand Down
4 changes: 2 additions & 2 deletions lib/config-gen/tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ loggers:
timestamp: epoch("ms")
for_each: []
where: null
limit: null
to: stdout
pretty: false
limit: null
kill: false
test2:
query: null
limit: null
to: !file out.txt
pretty: false
limit: null
kill: false
providers:
sequence: !list
Expand Down
59 changes: 51 additions & 8 deletions lib/config/src/configv1/convert_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,17 +374,60 @@ fn map_query(
for_each: Vec<WithMarker<String>>,
where_clause: Option<WithMarker<String>>,
) -> Option<Query<False>> {
if let Some(w) = where_clause {
// Fallback query if we can't parse anything
let empty_query = Query::simple("PLEASE_UPDATE_MANUALLY".to_owned(), vec![], None).unwrap();

// Attempt to parse the where_clause
let where_clause = if let Some(w) = where_clause {
let w = w.destruct().0;
log::warn!("query `where` item {w:?} must be updated manually");
Some(w)
} else {
None
};
// Attempt to parse the for_each
let for_each: Vec<String> = for_each
.iter()
.map(|fe| (fe.inner.to_string(), fe.marker).0)
.collect();

// See if we can create a fallback with the where and for_each but without the select
let manual_query = match Query::simple(
"PLEASE_UPDATE_MANUALLY".to_owned(),
for_each.clone(),
where_clause.clone(),
) {
Ok(q) => q,
Err(e) => {
log::warn!("query `where` or `for_each` item must be updated manually: {e:?}");
empty_query
}
};
for_each.into_iter().for_each(|fe| {
let fe = fe.destruct().0;
log::warn!("query `for_each` item {fe:?} must be updated manually");
});

// Finally attempt to parse the select but fallback to the manual_query or empty_query
select.map(|s| {
log::warn!("query `select` item {s:?} must be updated manually");
Query::simple("PLEASE_UPDATE_MANUALLY".to_owned(), vec![], None).unwrap()
let select_temp = s.inner();
log::debug!("select_temp query: {select_temp}");
let query = match select_temp {
json::Value::Object(_) => {
log::info!("Object query: {select_temp}");
Query::<False>::complex_json(
format!("{select_temp}").as_str(),
for_each,
where_clause,
)
}
json::Value::String(s) => Query::simple(s.to_string(), for_each, where_clause),
_ => Query::simple(format!("{select_temp}"), for_each, where_clause),
};
let query = match query {
Ok(q) => q,
Err(e) => {
log::warn!("query `select` {select_temp} must be updated manually: {e:?}");
manual_query
}
};
log::debug!("new query: {query:?}");
query
})
}

Expand Down
Loading