On 22/08/17 16:57, John Baird wrote:
Henrik,

Whether the existing YAML/JSON/HOCON backend is referenced, everything is using the context of `path` to do the lookups.  The issues with this in regards to a file backend, is I am unsure as to how to access the value or file being looked up.  The `path` for the other backends is statically defined and they load the content accordingly.  Do you know how to access the value being looked up or if that is even possible in this context ?

*context.cached_file_data(path) do |content|
*

Path in this case is the full URI to the YAML file being ingested, for instance. But I need to append the variable being looked up to that in order to find the file I am seeking. I believe that is the missing piece I need to make this all work. Any insight would be appreciated. Thanks!


What you want to do is to use the kind of function that handles lookup key by key. You would otherwise have to load all the data files and return all of them as a hash. That would mean that it is very slow the first time, and that you may waste lots of memory if only looking up some of the values.

The cache that is available can be used if you want to keep contents in memory. That is only of value if the content is used many times as is the case if a backend function reads a yaml or json file containing a hash. I suggest skipping trying to cache in your first implementation (guessing that the same key is typically not looked up over and over again).

Simply resolve the name of the key into a path and read that file and return the value. (Alternatibely, if there is no such file call the not_found on the context).

There is support for reading binary files. The result is an instance of Binary. That data type is not fully supported everywhere, but I think it is fine to use as content of a File data type. (There is a file() function that reads a text file and a binary_file that reads it as a binary).

Hope this helps you get a bit further. Keep the questions coming...

Best,
- henrik

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com <mailto:puppet-users+unsubscr...@googlegroups.com>. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/28c0c2d2-b350-47d6-a775-e282abd4f158%40googlegroups.com <https://groups.google.com/d/msgid/puppet-users/28c0c2d2-b350-47d6-a775-e282abd4f158%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.


--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

--
You received this message because you are subscribed to the Google Groups "Puppet 
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/onhi4p%24m38%241%40blaine.gmane.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to