mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-13 03:42:35 -06:00
d0350b326e
Originally meant to be `array.concat_n`, but this name is better as the behavior of this function differs from `array.concat` — namely that `array.flatten` accepts any type of valued in the input array. Only arrays are however flattened, and the rest are appended directly to the flattened output. Note that this function only flattens at the topmost level of the input array — not recursively! A cursory look at a few other languages suggest a single level is the common case. But if others feel we should flstten more, I'm happy to make an update. The C code for a Wasm implementstion here is cowboy coded, and I did not manage to run the tests on my machine due to some `docker` <-> `container` differences. I mostly just imitated the existing code in the array category. I doubt it'll work on the first try, but only CI can judge me. Also: - Remove `opa fmt` step from the Rego CI step, as this is done by Regal anyway a little later in the list of tasks. - Replace some hard-coded `docker` names in the `Makefile` with `$(DOCKER)` - Added name of built-in function missing to the unsupportedBuiltinErr error, as it has happened a few times now that I've used `:=` in a query, and had no clue what built-in it referred to. Fixes #8226 Signed-off-by: Anders Eknert <anders.eknert@apple.com>
10 lines
264 B
C
10 lines
264 B
C
#ifndef OPA_ARRAY_H
|
|
#define OPA_ARRAY_H
|
|
|
|
opa_value *opa_array_concat(opa_value *a, opa_value *b);
|
|
opa_value *opa_array_flatten(opa_value *a);
|
|
opa_value *opa_array_slice(opa_value *a, opa_value *i, opa_value *j);
|
|
opa_value *opa_array_reverse(opa_value *a);
|
|
|
|
#endif
|