Module: CookbookOmnifetch
- Defined in:
- lib/cookbook-omnifetch/threaded_job_queue.rb,
lib/cookbook-omnifetch.rb,
lib/cookbook-omnifetch/git.rb,
lib/cookbook-omnifetch/base.rb,
lib/cookbook-omnifetch/path.rb,
lib/cookbook-omnifetch/github.rb,
lib/cookbook-omnifetch/version.rb,
lib/cookbook-omnifetch/exceptions.rb,
lib/cookbook-omnifetch/artifactory.rb,
lib/cookbook-omnifetch/chef_server.rb,
lib/cookbook-omnifetch/integration.rb,
lib/cookbook-omnifetch/staging_area.rb,
lib/cookbook-omnifetch/artifactserver.rb,
lib/cookbook-omnifetch/chef_server_artifact.rb,
lib/cookbook-omnifetch/metadata_based_installer.rb
Overview
- Copyright
-
Copyright 2014-2016, Chef Software Inc.
- License
-
Apache License, Version 2.0
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Defined Under Namespace
Classes: AbstractFunction, ArtifactoryLocation, ArtifactserverLocation, BaseLocation, ChefServerArtifactLocation, ChefServerLocation, CookbookValidationFailure, GitCommandError, GitError, GitLocation, GitNotInstalled, GithubLocation, Integration, MetadataBasedInstaller, MismatchedCookbookName, MissingConfiguration, NotACookbook, NullValue, OmnifetchError, PathLocation, StagingArea, StagingAreaNotAvailable, ThreadedJobQueue
Constant Summary collapse
- VERSION =
"0.12.2".freeze
Class Method Summary collapse
-
.cache_path ⇒ String
Returns the filepath to the location where data will be cached.
-
.cached_cookbook_class ⇒ #from_path
Returns an Object (generally a class, but not required) that respsonds to #from_path and returns an object representing the cookbook.
-
.chef_server_download_concurrency ⇒ Object
Returns the number of threads that will be used when downloading cookbooks from a Chef Server.
-
.configure {|String| ... } ⇒ Object
Yields the Integration object which configures Dependency Injection classes for the library.
-
.cookbook?(path) ⇒ Boolean
Returns true or false if the given path contains a Chef Cookbook.
- .default_chef_server_http_client ⇒ Object
-
.init(dependency, options = {}) ⇒ ~BaseLocation?
Create a new instance of a Location class given dependency and options.
-
.integration ⇒ String
Returns the Integration object which configures Dependency Injection classes for the library.
-
.shell_out_class ⇒ #shell_out
Returns an Object (generally a class or module, but that’s not required) that responds to the #shell_out method to run an external command.
-
.storage_path ⇒ Pathname
Returns a pathname object representing the location where cookbooks are cached.
-
.which(executable) ⇒ String?
Location an executable in the current user’s $PATH.
Class Method Details
.cache_path ⇒ String
Returns the filepath to the location where data will be cached.
72 73 74 |
# File 'lib/cookbook-omnifetch.rb', line 72 def self.cache_path integration.cache_path end |
.cached_cookbook_class ⇒ #from_path
Returns an Object (generally a class, but not required) that respsonds to #from_path and returns an object representing the cookbook. In berkshelf, this would be a Berkshelf::CachedCookbook (inherits from Ridley::Chef::Cookbook). The object returned by ‘cached_cookbook_class.from_path(path)` is expected to respond to #version and #cookbook_name
96 97 98 |
# File 'lib/cookbook-omnifetch.rb', line 96 def self.cached_cookbook_class integration.cached_cookbook_class end |
.chef_server_download_concurrency ⇒ Object
Returns the number of threads that will be used when downloading cookbooks from a Chef Server. The default is 1.
NOTE: This should only be changed if the ‘http_client` passed in to a ChefServerLocation or ChefServerArtifactLocation is thread-safe. In particular, the `Chef::ServerAPI` class is NOT THREAD SAFE. Chef Client uses thread-local storage to create one instance of `Chef::ServerAPI` per-thread when used in threaded code.
When a properly thread-safe HTTP client is used, this can be configured to a larger value to reduce the time needed to download cookbooks from a Chef Server.
123 124 125 |
# File 'lib/cookbook-omnifetch.rb', line 123 def self.chef_server_download_concurrency integration.chef_server_download_concurrency end |
.configure {|String| ... } ⇒ Object
Yields the Integration object which configures Dependency Injection classes for the library.
66 67 68 |
# File 'lib/cookbook-omnifetch.rb', line 66 def self.configure yield integration end |
.cookbook?(path) ⇒ Boolean
Returns true or false if the given path contains a Chef Cookbook
137 138 139 |
# File 'lib/cookbook-omnifetch.rb', line 137 def self.cookbook?(path) File.exist?(File.join(path, "metadata.json")) || File.exist?(File.join(path, "metadata.rb")) end |
.default_chef_server_http_client ⇒ Object
127 128 129 |
# File 'lib/cookbook-omnifetch.rb', line 127 def self.default_chef_server_http_client integration.default_chef_server_http_client end |
.init(dependency, options = {}) ⇒ ~BaseLocation?
Create a new instance of a Location class given dependency and options. The type of class is determined by the values in the given options
Hash.
If you do not provide an option with a matching location id, nil
is returned.
32 33 34 35 36 37 38 |
# File 'lib/cookbook-omnifetch.rb', line 32 def self.init(dependency, = {}) if klass = () # rubocop: disable Lint/AssignmentInCondition klass.new(dependency, ) else nil end end |
.integration ⇒ String
Returns the Integration object which configures Dependency Injection classes for the library.
58 59 60 |
# File 'lib/cookbook-omnifetch.rb', line 58 def self.integration @integration ||= Integration.new end |
.shell_out_class ⇒ #shell_out
Returns an Object (generally a class or module, but that’s not required) that responds to the #shell_out method to run an external command. The shell_out method accepts a single string for the command to run, and returns an object that responds to #success?, #stdout and #stderr.
Note that this shell_out method should not raise errors automatically.
84 85 86 |
# File 'lib/cookbook-omnifetch.rb', line 84 def self.shell_out_class integration.shell_out_class end |
.storage_path ⇒ Pathname
Returns a pathname object representing the location where cookbooks are cached.
NOTE: In the original berks code, this is generally accessed via Berkshelf.cookbook_store.storage_path
107 108 109 |
# File 'lib/cookbook-omnifetch.rb', line 107 def self.storage_path integration.storage_path end |
.which(executable) ⇒ String?
Location an executable in the current user’s $PATH
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/cookbook-omnifetch.rb', line 44 def self.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 |