From 708f17d49b2efd721371fec88509f1e70e56b6e0 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Sat, 13 Feb 2021 14:24:22 +0100 Subject: feat(users/Profpatsch/netencode/record-splice-env): ignore non-scal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- users/Profpatsch/netencode/default.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/users/Profpatsch/netencode/default.nix b/users/Profpatsch/netencode/default.nix index 4965bb74f20c..a54a946d6e0a 100644 --- a/users/Profpatsch/netencode/default.nix +++ b/users/Profpatsch/netencode/default.nix @@ -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 can’t 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), } -- cgit 1.4.1