Skip to content
This repository has been archived by the owner on Nov 25, 2024. It is now read-only.

Task to manage chefignore file #90

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions lib/builderator/tasks/berkshelf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,26 @@ def configure
Interface.berkshelf.write
end

desc 'chefignore', 'Create or Update chefignore to ignore .builderator directory'
def chefignore
ignore_file_list = ['.builderator']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@athompson-r7 how about making this a method_option (--ignore-files) and defaulting to [".builderator"]?

ignore = Util.relative_path('chefignore').to_s
ignore_file = ::File.readlines(ignore)
ignore_file.map! { |i| i.chomp }
files = ignore_file_list.all? { |i| ignore_file.include?(i) }
unless files
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about unless all_files_ignored instead?

file = ::File.open(ignore, 'a')
file.printf("\n# Builderator Added Values\n")
say_status :chefignore, "Adding the following to chefignore: #{ignore_file_list.join(',')}. Add this to SCM!", :yellow
ignore_file_list.each do |ignore|
file.puts(ignore)
end
end
dest_chefignore = Interface.berkshelf.directory.join('chefignore')
::FileUtils.rm dest_chefignore if ::File.exist?(dest_chefignore)
::FileUtils.cp ignore, dest_chefignore
end

desc 'metadata COOKBOOK', 'Generate metadata.json from metadata.rb for a COOKBOOK that has a path'
def metadata(cookbook)
fail "Cookbook #{ cookbook } does not have a path!" unless Config.cookbook.depends.has?(cookbook) &&
Expand All @@ -39,7 +59,9 @@ def metadata(cookbook)

desc 'vendor', 'Vendor a cookbook release and its dependencies'
def vendor
invoke :chefignore, [], options
invoke :configure, [], options

empty_directory Interface.berkshelf.vendor

command = "#{Interface.berkshelf.command} vendor #{Interface.berkshelf.vendor} "
Expand Down