summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantima-gupta <agupta@msystechnologies.com>2020-07-13 18:48:44 +0530
committerantima-gupta <agupta@msystechnologies.com>2020-07-13 18:48:44 +0530
commit4d8fda8e536432355720c05293d24c9c920df3be (patch)
tree5580aadea45a1b19332860b157cd177fdeb891e6
parent04eac6a86e51d71cdbfbe163ebb70a887c1c9ddb (diff)
downloadchef-4d8fda8e536432355720c05293d24c9c920df3be.tar.gz
Fixed windows cookbooks upload issue.
Updated cookbook_path option used File::PATH_SEPARATOR to split path. Added rspec for upload multiple paths cookbooks. Signed-off-by: antima-gupta <agupta@msystechnologies.com>
-rw-r--r--lib/chef/knife/cookbook_upload.rb10
-rw-r--r--spec/integration/knife/cookbook_upload_spec.rb26
2 files changed, 32 insertions, 4 deletions
diff --git a/lib/chef/knife/cookbook_upload.rb b/lib/chef/knife/cookbook_upload.rb
index 14e8419bec..803467fc2f 100644
--- a/lib/chef/knife/cookbook_upload.rb
+++ b/lib/chef/knife/cookbook_upload.rb
@@ -34,10 +34,12 @@ class Chef
banner "knife cookbook upload [COOKBOOKS...] (options)"
option :cookbook_path,
- short: "-o PATH:PATH",
- long: "--cookbook-path PATH:PATH",
- description: "A colon-separated path to look for cookbooks in.",
- proc: lambda { |o| o.split(":") }
+ short: "-o 'PATH:PATH'",
+ long: "--cookbook-path 'PATH:PATH'",
+ description: "A colon-separated path to look for cookbooks in.
+ Colon seprated path has been deprecated for Windows machine.
+ In windows please use semicolon-separated path(For ex: 'PATH;PATH').",
+ proc: lambda { |o| o.split(File::PATH_SEPARATOR) }
option :freeze,
long: "--freeze",
diff --git a/spec/integration/knife/cookbook_upload_spec.rb b/spec/integration/knife/cookbook_upload_spec.rb
index 79a9efbfb7..e0ab388f50 100644
--- a/spec/integration/knife/cookbook_upload_spec.rb
+++ b/spec/integration/knife/cookbook_upload_spec.rb
@@ -97,5 +97,31 @@ describe "knife cookbook upload", :workstation do
expect { knife("cookbook upload x -o #{cb_dir}") }.to raise_error(Chef::Exceptions::MetadataNotValid)
end
end
+
+ when_the_repository "have cookbooks at muliple paths" do
+ let(:cb_dir_first) do
+ File.join(@repository_dir,"cookbooks")
+ .gsub(File::SEPARATOR,File::ALT_SEPARATOR || File::SEPARATOR)
+ end
+
+ let(:cb_dir_second) do
+ File.join(@repository_dir,"test_cookbooks")
+ .gsub(File::SEPARATOR,File::ALT_SEPARATOR || File::SEPARATOR)
+ end
+
+ before(:each) do
+ file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0")
+ file "test_cookbooks/y/metadata.rb", cb_metadata("y", "1.0.0")
+ end
+
+ it "knife cookbook upload with -o or --cookbook-path" do
+ knife("cookbook upload x y -o #{cb_dir_first}#{File::PATH_SEPARATOR}#{cb_dir_second}").should_succeed stderr: <<~EOM
+ Uploading x [1.0.0]
+ Uploading y [1.0.0]
+ Uploaded 2 cookbooks.
+ EOM
+ end
+
+ end
end
end