Module: Berkshelf
- Extended by:
- Mixin::Logging
- Defined in:
- lib/berkshelf.rb,
lib/berkshelf/cli.rb,
lib/berkshelf/shell.rb,
lib/berkshelf/config.rb,
lib/berkshelf/errors.rb,
lib/berkshelf/logger.rb,
lib/berkshelf/source.rb,
lib/berkshelf/version.rb,
lib/berkshelf/location.rb,
lib/berkshelf/lockfile.rb,
lib/berkshelf/packager.rb,
lib/berkshelf/resolver.rb,
lib/berkshelf/uploader.rb,
lib/berkshelf/berksfile.rb,
lib/berkshelf/installer.rb,
lib/berkshelf/mixin/git.rb,
lib/berkshelf/shell_out.rb,
lib/berkshelf/validator.rb,
lib/berkshelf/api_client.rb,
lib/berkshelf/dependency.rb,
lib/berkshelf/downloader.rb,
lib/berkshelf/source_uri.rb,
lib/berkshelf/visualizer.rb,
lib/berkshelf/file_syncer.rb,
lib/berkshelf/ssl_policies.rb,
lib/berkshelf/locations/git.rb,
lib/berkshelf/mixin/logging.rb,
lib/berkshelf/ridley_compat.rb,
lib/berkshelf/commands/shelf.rb,
lib/berkshelf/community_rest.rb,
lib/berkshelf/cookbook_store.rb,
lib/berkshelf/locations/base.rb,
lib/berkshelf/locations/path.rb,
lib/berkshelf/resolver/graph.rb,
lib/berkshelf/cached_cookbook.rb,
lib/berkshelf/formatters/base.rb,
lib/berkshelf/formatters/json.rb,
lib/berkshelf/formatters/null.rb,
lib/berkshelf/formatters/human.rb,
lib/berkshelf/locations/github.rb,
lib/berkshelf/api_client/errors.rb,
lib/berkshelf/api_client/version.rb,
lib/berkshelf/chef_config_compat.rb,
lib/berkshelf/chef_repo_universe.rb,
lib/berkshelf/api_client/connection.rb,
lib/berkshelf/api_client/remote_cookbook.rb,
lib/berkshelf/api_client/chef_server_connection.rb
Defined Under Namespace
Modules: APIClient, FileSyncer, Mixin, RidleyCompatAPI, ShellOut, Validator Classes: APIClientError, AbstractFunction, ArgumentError, BaseFormatter, BaseLocation, Berksfile, BerksfileNotFound, BerksfileReadError, BerkshelfError, CachedCookbook, ChefConfigCompat, ChefConnectionError, ChefRepoUniverse, Cli, CommunityREST, CommunitySiteError, Config, ConfigNotFound, ConfigurationError, ConstraintNotSatisfied, CookbookNotFound, CookbookStore, CookbookSyntaxError, CookbookValidationFailure, Dependency, DependencyNotFound, DependencyNotInstalled, DeprecatedError, Downloader, DuplicateDemand, DuplicateDependencyDefined, EnvironmentFileNotFound, EnvironmentNotFound, FrozenCookbook, GitCommandError, GitError, GitLocation, GitNotInstalled, GithubLocation, GraphvizCommandFailed, GraphvizNotInstalled, HumanFormatter, Installer, InsufficientPrivledges, InternalError, InvalidConfiguration, InvalidCookbookFiles, InvalidSourceURI, JsonFormatter, LicenseNotFound, Location, Lockfile, LockfileNotFound, LockfileOutOfSync, LockfileParserError, Logger, MismatchedCookbookName, MissingLockfileCookbookVersion, NoAPISourcesDefined, NoSolutionError, NotACookbook, NullFormatter, OutdatedDependency, PackageError, Packager, PathLocation, RedirectLimitReached, Resolver, RidleyCompat, RidleyCompatJSON, RidleyCompatSimple, SSLPolicy, Shelf, Source, SourceURI, UnknownCompressionType, UploadFailure, Uploader, Visualizer
Constant Summary collapse
- DEFAULT_FILENAME =
"Berksfile".freeze
- Shell =
Subclass the current shell (which is different based on the OS)
Class.new(Thor::Base.shell) do # Mute the output of this instance of UI until {#unmute!} is called def mute! @mute = true end # Unmute the output of this instance of UI until {#mute!} is called def unmute! @mute = false end def say(*args) return if quiet? super(*args) end alias_method :info, :say def warn(, color = :yellow) say(, color) end def error(, color = :red) = set_color(, *color) if color super() end end
- VERSION =
"8.0.15".freeze
Class Attribute Summary collapse
-
.berkshelf_path ⇒ String
Returns the filepath to the location Berkshelf will use for storage; temp files will go here, Cookbooks will be downloaded to or uploaded from here.
- .ui ⇒ Berkshelf::Shell
Attributes included from Mixin::Logging
Class Method Summary collapse
-
.chef_config ⇒ Berkshelf::ChefConfigCompat
The Chef configuration file.
- .chef_config=(config) ⇒ Object
-
.config ⇒ Berkshelf::Config
The Berkshelf configuration.
- .config=(config) ⇒ Object
- .cookbook_store ⇒ Berkshelf::CookbookStore
- .fix_proxies ⇒ Object
-
.formatter ⇒ ~Formatter
Get the appropriate Formatter object based on the formatter classes that have been registered.
-
.initialize_filesystem ⇒ Object
Initialize the filepath for the Berkshelf path..
- .ridley_connection(options = {}, &block) ⇒ Object
- .root ⇒ Pathname
-
.set_format(name) ⇒ ~Formatter
Specify the format for output.
- .ssl_policy ⇒ Object
-
.which(executable) ⇒ String?
Location an executable in the current user’s $PATH.
Class Attribute Details
.berkshelf_path ⇒ String
Returns the filepath to the location Berkshelf will use for storage; temp files will go here, Cookbooks will be downloaded to or uploaded from here. By default this is ‘~/.berkshelf’ but can be overridden by specifying a value for the ENV variable ‘BERKSHELF_PATH’.
89 90 91 |
# File 'lib/berkshelf.rb', line 89 def berkshelf_path @berkshelf_path ||= File.(ENV["BERKSHELF_PATH"] || "~/.berkshelf") end |
.ui ⇒ Berkshelf::Shell
78 79 80 |
# File 'lib/berkshelf.rb', line 78 def ui @ui ||= Berkshelf::Shell.new end |
Class Method Details
.chef_config ⇒ Berkshelf::ChefConfigCompat
The Chef configuration file.
108 109 110 |
# File 'lib/berkshelf.rb', line 108 def chef_config @chef_config ||= Berkshelf::ChefConfigCompat.new(ENV["BERKSHELF_CHEF_CONFIG"]) end |
.chef_config=(config) ⇒ Object
113 114 115 |
# File 'lib/berkshelf.rb', line 113 def chef_config=(config) @chef_config = config end |
.config ⇒ Berkshelf::Config
The Berkshelf configuration.
96 97 98 |
# File 'lib/berkshelf.rb', line 96 def config Berkshelf::Config.instance end |
.config=(config) ⇒ Object
101 102 103 |
# File 'lib/berkshelf.rb', line 101 def config=(config) Berkshelf::Config.set_config(config) end |
.cookbook_store ⇒ Berkshelf::CookbookStore
127 128 129 |
# File 'lib/berkshelf.rb', line 127 def cookbook_store CookbookStore.instance end |
.fix_proxies ⇒ Object
31 32 33 34 35 36 |
# File 'lib/berkshelf.rb', line 31 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 |
.formatter ⇒ ~Formatter
Get the appropriate Formatter object based on the formatter classes that have been registered.
135 136 137 |
# File 'lib/berkshelf.rb', line 135 def formatter @formatter ||= HumanFormatter.new end |
.initialize_filesystem ⇒ Object
Initialize the filepath for the Berkshelf path..
118 119 120 121 122 123 124 |
# File 'lib/berkshelf.rb', line 118 def initialize_filesystem FileUtils.mkdir_p(berkshelf_path, mode: 0755) unless File.writable?(berkshelf_path) raise InsufficientPrivledges.new(berkshelf_path) end end |
.ridley_connection(options = {}, &block) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
# File 'lib/berkshelf.rb', line 144 def ridley_connection( = {}, &block) = {} [:verify] = if [:ssl_verify].nil? Berkshelf.config.ssl.verify else [:ssl_verify] end [:cert_store] = ssl_policy.store if ssl_policy.store = {} [:ssl] = [:ssl] if .key?(:ssl) [:server_url] = [:server_url] || Berkshelf.config.chef.chef_server_url [:client_name] = [:client_name] || Berkshelf.config.chef.node_name [:client_key] = [:client_key] || Berkshelf.config.chef.client_key [:ssl] = if ![:server_url] || [:server_url] =~ /^\s*$/ raise ChefConnectionError, "Missing required attribute in your Berkshelf configuration: chef.server_url" end if ![:client_name] || [:client_name] =~ /^\s*$/ raise ChefConnectionError, "Missing required attribute in your Berkshelf configuration: chef.node_name" end if ![:client_key] || [:client_key].to_s =~ /^\s*$/ raise ChefConnectionError, "Missing required attribute in your Berkshelf configuration: chef.client_key" end RidleyCompat.new_client(**, &block) rescue ChefConnectionError, BerkshelfError raise rescue => ex log.exception(ex) raise ChefConnectionError, ex # todo implement end |
.root ⇒ Pathname
73 74 75 |
# File 'lib/berkshelf.rb', line 73 def root @root ||= Pathname.new(File.("../", File.dirname(__FILE__))) end |
.set_format(name) ⇒ ~Formatter
Specify the format for output
188 189 190 191 |
# File 'lib/berkshelf.rb', line 188 def set_format(name) id = name.to_s.capitalize @formatter = Berkshelf.const_get("#{id}Formatter").new end |
.ssl_policy ⇒ Object
139 140 141 |
# File 'lib/berkshelf.rb', line 139 def ssl_policy @ssl_policy ||= SSLPolicy.new end |
.which(executable) ⇒ String?
Location an executable in the current user’s $PATH
197 198 199 200 201 202 203 204 205 206 |
# File 'lib/berkshelf.rb', line 197 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.(executable, path) end end |