On Tue, May 21, 2013 at 1:38 PM, Adrien Thebo <[email protected]> wrote:

> It looks like PackageProvider#query is being called in the #properties
> method at (
> https://github.com/puppetlabs/puppet/blob/master/lib/puppet/provider/package.rb#L19
> ).
>

Ah!  Thanks.  I'd missed that query call. (After a fair amount of looking,
too!  But, for that file, only with eyeballs, not grep. Ah well.)

-Fritz

On Tue, May 21, 2013 at 1:38 PM, Adrien Thebo <[email protected]> wrote:

> It looks like PackageProvider#query is being called in the #properties
> method at (
> https://github.com/puppetlabs/puppet/blob/master/lib/puppet/provider/package.rb#L19).
> I deleted that method and ran the specs to see what blows up:
>
>   1) Package provider gem should be able to get a list of existing packages
>      Failure/Error: package.properties[:provider].should == provider.name
>       NoMethodError:
>        undefined method `properties' for
> (provider=gem):Puppet::Type::Package::ProviderGem
>      # ./spec/integration/provider/package_spec.rb:39:in `block (5 levels)
> in <top (required)>'
>      # ./spec/integration/provider/package_spec.rb:37:in `each'
>      # ./spec/integration/provider/package_spec.rb:37:in `block (4 levels)
> in <top (required)>'
>
>   2) Puppet::Type::Package::ProviderPip query should return a hash when
> pip and the package are present
>      Failure/Error: @provider.query.should == {
>      NoMethodError:
>        undefined method `properties' for
> (provider=pip):Puppet::Type::Package::ProviderPip
>      # ./lib/puppet/provider/package/pip.rb:51:in `block in query'
>      # ./lib/puppet/provider/package/pip.rb:50:in `each'
>      # ./lib/puppet/provider/package/pip.rb:50:in `query'
>      # ./spec/unit/provider/package/pip_spec.rb:81:in `block (3 levels) in
> <top (required)>'
>
>   3) Puppet::Type::Package::ProviderMsi#uninstall should require the
> productcode
>      Failure/Error: expect do
>        expected Puppet::Error with message matching /The productcode
> property is missing./, got #<NameError: undefined local variable or method
> `properties' for
> Package[mysql-5.1.58-win-x64](provider=msi):Puppet::Type::Package::ProviderMsi>
>      # ./spec/unit/provider/package/msi_spec.rb:156:in `block (3 levels)
> in <top (required)>'
>
>   4) Puppet::Type::Package::ProviderMsi#uninstall should uninstall using
> the productcode
>      Failure/Error: provider.uninstall
>      NameError:
>        undefined local variable or method `properties' for
> Package[mysql-5.1.58-win-x64](provider=msi):Puppet::Type::Package::ProviderMsi
>      # ./lib/puppet/provider/package/msi.rb:83:in `uninstall'
>      # ./spec/unit/provider/package/msi_spec.rb:165:in `block (3 levels)
> in <top (required)>'
>
>   5) Puppet::Type::Package::ProviderMsi#uninstall should warn if the
> package requests a reboot
>      Failure/Error: provider.uninstall
>      NameError:
>        undefined local variable or method `properties' for
> Package[mysql-5.1.58-win-x64](provider=msi):Puppet::Type::Package::ProviderMsi
>      # ./lib/puppet/provider/package/msi.rb:83:in `uninstall'
>      # ./spec/unit/provider/package/msi_spec.rb:174:in `block (3 levels)
> in <top (required)>'
>
>   6) Puppet::Type::Package::ProviderMsi#uninstall should warn if reboot
> initiated
>      Failure/Error: provider.uninstall
>      NameError:
>        undefined local variable or method `properties' for
> Package[mysql-5.1.58-win-x64](provider=msi):Puppet::Type::Package::ProviderMsi
>      # ./lib/puppet/provider/package/msi.rb:83:in `uninstall'
>      # ./spec/unit/provider/package/msi_spec.rb:183:in `block (3 levels)
> in <top (required)>'
>
>   7) Puppet::Type::Package::ProviderMsi#uninstall should warn if reboot
> required
>      Failure/Error: provider.uninstall
>      NameError:
>        undefined local variable or method `properties' for
> Package[mysql-5.1.58-win-x64](provider=msi):Puppet::Type::Package::ProviderMsi
>      # ./lib/puppet/provider/package/msi.rb:83:in `uninstall'
>      # ./spec/unit/provider/package/msi_spec.rb:192:in `block (3 levels)
> in <top (required)>'
>
>   8) Puppet::Type::Package::ProviderGem#instances should return ensure
> values as an array of installed versions
>      Failure/Error: provider_class.instances.map {|p| p.properties}.should
> == [
>      NoMethodError:
>        undefined method `properties' for
> (provider=gem):Puppet::Type::Package::ProviderGem
>      # ./spec/unit/provider/package/gem_spec.rb:127:in `block (4 levels)
> in <top (required)>'
>      # ./spec/unit/provider/package/gem_spec.rb:127:in `map'
>      # ./spec/unit/provider/package/gem_spec.rb:127:in `block (3 levels)
> in <top (required)>'
>
>   9) Puppet::Type::Package::ProviderGem#instances should not fail when an
> unmatched line is returned
>      Failure/Error: provider_class.instances.map {|p| p.properties}.
>      NoMethodError:
>        undefined method `properties' for
> (provider=gem):Puppet::Type::Package::ProviderGem
>      # ./spec/unit/provider/package/gem_spec.rb:137:in `block (4 levels)
> in <top (required)>'
>      # ./spec/unit/provider/package/gem_spec.rb:137:in `map'
>      # ./spec/unit/provider/package/gem_spec.rb:137:in `block (3 levels)
> in <top (required)>'
>
>   10) Puppet::Type::Package::ProviderOpkg when querying self.instances
> returns an array of packages
>      Failure/Error: installed_packages[0].properties.should ==
>      NoMethodError:
>        undefined method `properties' for
> (provider=opkg):Puppet::Type::Package::ProviderOpkg
>      # ./spec/unit/provider/package/opkg_spec.rb:143:in `block (4 levels)
> in <top (required)>'
>
>   11) Puppet::Type::Package::ProviderRpm self.instances returns an array
> of packages
>      Failure/Error: installed_packages[0].properties.should ==
>      NoMethodError:
>        undefined method `properties' for
> (provider=rpm):Puppet::Type::Package::ProviderRpm
>      # ./spec/unit/provider/package/rpm_spec.rb:79:in `block (3 levels) in
> <top (required)>'
>
>   12) Puppet::Type::Package::ProviderAptitude when retrieving ensure
> should detect absent packages
>      Failure/Error: pkg.property(:ensure).retrieve.should == expect
>      NoMethodError:
>        undefined method `properties' for
> Package[faff](provider=aptitude):Puppet::Type::Package::ProviderAptitude
>      # ./lib/puppet/type/package.rb:178:in `retrieve'
>      # ./spec/unit/provider/package/aptitude_spec.rb:25:in `block (4
> levels) in <top (required)>'
>
>   13) Puppet::Type::Package::ProviderAptitude when retrieving ensure
> should detect 1.2.3-1 packages
>      Failure/Error: pkg.property(:ensure).retrieve.should == expect
>      NoMethodError:
>        undefined method `properties' for
> Package[faff](provider=aptitude):Puppet::Type::Package::ProviderAptitude
>      # ./lib/puppet/type/package.rb:178:in `retrieve'
>      # ./spec/unit/provider/package/aptitude_spec.rb:25:in `block (4
> levels) in <top (required)>'
>
>   14) Puppet::Type::Package::ProviderPacman when fetching a package list
> should return installed packages with their versions
>      Failure/Error: packages[0].properties.should == {
>      NoMethodError:
>        undefined method `properties' for
> (provider=pacman):Puppet::Type::Package::ProviderPacman
>      # ./spec/unit/provider/package/pacman_spec.rb:201:in `block (3
> levels) in <top (required)>'
>
>   15) Puppet::Type::Package::ProviderAptrpm when retrieving ensure should
> report absent packages
>      Failure/Error: pkg.property(:ensure).retrieve.should == :absent
>      NoMethodError:
>        undefined method `properties' for
> Package[faff](provider=aptrpm):Puppet::Type::Package::ProviderAptrpm
>      # ./lib/puppet/type/package.rb:178:in `retrieve'
>      # ./spec/unit/provider/package/aptrpm_spec.rb:27:in `block (3 levels)
> in <top (required)>'
>
>   16) Puppet::Type::Package::ProviderAptrpm when retrieving ensure should
> report present packages correctly
>      Failure/Error: pkg.property(:ensure).retrieve.should == "1.2.3-1-5"
>      NoMethodError:
>        undefined method `properties' for
> Package[faff](provider=aptrpm):Puppet::Type::Package::ProviderAptrpm
>      # ./lib/puppet/type/package.rb:178:in `retrieve'
>      # ./spec/unit/provider/package/aptrpm_spec.rb:32:in `block (3 levels)
> in <top (required)>'
>
> It looks like the #query method is only called once and the #properties
> method serves to memoize that value. There might be other ways to implement
> this, but it does look like the #query method is still used heavily.
>
>
> On Fri, May 17, 2013 at 12:30 PM, John E Fritz <[email protected]> wrote:
>
>> All the package providers supplied with Puppet seem to implement or
>> inherit the query method, but as far as we can tell, this isn't used in
>> other parts of the system.  Is it required?
>>
>> Until June 2007, it was in used by the package type (in
>> lib/puppet/type/package.rb) in the exists? and retrieve method, but
>> commit 73502a7 got rid of those (but left a comment mentioning query above
>> the exists? method).
>>
>> We don't want to leave out something people rely on, but we also don't
>> want to do unnecessary cargo-culting.
>>
>> John Fritz and Jim Toth
>>
>>  --
>> 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 [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at http://groups.google.com/group/puppet-dev?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
>
> --
> Adrien Thebo | Puppet Labs
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/puppet-dev?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-dev?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to