[openstack-dev] [Heat] New function: first_nonnull
Clint Byrum
clint at fewbar.com
Sun Nov 9 16:54:29 UTC 2014
Excerpts from Angus Salkeld's message of 2014-11-09 00:15:42 -0800:
> On 06/11/2014 8:32 AM, "Clint Byrum" <clint at fewbar.com> wrote:
> >
> > Excerpts from Lee, Alexis's message of 2014-11-05 15:46:43 +0100:
> > > 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.
> > >
> > > What do you think please?
> > >
> >
> > Yes this is super useful for writing responsive, reusable templates.
> >
> > I'd like to suggest that this be called 'coalesce' as that is what SQL
> > calls it.
>
> Although I have no clue why they called it that (colalesce mean join/merge
> not get first non-null). I'd rather it be called what it does
> "first_nonnull()" seems more obvious to me. We could also try the
> conditional as Zane suggested.
I believe it is called that because it is meant to coalesce a list of
variables in descending priority into one, which is precisely the use
case presented.
That said, first_nonnull is fine too if that nuance is not as obvious to
others as it is to me. :-P
More information about the OpenStack-dev
mailing list