summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVasu1105 <vasundhara.jagdale@msystechnologies.com>2019-10-22 19:04:02 +0530
committerVasu1105 <vasundhara.jagdale@msystechnologies.com>2019-12-16 12:33:57 +0530
commit485cd1b68c7b912c936175688e14741db587b664 (patch)
tree7802df153f37b6c2e43bd03db9ce347abbb36280 /lib
parentcd444f5dfd39e4494e0a8495b20b39259dab923a (diff)
downloadchef-485cd1b68c7b912c936175688e14741db587b664.tar.gz
Genrates metadata.json from metadata.rb if json file does not exist.
Signed-off-by: Vasu1105 <vasundhara.jagdale@msystechnologies.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/chef/cookbook_uploader.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/chef/cookbook_uploader.rb b/lib/chef/cookbook_uploader.rb
index ffc4040194..bf2d94b2ba 100644
--- a/lib/chef/cookbook_uploader.rb
+++ b/lib/chef/cookbook_uploader.rb
@@ -46,6 +46,12 @@ class Chef
end
def upload_cookbooks
+ cookbooks.each do |cookbook|
+ next if cookbook.all_files.include?("#{cookbook.root_paths[0]}/metadata.json")
+
+ generate_metadata_json(cookbook.name.to_s,cookbook)
+ end
+
# Syntax Check
validate_cookbooks
# generate checksums of cookbook files and create a sandbox
@@ -114,6 +120,13 @@ class Chef
Chef::Log.info("Upload complete!")
end
+ def generate_metadata_json(cookbook_name,cookbook)
+ metadata = Chef::Knife::CookbookMetadata.new
+ metadata.generate_metadata_from_file(cookbook_name, "#{cookbook.root_paths[0]}/metadata.rb")
+ cookbook.all_files << "#{cookbook.root_paths[0]}/metadata.json"
+ cookbook.cookbook_manifest.send(:generate_manifest)
+ end
+
def uploader_function_for(file, checksum, url, checksums_to_upload)
lambda do
# Checksum is the hexadecimal representation of the md5,