summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2017-04-02 10:36:21 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2017-04-02 10:36:21 -0700
commit5daf9335db751d651ed215c012cb932ff2ef425d (patch)
treedb0692cd03271926d0b474fca748c63d9285df26
parent40b8dbcc1be0454873b79b04537baa074c221361 (diff)
downloadchef-5daf9335db751d651ed215c012cb932ff2ef425d.tar.gz
Chef-13: coerce package options property to a Stringlcg/package-options
Windows side we still can't support this kind of API, this is for Unix-ey stuff. Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--lib/chef/provider/package.rb6
-rw-r--r--lib/chef/provider/package/windows/msi.rb2
-rw-r--r--lib/chef/resource/chocolatey_package.rb5
-rw-r--r--lib/chef/resource/package.rb2
-rw-r--r--lib/chef/resource/windows_package.rb5
-rw-r--r--spec/unit/provider/package/windows/msi_spec.rb2
-rw-r--r--spec/unit/resource/package_spec.rb9
7 files changed, 19 insertions, 12 deletions
diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb
index 6d4535fff5..c8a1b06a55 100644
--- a/lib/chef/provider/package.rb
+++ b/lib/chef/provider/package.rb
@@ -52,11 +52,7 @@ class Chef
end
def options
- if new_resource.options.is_a?(String)
- new_resource.options.shellsplit
- else
- new_resource.options
- end
+ new_resource.options
end
def check_resource_semantics!
diff --git a/lib/chef/provider/package/windows/msi.rb b/lib/chef/provider/package/windows/msi.rb
index 7e6048ce49..ef8b674b60 100644
--- a/lib/chef/provider/package/windows/msi.rb
+++ b/lib/chef/provider/package/windows/msi.rb
@@ -1,6 +1,6 @@
#
# Author:: Bryan McLellan <btm@loftninjas.org>
-# Copyright:: Copyright 2014-2016, Chef Software, Inc.
+# Copyright:: Copyright 2014-2017, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/lib/chef/resource/chocolatey_package.rb b/lib/chef/resource/chocolatey_package.rb
index 5460661f6d..a443b9a1d7 100644
--- a/lib/chef/resource/chocolatey_package.rb
+++ b/lib/chef/resource/chocolatey_package.rb
@@ -1,6 +1,6 @@
#
# Author:: Adam Jacob (<adam@chef.io>)
-# Copyright:: Copyright 2008-2016, Chef Software, Inc.
+# Copyright:: Copyright 2008-2017, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -31,6 +31,9 @@ class Chef
@resource_name = :chocolatey_package
end
+ # windows can't take Array options yet
+ property :options, String
+
property :package_name, [String, Array], coerce: proc { |x| [x].flatten }
property :version, [String, Array], coerce: proc { |x| [x].flatten }
diff --git a/lib/chef/resource/package.rb b/lib/chef/resource/package.rb
index a1f174a6f3..5647f203d2 100644
--- a/lib/chef/resource/package.rb
+++ b/lib/chef/resource/package.rb
@@ -36,7 +36,7 @@ class Chef
property :package_name, [ String, Array ], identity: true
property :version, [ String, Array ]
- property :options, [ String, Array ]
+ property :options, [ String, Array ], coerce: proc { |x| x.is_a?(String) ? x.shellsplit : x }
property :response_file, String, desired_state: false
property :response_file_variables, Hash, default: lazy { {} }, desired_state: false
property :source, String, desired_state: false
diff --git a/lib/chef/resource/windows_package.rb b/lib/chef/resource/windows_package.rb
index 0e8dd39672..e37bad4b0a 100644
--- a/lib/chef/resource/windows_package.rb
+++ b/lib/chef/resource/windows_package.rb
@@ -1,6 +1,6 @@
#
# Author:: Bryan McLellan <btm@loftninjas.org>
-# Copyright:: Copyright 2014-2016, Chef Software, Inc.
+# Copyright:: Copyright 2014-2017, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -37,6 +37,9 @@ class Chef
@source ||= source(@package_name) if @package_name.downcase.end_with?(".msi")
end
+ # windows can't take array options yet
+ property :options, String
+
# Unique to this resource
property :installer_type, Symbol
property :timeout, [ String, Integer ], default: 600
diff --git a/spec/unit/provider/package/windows/msi_spec.rb b/spec/unit/provider/package/windows/msi_spec.rb
index c8099c38d0..aa528ab90e 100644
--- a/spec/unit/provider/package/windows/msi_spec.rb
+++ b/spec/unit/provider/package/windows/msi_spec.rb
@@ -1,6 +1,6 @@
#
# Author:: Bryan McLellan <btm@loftninjas.org>
-# Copyright:: Copyright 2014-2016, Chef Software, Inc.
+# Copyright:: Copyright 2014-2017, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
diff --git a/spec/unit/resource/package_spec.rb b/spec/unit/resource/package_spec.rb
index 8c00ea2bdd..84f92f26b5 100644
--- a/spec/unit/resource/package_spec.rb
+++ b/spec/unit/resource/package_spec.rb
@@ -61,7 +61,12 @@ describe Chef::Resource::Package do
it "should accept a string for the options" do
@resource.options "something"
- expect(@resource.options).to eql("something")
+ expect(@resource.options).to eql(["something"])
+ end
+
+ it "should split options" do
+ @resource.options "-a -b 'arg with spaces' -b \"and quotes\""
+ expect(@resource.options).to eql(["-a", "-b", "arg with spaces", "-b", "and quotes"])
end
describe "when it has a package_name and version" do
@@ -74,7 +79,7 @@ describe Chef::Resource::Package do
it "describes its state" do
state = @resource.state_for_resource_reporter
expect(state[:version]).to eq("10.9.8")
- expect(state[:options]).to eq("-al")
+ expect(state[:options]).to eq(["-al"])
end
it "returns the file path as its identity" do