Module: Berkshelf
- Extended by:
- Mixin::Logging
- Defined in:
- lib/berkshelf.rb,
lib/berkshelf/ui.rb,
lib/berkshelf/cli.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/dependency.rb,
lib/berkshelf/downloader.rb,
lib/berkshelf/source_uri.rb,
lib/berkshelf/visualizer.rb,
lib/berkshelf/locations/git.rb,
lib/berkshelf/mixin/logging.rb,
lib/berkshelf/base_generator.rb,
lib/berkshelf/commands/shelf.rb,
lib/berkshelf/community_rest.rb,
lib/berkshelf/cookbook_store.rb,
lib/berkshelf/init_generator.rb,
lib/berkshelf/locations/base.rb,
lib/berkshelf/locations/path.rb,
lib/berkshelf/mixin/dsl_eval.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/cookbook_generator.rb,
lib/berkshelf/commands/test_command.rb
Defined Under Namespace
Modules: Mixin, UI Classes: AbstractFunction, ArgumentError, BaseFormatter, BaseGenerator, BaseLocation, Berksfile, BerksfileNotFound, BerksfileReadError, BerkshelfError, CachedCookbook, ChefConnectionError, Cli, CommunityREST, CommunitySiteError, Config, ConfigNotFound, ConstraintNotSatisfied, CookbookGenerator, CookbookNotFound, CookbookStore, CookbookSyntaxError, CookbookValidationFailure, Dependency, DependencyNotFound, DependencyNotInstalled, DeprecatedError, Downloader, DuplicateDemand, DuplicateDependencyDefined, EnvironmentNotFound, FrozenCookbook, GitLocation, GithubLocation, GraphvizCommandFailed, GraphvizNotInstalled, HumanFormatter, InitGenerator, Installer, InsufficientPrivledges, InternalError, InvalidConfiguration, InvalidCookbookFiles, InvalidSourceURI, JsonFormatter, LicenseNotFound, Location, Lockfile, LockfileNotFound, LockfileOutOfSync, LockfileParserError, Logger, MismatchedCookbookName, NoAPISourcesDefined, NoSolutionError, NotACookbook, NullFormatter, OutdatedDependency, PackageError, Packager, PathLocation, Resolver, Shelf, Source, SourceURI, TestCommand, UnknownCompressionType, UploadFailure, Uploader, VendorError, Visualizer
Constant Summary collapse
- DEFAULT_FILENAME =
'Berksfile'.freeze
- VERSION =
'3.1.0'
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 ⇒ Thor::Shell::Color, Thor::Shell::Basic
A basic shell on Windows, colored everywhere else.
Attributes included from Mixin::Logging
Class Method Summary collapse
-
.chef_config ⇒ Ridley::Chef::Config
The Chef configuration file.
- .chef_config=(config) ⇒ Object
-
.config ⇒ Berkshelf::Config
The Berkshelf configuration.
- .config=(config) ⇒ Object
- .cookbook_store ⇒ Berkshelf::CookbookStore
-
.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..
-
.mktmpdir ⇒ String
Creates a temporary directory within the Berkshelf path.
- .ridley_connection(options = {}, &block) ⇒ Object
- .root ⇒ Pathname
-
.set_format(name) ⇒ ~Formatter
Specify the format for output.
- .tmp_dir ⇒ String
-
.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’.
68 69 70 |
# File 'lib/berkshelf.rb', line 68 def berkshelf_path @berkshelf_path || ENV['BERKSHELF_PATH'] || File.('~/.berkshelf') end |
.ui ⇒ Thor::Shell::Color, Thor::Shell::Basic
Returns A basic shell on Windows, colored everywhere else.
57 58 59 |
# File 'lib/berkshelf.rb', line 57 def ui @ui end |
Class Method Details
.chef_config ⇒ Ridley::Chef::Config
The Chef configuration file.
87 88 89 |
# File 'lib/berkshelf.rb', line 87 def chef_config @chef_config ||= Ridley::Chef::Config.new(ENV['BERKSHELF_CHEF_CONFIG']) end |
.chef_config=(config) ⇒ Object
92 93 94 |
# File 'lib/berkshelf.rb', line 92 def chef_config=(config) @chef_config = config end |
.config ⇒ Berkshelf::Config
The Berkshelf configuration.
75 76 77 |
# File 'lib/berkshelf.rb', line 75 def config Berkshelf::Config.instance end |
.config=(config) ⇒ Object
80 81 82 |
# File 'lib/berkshelf.rb', line 80 def config=(config) Berkshelf::Config.set_config(config) end |
.cookbook_store ⇒ Berkshelf::CookbookStore
120 121 122 |
# File 'lib/berkshelf.rb', line 120 def cookbook_store CookbookStore.instance end |
.formatter ⇒ ~Formatter
Get the appropriate Formatter object based on the formatter classes that have been registered.
128 129 130 |
# File 'lib/berkshelf.rb', line 128 def formatter @formatter ||= HumanFormatter.new end |
.initialize_filesystem ⇒ Object
Initialize the filepath for the Berkshelf path..
97 98 99 100 101 102 103 |
# File 'lib/berkshelf.rb', line 97 def initialize_filesystem FileUtils.mkdir_p(berkshelf_path, mode: 0755) unless File.writable?(berkshelf_path) raise InsufficientPrivledges.new(berkshelf_path) end end |
.mktmpdir ⇒ String
Creates a temporary directory within the Berkshelf path
114 115 116 117 |
# File 'lib/berkshelf.rb', line 114 def mktmpdir FileUtils.mkdir_p(tmp_dir) Dir.mktmpdir(nil, tmp_dir) end |
.ridley_connection(options = {}, &block) ⇒ Object
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/berkshelf.rb', line 133 def ridley_connection( = {}, &block) = .slice(: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] = { verify: ([:ssl_verify].nil?) ? Berkshelf.config.ssl.verify : [:ssl_verify]} unless [:server_url].present? raise ChefConnectionError, 'Missing required attribute in your Berkshelf configuration: chef.server_url' end unless [:client_name].present? raise ChefConnectionError, 'Missing required attribute in your Berkshelf configuration: chef.node_name' end unless [:client_key].present? 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(, &block) rescue Ridley::Errors::RidleyError => ex log.exception(ex) raise ChefConnectionError, ex # todo implement end |
.root ⇒ Pathname
51 52 53 |
# File 'lib/berkshelf.rb', line 51 def root @root ||= Pathname.new(File.('../', File.dirname(__FILE__))) end |
.set_format(name) ⇒ ~Formatter
Specify the format for output
170 171 172 173 |
# File 'lib/berkshelf.rb', line 170 def set_format(name) id = name.to_s.capitalize @formatter = Berkshelf.const_get("#{id}Formatter").new end |
.tmp_dir ⇒ String
106 107 108 |
# File 'lib/berkshelf.rb', line 106 def tmp_dir File.join(berkshelf_path, 'tmp') end |
.which(executable) ⇒ String?
Location an executable in the current user’s $PATH
179 180 181 182 183 184 185 186 187 188 |
# File 'lib/berkshelf.rb', line 179 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 |