lib/berkshelf.rb in berkshelf-6.3.4 vs lib/berkshelf.rb in berkshelf-7.0.0

- old
+ new

@@ -1,32 +1,31 @@ + # XXX: work around logger spam from hashie # https://github.com/intridea/hashie/issues/394 begin require "hashie" require "hashie/logger" Hashie.logger = Logger.new(nil) rescue LoadError # intentionally left blank end -require "buff/extensions" require "cleanroom" require "digest/md5" require "forwardable" require "json" require "pathname" -require "ridley" require "semverse" require "solve" require "thor" require "uri" -require "celluloid" JSON.create_id = nil require_relative "berkshelf/core_ext" require_relative "berkshelf/thor_ext" +require "berkshelf/chef_config_compat" module Berkshelf Encoding.default_external = Encoding::UTF_8 def self.fix_proxies @@ -66,11 +65,11 @@ class << self include Mixin::Logging attr_writer :berkshelf_path - attr_accessor :ui + attr_writer :ui # @return [Pathname] def root @root ||= Pathname.new(File.expand_path("../", File.dirname(__FILE__))) end @@ -103,13 +102,13 @@ Berkshelf::Config.set_config(config) end # The Chef configuration file. # - # @return [Ridley::Chef::Config] + # @return [Berkshelf::ChefConfigCompat] def chef_config - @chef_config ||= Ridley::Chef::Config.new(ENV["BERKSHELF_CHEF_CONFIG"]) + @chef_config ||= Berkshelf::ChefConfigCompat.new(ENV["BERKSHELF_CHEF_CONFIG"]) end # @param [Ridley::Chef::Config] def chef_config=(config) @chef_config = config @@ -149,33 +148,33 @@ else options[:ssl_verify] end ssl_options[:cert_store] = ssl_policy.store if ssl_policy.store - ridley_options = options.slice(:ssl) + ridley_options = {} + ridley_options[:ssl] = options[:ssl] if options.key?(:ssl) ridley_options[:server_url] = options[:server_url] || Berkshelf.config.chef.chef_server_url ridley_options[:client_name] = options[:client_name] || Berkshelf.config.chef.node_name ridley_options[:client_key] = options[:client_key] || Berkshelf.config.chef.client_key ridley_options[:ssl] = ssl_options - unless ridley_options[:server_url].present? + if !ridley_options[:server_url] || ridley_options[:server_url] =~ /^\s*$/ raise ChefConnectionError, "Missing required attribute in your Berkshelf configuration: chef.server_url" end - unless ridley_options[:client_name].present? + if !ridley_options[:client_name] || ridley_options[:client_name] =~ /^\s*$/ raise ChefConnectionError, "Missing required attribute in your Berkshelf configuration: chef.node_name" end - unless ridley_options[:client_key].present? + if !ridley_options[:client_key] || ridley_options[:client_key] =~ /^\s*$/ raise ChefConnectionError, "Missing required attribute in your Berkshelf configuration: chef.client_key" end - # @todo Something scary going on here - getting an instance of Kitchen::Logger from test-kitchen - # https://github.com/opscode/test-kitchen/blob/master/lib/kitchen.rb#L99 - Celluloid.logger = nil unless ENV["DEBUG_CELLULOID"] - Ridley.open(ridley_options, &block) - rescue Ridley::Errors::RidleyError => ex + RidleyCompat.new_client(ridley_options, &block) + rescue ChefConnectionError, BerkshelfError + raise + rescue => ex log.exception(ex) raise ChefConnectionError, ex # todo implement end # Specify the format for output @@ -218,27 +217,23 @@ end end end require_relative "berkshelf/lockfile" -require_relative "berkshelf/base_generator" require_relative "berkshelf/berksfile" require_relative "berkshelf/cached_cookbook" require_relative "berkshelf/cli" +require_relative "berkshelf/chef_config_compat" require_relative "berkshelf/community_rest" -require_relative "berkshelf/cookbook_generator" require_relative "berkshelf/cookbook_store" require_relative "berkshelf/config" require_relative "berkshelf/dependency" require_relative "berkshelf/downloader" -require_relative "berkshelf/init_generator" require_relative "berkshelf/installer" require_relative "berkshelf/logger" require_relative "berkshelf/resolver" require_relative "berkshelf/source" require_relative "berkshelf/source_uri" require_relative "berkshelf/validator" require_relative "berkshelf/ssl_policies" -Ridley.logger = Berkshelf.logger Berkshelf.logger.level = Logger::WARN -Celluloid.logger.level = Logger::ERROR