Hi, A bit of help is needed with this geppetto issue: https://github.com/cloudsmith/geppetto/issues/87 It is about the parameter "name" in relation to "file". Appreciate feedback. Regards - henrik -- 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.
So it would appear the parameter ''name'' acts as namevar for file and exec at least ... its not defined in the type for these explicitly - it seems implicit. This seems historical and I haven''t seen it used before (at least I''ve never used it myself). Does anyone know the history behind this? The following: @key_attribute_parameters ||= ( params = @parameters.find_all { |param| param.isnamevar? or param.name == :name } ) Is defined in puppet/type.rb :-). Not sure if we have this behavior documented - or if its up for deprecation :-). ken. On Wed, Jun 22, 2011 at 6:40 PM, Henrik Lindberg <henrik.lindberg@cloudsmith.com> wrote:> Hi, > A bit of help is needed with this geppetto issue: > https://github.com/cloudsmith/geppetto/issues/87 > > It is about the parameter "name" in relation to "file". > > Appreciate feedback. > > Regards > - henrik > > -- > 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. > >-- 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.
On Wed, Jun 22, 2011 at 08:37:25PM +0100, Ken Barber wrote:> So it would appear the parameter ''name'' acts as namevar for file and > exec at least ... its not defined in the type for these explicitly - > it seems implicit. This seems historical and I haven''t seen it used > before (at least I''ve never used it myself). Does anyone know the > history behind this? > > The following: > > @key_attribute_parameters ||= ( > params = @parameters.find_all { |param| > param.isnamevar? or param.name == :name > } > )I guess this was added because not all types define a namevar. If you have no parameter marked as the namevar, :name is your namevar.> > Is defined in puppet/type.rb :-). Not sure if we have this behavior > documented - or if its up for deprecation :-).I guess the more interesting bits are: def self.validattr?(name) name = symbolize(name) return true if name == :name @validattrs ||= {} unless @validattrs.include?(name) @validattrs[name] = !!(self.validproperty?(name) or self.validparameter?(name) or self.metaparam?(name)) end @validattrs[name] end So name is always considered a valid parameter. In fact name can always be used to reference the namevar parameter: def [](name) name = attr_alias(name) fail("Invalid parameter #{name}(#{name.inspect})") unless self.class.validattr?(name) if name == :name && nv = name_var name = nv end if obj = @parameters[name] # Note that if this is a property, then the value is the "should" value, # not the current value. obj.value else return nil end end At the moment some parts of puppet depend on this behaviour because puppet often uses the value of the name parameter to identify a resource. If we remove the current name translation magic, referencing a resource by the name parameter will obviously not work for resources that dont have a name parameter. Hopefully this will be resolved in the future (always query a resource by uniqueness_key and dont rely on a name parameter at all). For further reading: problems with composite namevars because of the current way to query a resource * http://projects.puppetlabs.com/issues/5605 * http://projects.puppetlabs.com/issues/7629 Experimental patch on puppet-dev by Dan Bode * http://groups.google.com/group/puppet-dev/msg/7295ee43e76c02fd -Stefan> > ken. > > On Wed, Jun 22, 2011 at 6:40 PM, Henrik Lindberg > <henrik.lindberg@cloudsmith.com> wrote: > > Hi, > > A bit of help is needed with this geppetto issue: > > https://github.com/cloudsmith/geppetto/issues/87 > > > > It is about the parameter "name" in relation to "file". > > > > Appreciate feedback. > > > > Regards > > - henrik > > > > -- > > 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. > > > > > > -- > 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. >
Thanks Stefan. A bug (originally a doc bug) and subsequent discussion at Puppetlabs is documented here: https://projects.puppetlabs.com/issues/8096 ken. On Thu, Jun 23, 2011 at 6:11 PM, Stefan Schulte <stefan.schulte@taunusstein.net> wrote:> On Wed, Jun 22, 2011 at 08:37:25PM +0100, Ken Barber wrote: >> So it would appear the parameter ''name'' acts as namevar for file and >> exec at least ... its not defined in the type for these explicitly - >> it seems implicit. This seems historical and I haven''t seen it used >> before (at least I''ve never used it myself). Does anyone know the >> history behind this? >> >> The following: >> >> @key_attribute_parameters ||= ( >> params = @parameters.find_all { |param| >> param.isnamevar? or param.name == :name >> } >> ) > > I guess this was added because not all types define a namevar. If you > have no parameter marked as the namevar, :name is your namevar. >> >> Is defined in puppet/type.rb :-). Not sure if we have this behavior >> documented - or if its up for deprecation :-). > > I guess the more interesting bits are: > > def self.validattr?(name) > name = symbolize(name) > return true if name == :name > @validattrs ||= {} > > unless @validattrs.include?(name) > @validattrs[name] = !!(self.validproperty?(name) or self.validparameter?(name) or self.metaparam?(name)) > end > > @validattrs[name] > end > > So name is always considered a valid parameter. In fact name can always > be used to reference the namevar parameter: > > def [](name) > name = attr_alias(name) > > fail("Invalid parameter #{name}(#{name.inspect})") unless self.class.validattr?(name) > > if name == :name && nv = name_var > name = nv > end > > if obj = @parameters[name] > # Note that if this is a property, then the value is the "should" value, > # not the current value. > obj.value > else > return nil > end > end > > At the moment some parts of puppet depend on this behaviour because puppet > often uses the value of the name parameter to identify a resource. If we > remove the current name translation magic, referencing a resource by the > name parameter will obviously not work for resources that dont have a > name parameter. > > Hopefully this will be resolved in the future (always query a resource > by uniqueness_key and dont rely on a name parameter at all). > > For further reading: > > problems with composite namevars because of the current way to query a > resource > * http://projects.puppetlabs.com/issues/5605 > * http://projects.puppetlabs.com/issues/7629 > > Experimental patch on puppet-dev by Dan Bode > * http://groups.google.com/group/puppet-dev/msg/7295ee43e76c02fd > > -Stefan > >> >> ken. >> >> On Wed, Jun 22, 2011 at 6:40 PM, Henrik Lindberg >> <henrik.lindberg@cloudsmith.com> wrote: >> > Hi, >> > A bit of help is needed with this geppetto issue: >> > https://github.com/cloudsmith/geppetto/issues/87 >> > >> > It is about the parameter "name" in relation to "file". >> > >> > Appreciate feedback. >> > >> > Regards >> > - henrik >> > >> > -- >> > 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. >> > >> > >> >> -- >> 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. >> >-- 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.