https://cerbos.dev logo
#help
Title
# help
w

Will Ho

12/14/2023, 11:24 PM
Hello! I'm trying to define an exported variable that contains a list as a value like this:
Copy code
apiVersion: api.cerbos.dev/v1
description: My variable
exportVariables:
  name: my_variable
  definitions: 
    variable_definition:
    - foo
    - bar
However, Cerbos errors out with
/exportVariables/definitions/variable_definition: expected string, but got array]"
. Is it possible to define a static list of strings for a variable?
d

Dennis (Cerbos)

12/15/2023, 3:57 AM
Hi, please try wrapping an array in single-quotes:
variable_definition: '["foo", "bar"]'
. Here, the YAML parser sees it as a string, and then CEL parses it as an array.
w

Will Ho

12/15/2023, 6:15 PM
Ah thank you! That works 🙂
I did not know the CEL parser does additional parsing on the string, my misunderstanding
o

Oleh Zhovnuvatyi

01/03/2024, 11:42 PM
I had the same question and was looking for ways to implement it everywhere. Your answer helped me a lot. It would be nice to have a similar example in the documentation, I feel that there will be other users with the same question.
👍 2
3 Views