Created
March 26, 2014 22:12
-
-
Save danielsdeleo/9794820 to your computer and use it in GitHub Desktop.
Show all the places where you have multiple cookbooks that shadow each other.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Show all the places where you have multiple cookbooks that shadow each other. | |
# | |
# Run this as: | |
# | |
# knife exec shadow-check.rb | |
config = Chef::Config | |
cookbook_loader = begin | |
Chef::Cookbook::FileVendor.on_create { |manifest| Chef::Cookbook::FileSystemFileVendor.new(manifest, config[:cookbook_path]) } | |
Chef::CookbookLoader.new(config[:cookbook_path]) | |
end | |
ui = Chef::Knife::UI.new($stdout, $stderr, $stdin, {}) | |
cookbook_loader.load_cookbooks | |
if cookbook_loader.merged_cookbooks.empty? | |
ui.msg "cookbooks ok" | |
else | |
ui.warn "* " * 40 | |
ui.warn(<<-WARNING) | |
The cookbooks: #{cookbook_loader.merged_cookbooks.join(', ')} exist in multiple places in your cookbook_path. | |
A composite version of these cookbooks has been compiled for uploading. | |
#{ui.color('IMPORTANT:', :red, :bold)} In a future version of Chef, this behavior will be removed and you will no longer | |
be able to have the same version of a cookbook in multiple places in your cookbook_path. | |
WARNING | |
ui.warn "The affected cookbooks are located:" | |
ui.output ui.format_for_display(cookbook_loader.merged_cookbook_paths) | |
ui.warn "* " * 40 | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment