Maxim Ianoglo
2010-Apr-16 15:36 UTC
[Puppet Users] Custom Types: issue with accessing resources in provider from type
Hello, Tryign to make a custom type Type: module Puppet newtype(:simple_line) do ensurable newparam(:name) do isnamevar end newproperty(:target) do defaultto { if @resource.class.defaultprovider.ancestors.include? Puppet::Provider::ParsedFile @resource.class.defaultprovider.default_target else nil end } end newproperty(:pcre_pattern) do validate do |value| if value.class != String raise ArgumentError, "Shoult be string" else super end end end newproperty(:line) do validate do |value| if value.is_a? String raise ArgumentError, "Shoult be string" else super end end end end end Provider: require ''puppet/provider/parsedfile'' target = "/tmp/simple_line_dummy_file" Puppet::Type.type(:simple_line).provide( :parsed, :parent => Puppet::Provider::ParsedFile, :default_target => target, :filetype => :flat ) do text_line :comment, :match => @resource.value(:pcre_pattern) text_line :blank, :match => /^\s*$/ record_line :parsed, :fields => %w{line} end But I keep getting this error: NoMethodError: undefined method `value'' for nil:NilClass How can i fix this ? Thank you. -- Maxim Ianoglo -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
Jeff McCune
2010-Apr-16 15:48 UTC
Re: [Puppet Users] Custom Types: issue with accessing resources in provider from type
Hi, This question will probably get a better response on the Puppet developer mailing list. -Jeff -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.