What would you expect to get when you have a tag without = in it?

"myvar" string => "value", meta => { "inventory", "attribute_name=my 
special inventory thing" };

"inventory_tags" slist => getvariablemetatags("myvar", "inventory");

An empty list?
A list with a single element of empty string? { "" }
Skip defining the variable? <- my preference


I can see this being useful.

On Wednesday, July 13, 2016 at 5:07:05 AM UTC-5, Ted Zlatanov wrote:
>
> On Wed, 13 Jul 2016 08:35:04 +0200 Kristian Amlie <[email protected] 
> <javascript:>> 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 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"dev-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dev-cfengine/2134757f-d7e9-438d-a148-09468fae96de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to