summaryrefslogtreecommitdiff
path: root/lib/chef/provider/package
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2018-01-29 16:56:11 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2018-03-15 18:03:29 -0700
commita8ab756cb36c073c324359cace903191a2db52c8 (patch)
treebdc7d9ceaa1029590da8e4a210362f7dffe49794 /lib/chef/provider/package
parentdd236ac36c54c54897de5f6e42d5f19737518b43 (diff)
downloadchef-a8ab756cb36c073c324359cace903191a2db52c8.tar.gz
add specs for YumCache fascade
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/provider/package')
-rw-r--r--lib/chef/provider/package/yum/python_helper.rb3
-rw-r--r--lib/chef/provider/package/yum/yum_cache.rb18
2 files changed, 15 insertions, 6 deletions
diff --git a/lib/chef/provider/package/yum/python_helper.rb b/lib/chef/provider/package/yum/python_helper.rb
index 2488ca38c1..cbdd85bbbd 100644
--- a/lib/chef/provider/package/yum/python_helper.rb
+++ b/lib/chef/provider/package/yum/python_helper.rb
@@ -1,5 +1,5 @@
#
-# Copyright:: Copyright 2016-2017, Chef Software Inc.
+# Copyright:: Copyright 2016-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,6 +18,7 @@
require "chef/mixin/which"
require "chef/mixin/shell_out"
require "chef/provider/package/yum/version"
+require "singleton"
require "timeout"
class Chef
diff --git a/lib/chef/provider/package/yum/yum_cache.rb b/lib/chef/provider/package/yum/yum_cache.rb
index 2a6c6b8d2a..2c29e6ad71 100644
--- a/lib/chef/provider/package/yum/yum_cache.rb
+++ b/lib/chef/provider/package/yum/yum_cache.rb
@@ -20,11 +20,16 @@ require "chef/provider/package/yum/python_helper"
require "chef/provider/package"
require "singleton"
+#
+# These are largely historical APIs, the YumCache object no longer exists and this is a
+# fascade over the python helper class. It should be considered deprecated-lite and
+# no new APIs should be added and should be added to the python_helper instead.
+#
+
class Chef
class Provider
class Package
class Yum < Chef::Provider::Package
- # Cache for our installed and available packages, pulled in from yum-dump.py
class YumCache
include Singleton
@@ -54,12 +59,12 @@ class Chef
def available_version(name)
p = python_helper.package_query(:whatavailable, name)
- "#{p.version}.#{p.arch}"
+ "#{p.version}.#{p.arch}" unless p.version.nil?
end
def installed_version(name)
p = python_helper.package_query(:whatinstalled, name)
- "#{p.version}.#{p.arch}"
+ "#{p.version}.#{p.arch}" unless p.version.nil?
end
def package_available?(name)
@@ -67,13 +72,16 @@ class Chef
!p.version.nil?
end
+ # NOTE that it is the responsibility of the python_helper to get these APIs correct and
+ # we do not do any validation here that the e.g. version or arch matches the requested value
+ # (because the bigger issue there is a buggy+broken python_helper -- so don't try to fix those
+ # kinds of bugs here)
def version_available?(name, version, arch = nil)
p = python_helper.package_query(:whatavailable, name, version, arch)
!p.version.nil?
end
- private
-
+ # @api private
def python_helper
@python_helper ||= PythonHelper.instance
end