-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Berkshelf #2
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,13 @@ module Cookbooks | |
def self.upload_all | ||
cookbooks = File.dirname(Chef::Config[:cookbook_path]) | ||
Dir.chdir(cookbooks) do | ||
puts 'Uploading librarian cookbooks' | ||
upload_cheffile | ||
puts 'Uploading dependency cookbooks' | ||
|
||
if File.exist?('Berksfile') | ||
upload_berksfile | ||
elsif File.exist?('Cheffile') | ||
upload_cheffile | ||
end | ||
|
||
puts 'Uploading site cookbooks' | ||
books = Dir['cookbooks/*'] | ||
|
@@ -28,6 +33,7 @@ def self.upload_cookbooks(path, books) | |
|
||
books = books.collect do |name| | ||
next if Cache.cache(File.join(path, name)) | ||
next if File.file?(File.join(path, name)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess this is because it might erroneously try to upload a single file as a cookbook? Should we make this 'next unless File.dir?'? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think there are conceivably edge cases, for special files (maybe for instance, symlinks, where it might respond to File.file? with true, as well as File.directory? with true, if the target is a directory - unsure of this). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. http://ruby-doc.org/core-2.2.0/File.html#method-c-file-3F
|
||
puts "Will upload #{name}" | ||
cookbook = loader.load_cookbook(name) | ||
c = Chef::Cookbook::SyntaxCheck.for_cookbook(name, path) | ||
|
@@ -62,12 +68,21 @@ def self.upload_site_cookbooks(books) | |
paths.values.flatten.uniq.sort | ||
end | ||
|
||
def self.upload_berksfile | ||
return if ENV['NO_BERKSHELF'] | ||
|
||
FileUtils.mkdir_p('tmp/berkshelf/cookbooks') | ||
system('berks vendor tmp/berkshelf/cookbooks') | ||
cookbooks = Dir.entries('tmp/berkshelf/cookbooks') - %w(. ..) | ||
upload_cookbooks('tmp/berkshelf/cookbooks', cookbooks) | ||
end | ||
|
||
def self.upload_cheffile | ||
unless ENV['NO_LIBRARIAN'] | ||
FileUtils.mkdir_p('tmp/librarian/cookbooks') | ||
system('librarian-chef install --quiet --path tmp/librarian/cookbooks') | ||
upload_cookbooks('tmp/librarian/cookbooks', cheffile_cookbooks.map(&:name)) | ||
end | ||
return if ENV['NO_LIBRARIAN'] | ||
|
||
FileUtils.mkdir_p('tmp/librarian/cookbooks') | ||
system('librarian-chef install --quiet --path tmp/librarian/cookbooks') | ||
upload_cookbooks('tmp/librarian/cookbooks', cheffile_cookbooks.map(&:name)) | ||
end | ||
|
||
def self.cheffile_cookbooks | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was this done for testing? I don't think we want this hardcoded here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it was done for testing. Also was following the README, which doesn't work without this line... i.e.
bundle exec ruby lib/chefdepartie.rb
simply returns without it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good to merge once this is removed, I'll update the readme