[openstack-dev] [Heat] New function: first_nonnull

Clint Byrum clint at fewbar.com
Sun Nov 9 16:58:38 UTC 2014


Excerpts from Zane Bitter's message of 2014-11-06 15:35:09 -0800:
> On 06/11/14 20:44, Steven Hardy wrote:
> > On Wed, Nov 05, 2014 at 02:46:43PM +0000, Lee, Alexis wrote:
> >>     I'm considering adding a function which takes a list and returns the first
> >>
> >>     non-null, non-empty value in that list.
> >>
> >>     So you could do EG:
> >>
> >>         some_thing:
> >>
> >>             config:
> >>
> >>                 ControlVIP:
> >>
> >>                     first_nonnull:
> >>
> >>                     - {get_param: ControlVIP}
> >>
> >>                     - {get_attr: [ControlVirtualIP, fixed_ips, 0,
> >>     ip_address]}]}
> >>
> >>
> >>     I'm open to other names, EG "some", "or", "fallback_list" etc.
> >>
> >>     Steve Hardy suggested building this into get_attr or Fn::Select. My
> >>     feeling is that those each do one job well right now, I'm happy to
> >>     take a steer though.
> >
> > Ah, from our IRC discussion I was thinking you wanted primarily list
> > filtering of get_attr output, thus thinking an optional argument would make
> > more sense than a new function.
> >
> > I see now that you're actually looking for something of a poor-mans
> > conditional, so you choose either the ControlVIP parameter, or the
> > ControlVirtualIP attribute, for which your proposal is probably cleaner -
> > my concern is just that we avoid a proliferation of different list
> > select/filter functions, when we could just have one.
> 
> 
> Crazy thought: why not just implement conditionals? We had a proto-spec 
> for them started at one point...
> 

The coalesce/first_nonnull is just a shortcut for a common conditional
problem. I'd agree that conditionals are useful as well, but they might
be better served by more time to bake than this more narrow case.



More information about the OpenStack-dev mailing list