puppet-filemapper icon indicating copy to clipboard operation
puppet-filemapper copied to clipboard

defaultto values on properties are not respected

Open jhoblitt opened this issue 12 years ago • 3 comments

It appears that the properties of resources created by filemapper that have a defaultto set but do not have a value presently discoverable from the system, have a nil value. This seems to be incorrect behavior and these properties should have the defaultto value.

jhoblitt avatar Jul 24 '13 20:07 jhoblitt

I just did a quick scan of the Puppet core providers and it appears that ParsedFile is one of the few that propagates this information from the type instance down to the provider instance by overwriting the inherited definition of self.mk_resource_methods:

if @property_hash[attr] or self.class.valid_attr?(self.class.name, attr)
  @property_hash[attr] || :absent
else
  if defined?(@resource)
    @resource.should(attr)
  else
    nil
  end
end

Note the fallthrough to @resource.should

Most providers use the default implementation defined in the top-level provider class:

@property_hash[attr] || :absent

Generally, the Type instance should represent the state in the catalog, what the resource "should be", and the Provider instance should represent the state of the system --- what the resource actually "is".

ParsedFile is full of many ideas, most of them bad. I'm not sure exposing "should" values inside the provider is one of the good ones.

Sharpie avatar Mar 09 '14 05:03 Sharpie

Speaking of which... it looks like Filemapper used to return should values, but this behavior was pulled in a2fc3ad.

Sharpie avatar Mar 09 '14 06:03 Sharpie

Is this still an issue?

jyaworski avatar Mar 05 '16 06:03 jyaworski