On Wed, 13 Jul 2016 08:35:04 +0200 Kristian Amlie <
kristia...@cfengine.com> wrote:
KA> On 12/07/16 18:08, Ted Zlatanov wrote:
>> Right now, getclassmetatags("myclass") and getvariablemetatags("myvar")
>> return an slist of all the tags for their respective class or variable.
>>
>> In 3.9.0, I found myself needing a specific tag value instead of all of
>> them, so I was doing
>>
>> regex_replace(nth(grep("^foo=.*", getclassmetatags("myclass")), 0), "^foo=", "", "T")
>>
>> to get the value of the "foo=bar" tag of "myclass". So I would love to
>> have an optional second argument getclassmetatags("myclass", "foo") and
>> getvariablemetatags("myvar", "foo") that give me a slist of the specific
>> tag values, removing the key. What do you think? It would be backwards
>> compatible and fairly easy to implement.
KA> Would it need to be an slist? If you ask for a specific tag you'll get
KA> just one value, no? Or do you mean that it should be an expression?
You'd get an slist, because you can have meta => { "foo=1", "foo=2" } so
the function signature won't change.
KA> I guess this makes sense, but just out of curiosity, can you share some
KA> more about why you needed this, if it's not too secret? :-)
It was for
https://github.com/cfengine/masterfiles/pull/766 but I think
it's a generally useful extension.
Ted