Open knorby opened 11 years ago
+1 for something that would do casting. It feels weird to cast my stuff in my work.
Maybe we can utilize json.loads()
somehow? That would fix most default cases and is fairly straightforward.
(thanks for a cool and useful little module, btw)
Well, the type issue mostly exists because yaml support can't be guaranteed, but you can get it if you initialize Facter with use_yaml. I don't remember the issues around facter support (I don't use puppet regularly anymore), but yaml support in python was the other reason. I recommend that you use the yaml approach if this is a concern for you, as this approach actually gets the correct type from facter.
I think there are some cases where json.loads wouldn't work out, which gives me some pause on that particular approach; something more robust than a json parser could certainly work here. As I mentioned in the issue, I'm also concerned with cases like version strings.
I can fit something in, but I will probably leave it off by default, similar to how the yaml flag works.
Facts already have inconsistent types and are usually strings more often then not, regardless of the value. When using with YAML, some values show up as a non-string type, and when not using YAML, they show up as a string. There are a few ways to improve this:
The best option is probably a choice between 1 and 3.