Hello! I'm trying to define an exported variable t...
# help
w
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
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
Ah thank you! That works 🙂
I did not know the CEL parser does additional parsing on the string, my misunderstanding
o
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