Re: [openstack-dev] [Heat] New function: first_nonnull
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 +, 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. ___ OpenStack-dev mailing list OpenStack-dev@lists.openstack.org http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
Re: [openstack-dev] [Heat] New function: first_nonnull
Excerpts from Angus Salkeld's message of 2014-11-09 00:15:42 -0800: > On 06/11/2014 8:32 AM, "Clint Byrum" 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 ___ OpenStack-dev mailing list OpenStack-dev@lists.openstack.org http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
Re: [openstack-dev] [Heat] New function: first_nonnull
On 06/11/2014 8:32 AM, "Clint Byrum" 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. -Angus > > ___ > OpenStack-dev mailing list > OpenStack-dev@lists.openstack.org > http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev ___ OpenStack-dev mailing list OpenStack-dev@lists.openstack.org http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
Re: [openstack-dev] [Heat] New function: first_nonnull
On 06/11/14 20:44, Steven Hardy wrote: On Wed, Nov 05, 2014 at 02:46:43PM +, 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... To clarify I wasn't suggesting we add anything into Fn::Select, but possibly implementing a native alternative which does what Fn::Select does and includes optional list filtering, e.g something flexible which can do more than just select a non-null value, e.g something like: list_select: - {get_param: ControlVIP} - {get_attr: [ControlVirtualIP, fixed_ips, 0, ip_address]}]} - 0 - non_null This would take any number of list arguments, join them, then take an index value, and an optional filter value. Maybe we could even make the "0" optional and default to zero, provided there's a non-overlapping range of input allowed for the index and filter arguments. Don't have a very strong opinion on the name, but FWIW I prefer first_nonnull over coalesce, just because the latter is really clear if you know the mysql function, and really not if you don't :) Happy to hear other ideas, but I think it's good that we discuss this before committing to an interface (either here or in a spec review). Steve ___ OpenStack-dev mailing list OpenStack-dev@lists.openstack.org http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev ___ OpenStack-dev mailing list OpenStack-dev@lists.openstack.org http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
Re: [openstack-dev] [Heat] New function: first_nonnull
On Wed, Nov 05, 2014 at 02:46:43PM +, 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. To clarify I wasn't suggesting we add anything into Fn::Select, but possibly implementing a native alternative which does what Fn::Select does and includes optional list filtering, e.g something flexible which can do more than just select a non-null value, e.g something like: list_select: - {get_param: ControlVIP} - {get_attr: [ControlVirtualIP, fixed_ips, 0, ip_address]}]} - 0 - non_null This would take any number of list arguments, join them, then take an index value, and an optional filter value. Maybe we could even make the "0" optional and default to zero, provided there's a non-overlapping range of input allowed for the index and filter arguments. Don't have a very strong opinion on the name, but FWIW I prefer first_nonnull over coalesce, just because the latter is really clear if you know the mysql function, and really not if you don't :) Happy to hear other ideas, but I think it's good that we discuss this before committing to an interface (either here or in a spec review). Steve ___ OpenStack-dev mailing list OpenStack-dev@lists.openstack.org http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
Re: [openstack-dev] [Heat] New function: first_nonnull
Except it penalizes us bad spellers. ;) Kevin From: Clint Byrum Sent: Wednesday, November 05, 2014 11:26:43 PM To: openstack-dev Subject: Re: [openstack-dev] [Heat] New function: first_nonnull 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. ___ OpenStack-dev mailing list OpenStack-dev@lists.openstack.org http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev ___ OpenStack-dev mailing list OpenStack-dev@lists.openstack.org http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
Re: [openstack-dev] [Heat] New function: first_nonnull
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. ___ OpenStack-dev mailing list OpenStack-dev@lists.openstack.org http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
Re: [openstack-dev] [Heat] New function: first_nonnull
We have a template usability session at 9am this morning, and we'll be covering these sort of utility functions as part of that session. If you don't make it we can follow up later. On 05/11/14 15:46, 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. What do you think please? Alexis (lxsli) ___ OpenStack-dev mailing list OpenStack-dev@lists.openstack.org http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev ___ OpenStack-dev mailing list OpenStack-dev@lists.openstack.org http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
Re: [openstack-dev] [Heat] New function: first_nonnull
That would be very useful. It would eliminate a few more places where I've needed the aws if function. It would be good to keep the get_ prefix for consistency. Id vote for seperate function. Its cleaner. Thanks, Kevin From: Lee, Alexis Sent: Wednesday, November 05, 2014 6:46:43 AM To: OpenStack Development Mailing List (not for usage questions) Subject: [openstack-dev] [Heat] New function: first_nonnull 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? Alexis (lxsli) ___ OpenStack-dev mailing list OpenStack-dev@lists.openstack.org http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
[openstack-dev] [Heat] New function: first_nonnull
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? Alexis (lxsli) ___ OpenStack-dev mailing list OpenStack-dev@lists.openstack.org http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev