[openstack-dev] [Heat] Conditionals, was: New function: first_nonnull

Alexis Lee alexisl at hp.com
Mon Nov 10 17:34:13 UTC 2014


Zane Bitter said on Fri, Nov 07, 2014 at 12:35:09AM +0100:
> Crazy thought: why not just implement conditionals? We had a
> proto-spec for them started at one point...

I didn't know that was on the table :)

How about we support YAQL expressions? https://github.com/ativelkov/yaql
Plus some HOFs (higher-order functions) like cond, map, filter, foldleft
etc?

Here's first_nonnull:

  config:
    Fn::Select
      - 0
      filter:
        - yaql: "$.0 != null"
        - <item1>
        - <itemN>

Making the 'yaql' function eponymous means we can easily plug other
expression languages in later if we choose.

We can restrict the functions available to YAQL expressions to avoid a
halting problem.

Each HOF will know how to populate the context for subordinate YAQL
expressions. When used outside a HOF, only add a default context of
parameters and input_values.

Is this totally crazy or worth spec-ifying?


Alexis
-- 
Nova Engineer, HP Cloud.  AKA lealexis, lxsli.



More information about the OpenStack-dev mailing list