-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$foreach and $exists functions #152
Comments
I would prefer This amounts, in the general case, to TOSCA supporting lambdas, and there are two different functionalities that you may want to achieve: distribution and aggregation.
Consider now that functions Now if we define $and:
- $each:
- colo-group
- X
- $foreach:
- colo-group
- Y
- $equal:
- [ X, RELATIONSHIP, host, TARGET, uuid ]
- [ Y, RELATIONSHIP, host, TARGET, uuid ] You may of course still have shorthand functions |
Yes, I believe we want aggregation semantics, not distribution. |
Back in the days of OASIS TOSCA 1.0, one could use one's own expression language:
(That came from WS-BPEL) Back in those days, one could use XPath or Java. For XPath, the concrete expression was (more or less) clear; for Java, one needed another specification). So, why not offer a Python / go / ... expression language plug in possibility? In another project, we made good experiences with jq, although the syntax is not as nice as Python. |
Calin has previously suggested adding
$foreach
and$exists
functions that would apply boolean expressions to lists of nodes or relationships.$foreach
evaluates totrue
if the boolean expression evaluates totrue
for all elements in the list (booleanand
) and$exists
evaluates totrue
if the boolean expression evaluates totrue
for at least one of the elements in the list (booleanor
). I believe Calin's suggested syntax was as follows:Meaning that for any combination of list1 and list2 elements the applied boolean_comp is
true
.I believe this syntax can be simplified as follows:
I believe there is no need to specify two list arguments, since the boolean expression can decide which arguments to take. Of course, if one of the arguments of the boolean expression is a list, then we may need a second
$foreach
function that iterates over the second list. In that case, we need to be able to identify which element in which list is being used, which may require a variable name. Using a variable name, the syntax would look as follows:The boolean expression could then use that variable name as appropriate.
With this syntax, we could then support formal definitions of declarative policies. For example, the following would express a colocation policy for all nodes in a colocation group named
colo-group
:The text was updated successfully, but these errors were encountered: