balena-io-modules / balena-temen Goto Github PK
View Code? Open in Web Editor NEWBalena TEMplating ENgine
License: Apache License 2.0
Balena TEMplating ENgine
License: Apache License 2.0
base64encode
base64decode
Specification allows to evaluate expression containing relative paths. Currently there's no support for this.
Attaching examples found by fuzzer
slow-examples.zip
chrono
doesn't support wasm32
(see chronotope/chrono#243 & chronotope/chrono#287)src/context.rs
:
#[cfg(not(target_arch = "wasm32"))]
fn utc_now() -> DateTime<Utc> {
Utc::now()
}
// chrono crate doesn't support wasm32 arch yet, workaround
#[cfg(target_arch = "wasm32")]
fn utc_now() -> DateTime<Utc> {
let now = js_sys::Date::new_0();
let millisecs_since_unix_epoch: u64 = now.get_time() as u64;
let secs = millisecs_since_unix_epoch / 1000;
let nanos = 1_000_000 * (millisecs_since_unix_epoch - 1000 * secs);
let naive = NaiveDateTime::from_timestamp(secs as i64, nanos as u32);
DateTime::from_utc(naive, Utc)
}
Function now
isn't implemented.
See Functions.
Current implementation of the fuzzer is kind of useless. There's no way how to get the crashing input, etc. Useless fuzzer was removed.
We have to come up with some fuzzing strategy like:
Once new uuid
crate is released and #352 fixed, we can remove our uuid
& rand
workaround.
rand
dependencyv4
feature (uuid
crate)wasm-bindgen
feature (uuid
crate, wasm32
arch)uuidv4()
fn body with Uuid::new_v4()
Once all features will be in place, fully working, optimise the whole crate, because it:
Issue on rand side: rust-random/rand#682
See also #48
Reproducible Node case:
const bt = require('balena-temen');
console.log(
bt.evaluate({
"uuid": {
"$$eval": "uuidv4()"
}
})
);
The error message:
panicked at 'could not initialize thread_rng: No entropy sources available (permanently unavailable)', /Users/robertvojta/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.5.5/src/rngs/thread.rs:84:17
wasm://wasm/004488ea:574
RuntimeError: unreachable
at __rust_start_panic (wasm-function[573]:1)
at rust_panic (wasm-function[570]:30)
at std::panicking::rust_panic_with_hook::h6790e8431e342a60 (wasm-function[565]:444)
at std::panicking::continue_panic_fmt::h3b66c044a41127bf (wasm-function[564]:120)
at std::panicking::begin_panic_fmt::h522439ba8a0fbac4 (wasm-function[561]:95)
at rand::rngs::thread::THREAD_RNG_KEY::__init::_$u7b$$u7b$closure$u7d$$u7d$::hdd28f475617c5274 (wasm-function[357]:91)
at rand::rngs::thread::thread_rng::hef4638d394e756b1 (wasm-function[356]:1024)
at uuid::v4::_$LT$impl$u20$uuid..Uuid$GT$::new_v4::h9644a31e3bf57f8d (wasm-function[345]:14)
at balena_temen::builtin::function::uuidv4::uuidv4::h3ce10819a87f445f (wasm-function[200]:18)
at balena_temen::engine::Engine::eval_function::he1b50994ba503a6b (wasm-function[233]:943)
Same error in both nodeJS & browser.
@mikesimos Flowdock thread message:
Just an update, here is a list of DSL generators (+validators ideally) we use/ll be using in balena configuration:
require('dhparam')(bits)
)More info about EC *.
Imagine you have a JSON like this one ...
{
"uuid": {
"$$eval": "uuidv4()"
},
"id: {
"$$eval": "ssid | slugify"
},
"ssid": "Zrzka 5G"
}
... and you'd like to evaluate everything at once to get something like ...
{
"uuid": "2a0b9f5a-04e8-483e-bb3c-c889822afc67",
"id": "zrzka-5g",
"ssid": "Zrzka 5G"
}
... we should provide a helper function for this, so, one can do it with one call. It's possible today, but one has to find all $$eval
and evaluate them one by one.
@cyplo WDYT?
We should replace error-chain
with custom error type allowing us to provide more precise error messages like which part of the expression is wrong, etc.
We have to provide a public API for users with the ability to normalize identifier. It means conversion from relative identifier to an absolute one (remove this
and super
keywords).
Till 0.1, even patch version can break public API. Once all features will be in place, working, API should be stabilised, 0.1 released and then we should follow semantic versioning.
We need to add benchmarks, but we have to check with CI guys how stable in terms of performance is our CI, etc. Or we should run them locally on our machines with predictable performance.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.