That makes sense, and yeah, that whole catalog should be there unless
you're dynamically injecting resources.

You might want to add a check before splunk_config['forwarder_confdir'] in
case you didn't find the resource in the catalog so you don't hit a null
pointer issue.

Not seeing a better way to do this right now actually.

Trevor

On Fri, Jan 30, 2015 at 3:23 PM, Nan Liu <nan....@gmail.com> wrote:

> On Fri, Jan 30, 2015 at 1:12 PM, Trevor Vaughan <tvaug...@onyxpoint.com>
> wrote:
>
>> If you do access the catalog in a self.* method, it's completely compile
>> order dependent and you'll only have access to the catalog as compiled to
>> that point, not the entire catalog.
>>
>
> It should be the whole catalog since the provider is running once
> everything is compiled. The partial catalog problem is only with puppet
> functions (or anything in a manifest).
>
> I was able to work around this by abusing self.prefetch, since the
> transaction layer passes in a subset of resources:
>
> def self.prefetch(resources)
>     catalog = resources[resources.keys.first].catalog
>     # Note: catalog.resources != resources
>     splunk_config = catalog.resources.find{|s| s.type == :splunk_config}
>     confdir = splunk_config['forwarder_confdir'] || raise(Puppet::Error,
> 'Unknown splunk forwarder confdir')
>     @file_path = File.join(confdir, 'outputs.conf')
> end
>
> The whole work around have been submitted as a PR [1]. I am open for a
> better solution, since this doesn't seem ideal.
>
> Nan
>
> 1. https://github.com/puppetlabs/puppetlabs-splunk/pull/14
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-dev+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-dev/CACqVBqD0d5Tf-URcPT%3D0yhOex6795zeD3n9n_mvpXHS1i6mh8Q%40mail.gmail.com
> <https://groups.google.com/d/msgid/puppet-dev/CACqVBqD0d5Tf-URcPT%3D0yhOex6795zeD3n9n_mvpXHS1i6mh8Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Trevor Vaughan
Vice President, Onyx Point, Inc
(410) 541-6699
tvaug...@onyxpoint.com

-- This account not approved for unencrypted proprietary information --

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-dev/CANs%2BFoWSY7PCji9%3DBAmHdt7GmDg_OVUsUAtt4sR%2BWMkSf%2B94_A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to