def run
config[:cookbook_path] ||= Chef::Config[:cookbook_path]
assert_environment_valid!
warn_about_cookbook_shadowing
version_constraints_to_update = {}
@server_side_cookbooks = Chef::CookbookVersion.list
if config[:all]
justify_width = cookbook_repo.cookbook_names.map {|name| name.size}.max.to_i + 2
cookbook_repo.each do |cookbook_name, cookbook|
cookbook.freeze_version if config[:freeze]
upload(cookbook, justify_width)
version_constraints_to_update[cookbook_name] = cookbook.version
end
else
if @name_args.empty?
show_usage
ui.error("You must specify the --all flag or at least one cookbook name")
exit 1
end
justify_width = @name_args.map {|name| name.size }.max.to_i + 2
@name_args.each do |cookbook_name|
begin
cookbook = cookbook_repo[cookbook_name]
if config[:depends]
cookbook.metadata.dependencies.each do |dep, versions|
@name_args.push dep
end
end
cookbook.freeze_version if config[:freeze]
upload(cookbook, justify_width)
version_constraints_to_update[cookbook_name] = cookbook.version
rescue Exceptions::CookbookNotFoundInRepo => e
ui.error("Could not find cookbook #{cookbook_name} in your cookbook path, skipping it")
Log.debug(e)
end
end
end
ui.info "upload complete"
update_version_constraints(version_constraints_to_update) if config[:environment]
end