module Berkshelf
def self.fix_proxies
def self.fix_proxies ENV["http_proxy"] = ENV["HTTP_PROXY"] if ENV["HTTP_PROXY"] && !ENV["http_proxy"] ENV["https_proxy"] = ENV["HTTPS_PROXY"] if ENV["HTTPS_PROXY"] && !ENV["https_proxy"] ENV["ftp_proxy"] = ENV["FTP_PROXY"] if ENV["FTP_PROXY"] && !ENV["ftp_proxy"] ENV["no_proxy"] = ENV["NO_PROXY"] if ENV["NO_PROXY"] && !ENV["no_proxy"] end
def berkshelf_path
-
(String)
-
def berkshelf_path @berkshelf_path ||= File.expand_path(ENV["BERKSHELF_PATH"] || "~/.berkshelf") end
def chef_config
-
(Berkshelf::ChefConfigCompat)
-
def chef_config @chef_config ||= Berkshelf::ChefConfigCompat.new(ENV["BERKSHELF_CHEF_CONFIG"]) end
def chef_config=(config)
-
(
Ridley::Chef::Config
) --
def chef_config=(config) @chef_config = config end
def config
-
(Berkshelf::Config)
-
def config Berkshelf::Config.instance end
def config=(config)
-
(
Berkshelf::Config
) --
def config=(config) Berkshelf::Config.set_config(config) end
def cookbook_store
-
(Berkshelf::CookbookStore)
-
def cookbook_store CookbookStore.instance end
def formatter
-
(~Formatter)
-
def formatter @formatter ||= HumanFormatter.new end
def initialize_filesystem
def initialize_filesystem FileUtils.mkdir_p(berkshelf_path, mode: 0755) unless File.writable?(berkshelf_path) raise InsufficientPrivledges.new(berkshelf_path) end end
def null_stream
def null_stream @null ||= begin strm = STDOUT.clone strm.reopen(RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ ? "NUL:" : "/dev/null") strm.sync = true strm end end
def ridley_connection(options = {}, &block)
-
(Berkshelf::ChefConnectionError)
-
def ridley_connection(options = {}, &block) ssl_options = {} ssl_options[:verify] = if options[:ssl_verify].nil? Berkshelf.config.ssl.verify else options[:ssl_verify] end ssl_options[:cert_store] = ssl_policy.store if ssl_policy.store 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 if !ridley_options[:server_url] || ridley_options[:server_url] =~ /^\s*$/ raise ChefConnectionError, "Missing required attribute in your Berkshelf configuration: chef.server_url" end if !ridley_options[:client_name] || ridley_options[:client_name] =~ /^\s*$/ raise ChefConnectionError, "Missing required attribute in your Berkshelf configuration: chef.node_name" end if !ridley_options[:client_key] || ridley_options[:client_key].to_s =~ /^\s*$/ raise ChefConnectionError, "Missing required attribute in your Berkshelf configuration: chef.client_key" end RidleyCompat.new_client(**ridley_options, &block) rescue ChefConnectionError, BerkshelfError raise rescue => ex log.exception(ex) raise ChefConnectionError, ex # todo implement end
def root
-
(Pathname)
-
def root @root ||= Pathname.new(File.expand_path("../", File.dirname(__FILE__))) end
def set_format(name)
-
(~Formatter)
-
Other tags:
- Example: Berkshelf.set_format :json -
Parameters:
-
format_id
(#to_sym
) --
def set_format(name) id = name.to_s.capitalize @formatter = Berkshelf.const_get("#{id}Formatter").new end
def ssl_policy
def ssl_policy @ssl_policy ||= SSLPolicy.new end
def ui
-
(Berkshelf::Shell)
-
def ui @ui ||= Berkshelf::Shell.new end
def which(executable)
-
(String, nil)
-
def which(executable) if File.file?(executable) && File.executable?(executable) executable elsif ENV["PATH"] path = ENV["PATH"].split(File::PATH_SEPARATOR).find do |p| File.executable?(File.join(p, executable)) end path && File.expand_path(executable, path) end end