feat(users/Profpatsch/netencode/record-splice-env): ignore non-scal

The headers are not a scalar, so record-splice-env doesn’t know how to
convert them to an envvar; let’s just ignore everything that can’t be
converted to a scalar for now.

Change-Id: I74ed0aa942fcd26beb058705830bc2f2b516e93e
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2523
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
This commit is contained in:
Profpatsch 2021-02-13 14:24:22 +01:00
parent 1d752f031b
commit 708f17d49b

View file

@ -131,15 +131,20 @@ let
} ''
extern crate netencode;
extern crate exec_helpers;
use netencode::dec::{Record, ScalarAsBytes, Decoder, DecodeError};
use netencode::dec::{Record, Try, ScalarAsBytes, Decoder, DecodeError};
fn main() {
let mut buf = vec![];
let u = netencode::u_from_stdin_or_die_user_error("record-splice-env", &mut buf);
let (_, prog) = exec_helpers::args_for_exec("record-splice-env", 0);
match Record(ScalarAsBytes).dec(u) {
match Record(Try(ScalarAsBytes)).dec(u) {
Ok(map) => {
exec_helpers::exec_into_args("record-splice-env", prog, map);
exec_helpers::exec_into_args(
"record-splice-env",
prog,
// some elements cant be decoded as scalars, so just ignore them
map.into_iter().filter_map(|(k, v)| v.map(|v2| (k, v2)))
);
},
Err(DecodeError(err)) => exec_helpers::die_user_error("record-splice-env", err),
}