summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2017-04-11 13:22:06 +0100
committerGitHub <noreply@github.com>2017-04-11 13:22:06 +0100
commitab621a6151c309f7b9787c8c7134453ae6e04e36 (patch)
treeafeb0316626c85c5457f0e59c06107ed7170b30d
parent9f525597f4e40a3dfec7bf469cbe2677de58200b (diff)
parentd9a7c0863a67c066523584f11b7a1aeda60a2e05 (diff)
downloadchef-ab621a6151c309f7b9787c8c7134453ae6e04e36.tar.gz
Merge pull request #6047 from coderanger/yum-options
Fix some fallout from the options converstion to an array
-rw-r--r--lib/chef/provider/package.rb6
-rw-r--r--lib/chef/provider/package/yum.rb2
-rw-r--r--spec/unit/provider/package/yum_spec.rb14
3 files changed, 13 insertions, 9 deletions
diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb
index 65dda05f85..4b73f47ed3 100644
--- a/lib/chef/provider/package.rb
+++ b/lib/chef/provider/package.rb
@@ -297,7 +297,11 @@ class Chef
def expand_options(options)
# its deprecated but still work to do to deprecate it fully
#Chef.deprecated(:package_misc, "expand_options is deprecated, use shell_out_compact or shell_out_compact_timeout instead")
- options ? " #{options}" : ""
+ if options
+ " #{options.is_a?(Array) ? Shellwords.join(options) : options}"
+ else
+ ""
+ end
end
# Check the current_version against either the candidate_version or the new_version
diff --git a/lib/chef/provider/package/yum.rb b/lib/chef/provider/package/yum.rb
index f1ba9dd4eb..d87e421409 100644
--- a/lib/chef/provider/package/yum.rb
+++ b/lib/chef/provider/package/yum.rb
@@ -194,7 +194,7 @@ class Chef
def manage_extra_repo_control
if new_resource.options
repo_control = []
- new_resource.options.split.each do |opt|
+ new_resource.options.each do |opt|
repo_control << opt if opt =~ /--(enable|disable)repo=.+/
end
diff --git a/spec/unit/provider/package/yum_spec.rb b/spec/unit/provider/package/yum_spec.rb
index e0a5f8c862..e8eb830f65 100644
--- a/spec/unit/provider/package/yum_spec.rb
+++ b/spec/unit/provider/package/yum_spec.rb
@@ -278,31 +278,31 @@ describe Chef::Provider::Package::Yum do
end
it "should flush the cache if :before is true" do
- allow(@new_resource).to receive(:flush_cache).and_return({ :after => false, :before => true })
+ @new_resource.flush_cache({ :after => false, :before => true })
expect(@yum_cache).to receive(:reload).once
@provider.load_current_resource
end
it "should flush the cache if :before is false" do
- allow(@new_resource).to receive(:flush_cache).and_return({ :after => false, :before => false })
+ @new_resource.flush_cache({ :after => false, :before => false })
expect(@yum_cache).not_to receive(:reload)
@provider.load_current_resource
end
it "should detect --enablerepo or --disablerepo when passed among options, collect them preserving order and notify the yum cache" do
- allow(@new_resource).to receive(:options).and_return("--stuff --enablerepo=foo --otherthings --disablerepo=a,b,c --enablerepo=bar")
+ @new_resource.options("--stuff --enablerepo=foo --otherthings --disablerepo=a,b,c --enablerepo=bar")
expect(@yum_cache).to receive(:enable_extra_repo_control).with("--enablerepo=foo --disablerepo=a,b,c --enablerepo=bar")
@provider.load_current_resource
end
it "should let the yum cache know extra repos are disabled if --enablerepo or --disablerepo aren't among options" do
- allow(@new_resource).to receive(:options).and_return("--stuff --otherthings")
+ @new_resource.options("--stuff --otherthings")
expect(@yum_cache).to receive(:disable_extra_repo_control)
@provider.load_current_resource
end
it "should let the yum cache know extra repos are disabled if options aren't set" do
- allow(@new_resource).to receive(:options).and_return(nil)
+ @new_resource.options(nil)
expect(@yum_cache).to receive(:disable_extra_repo_control)
@provider.load_current_resource
end
@@ -558,7 +558,7 @@ describe Chef::Provider::Package::Yum do
it "installs the package with the options given in the resource" do
@provider.load_current_resource
allow(@provider).to receive(:candidate_version).and_return("11")
- allow(@new_resource).to receive(:options).and_return("--disablerepo epmd")
+ @new_resource.options("--disablerepo epmd")
allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1)
expect(@provider).to receive(:yum_command).with(
"-d0 -e0 -y --disablerepo epmd install cups-11"
@@ -2261,7 +2261,7 @@ describe "Chef::Provider::Package::Yum - Multi" do
expect(@provider).to receive(:yum_command).with(
"-d0 -e0 -y --disablerepo epmd install cups-1.2.4-11.19.el5 vim-1.0"
)
- allow(@new_resource).to receive(:options).and_return("--disablerepo epmd")
+ @new_resource.options("--disablerepo epmd")
@provider.install_package(%w{cups vim}, ["1.2.4-11.19.el5", "1.0"])
end