berkshelf 7.0.7 → 7.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -3
- data/Rakefile +4 -4
- data/berkshelf.gemspec +10 -12
- data/bin/berks +5 -0
- data/lib/berkshelf.rb +8 -9
- data/lib/berkshelf/api_client/chef_server_connection.rb +3 -2
- data/lib/berkshelf/api_client/connection.rb +1 -1
- data/lib/berkshelf/api_client/remote_cookbook.rb +1 -1
- data/lib/berkshelf/berksfile.rb +41 -39
- data/lib/berkshelf/cached_cookbook.rb +6 -4
- data/lib/berkshelf/chef_config_compat.rb +2 -1
- data/lib/berkshelf/chef_repo_universe.rb +6 -4
- data/lib/berkshelf/cli.rb +6 -6
- data/lib/berkshelf/commands/shelf.rb +1 -1
- data/lib/berkshelf/community_rest.rb +6 -6
- data/lib/berkshelf/config.rb +3 -3
- data/lib/berkshelf/cookbook_store.rb +2 -4
- data/lib/berkshelf/core_ext.rb +1 -1
- data/lib/berkshelf/core_ext/file_utils.rb +3 -3
- data/lib/berkshelf/dependency.rb +1 -1
- data/lib/berkshelf/downloader.rb +9 -6
- data/lib/berkshelf/errors.rb +5 -2
- data/lib/berkshelf/file_syncer.rb +7 -12
- data/lib/berkshelf/formatters/human.rb +1 -1
- data/lib/berkshelf/formatters/json.rb +4 -4
- data/lib/berkshelf/installer.rb +1 -1
- data/lib/berkshelf/location.rb +3 -3
- data/lib/berkshelf/locations/git.rb +6 -12
- data/lib/berkshelf/lockfile.rb +14 -14
- data/lib/berkshelf/logger.rb +4 -2
- data/lib/berkshelf/mixin/git.rb +3 -3
- data/lib/berkshelf/packager.rb +5 -7
- data/lib/berkshelf/resolver.rb +1 -1
- data/lib/berkshelf/ridley_compat.rb +1 -1
- data/lib/berkshelf/shell.rb +2 -1
- data/lib/berkshelf/shell_out.rb +4 -3
- data/lib/berkshelf/source.rb +8 -7
- data/lib/berkshelf/source_uri.rb +1 -1
- data/lib/berkshelf/ssl_policies.rb +5 -9
- data/lib/berkshelf/thor.rb +1 -1
- data/lib/berkshelf/thor_ext.rb +1 -1
- data/lib/berkshelf/uploader.rb +11 -9
- data/lib/berkshelf/validator.rb +2 -8
- data/lib/berkshelf/version.rb +1 -1
- data/lib/berkshelf/visualizer.rb +3 -3
- data/spec/config/knife.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/support/chef_server.rb +2 -2
- data/spec/support/git.rb +18 -18
- data/spec/support/path_helpers.rb +4 -4
- data/spec/unit/berkshelf/berksfile_spec.rb +7 -7
- data/spec/unit/berkshelf/cli_spec.rb +1 -2
- data/spec/unit/berkshelf/community_rest_spec.rb +1 -1
- data/spec/unit/berkshelf/core_ext/file_utils_spec.rb +2 -2
- data/spec/unit/berkshelf/dependency_spec.rb +5 -5
- data/spec/unit/berkshelf/downloader_spec.rb +4 -8
- data/spec/unit/berkshelf/locations/base_spec.rb +1 -2
- data/spec/unit/berkshelf/locations/git_spec.rb +2 -5
- data/spec/unit/berkshelf/locations/path_spec.rb +1 -2
- data/spec/unit/berkshelf/lockfile_spec.rb +9 -18
- data/spec/unit/berkshelf/ridley_compat_spec.rb +2 -2
- data/spec/unit/berkshelf/source_spec.rb +30 -19
- data/spec/unit/berkshelf/ssl_policies_spec.rb +3 -6
- data/spec/unit/berkshelf/uploader_spec.rb +6 -10
- data/spec/unit/berkshelf/validator_spec.rb +0 -13
- metadata +39 -193
- data/.github/lock.yml +0 -1
- data/.gitignore +0 -30
- data/.rubocop.yml +0 -12
- data/.travis.yml +0 -73
- data/CHANGELOG.legacy.md +0 -307
- data/CHANGELOG.md +0 -1589
- data/CONTRIBUTING.md +0 -68
- data/Gemfile.lock +0 -292
- data/PLUGINS.md +0 -25
- data/README.md +0 -72
- data/Thorfile +0 -61
- data/appveyor.yml +0 -31
- data/docs/berkshelf_for_newcomers.md +0 -64
- data/features/artifactory.feature +0 -70
- data/features/berksfile.feature +0 -46
- data/features/commands/apply.feature +0 -41
- data/features/commands/contingent.feature +0 -47
- data/features/commands/info.feature +0 -141
- data/features/commands/install.feature +0 -646
- data/features/commands/list.feature +0 -78
- data/features/commands/outdated.feature +0 -176
- data/features/commands/package.feature +0 -17
- data/features/commands/search.feature +0 -17
- data/features/commands/shelf/list.feature +0 -32
- data/features/commands/shelf/show.feature +0 -113
- data/features/commands/shelf/uninstall.feature +0 -96
- data/features/commands/show.feature +0 -83
- data/features/commands/update.feature +0 -142
- data/features/commands/upload.feature +0 -499
- data/features/commands/vendor.feature +0 -154
- data/features/commands/verify.feature +0 -29
- data/features/commands/viz.feature +0 -66
- data/features/community_site.feature +0 -37
- data/features/help.feature +0 -11
- data/features/json_formatter.feature +0 -158
- data/features/lifecycle.feature +0 -378
- data/features/lockfile.feature +0 -378
- data/features/step_definitions/berksfile_steps.rb +0 -54
- data/features/step_definitions/chef/config_steps.rb +0 -12
- data/features/step_definitions/chef_server_steps.rb +0 -60
- data/features/step_definitions/cli_steps.rb +0 -18
- data/features/step_definitions/config_steps.rb +0 -46
- data/features/step_definitions/environment_steps.rb +0 -11
- data/features/step_definitions/filesystem_steps.rb +0 -286
- data/features/step_definitions/gem_steps.rb +0 -13
- data/features/step_definitions/json_steps.rb +0 -29
- data/features/step_definitions/utility_steps.rb +0 -11
- data/features/support/aruba.rb +0 -12
- data/features/support/env.rb +0 -77
- data/spec/fixtures/cookbooks/example_cookbook/.gitignore +0 -2
- data/spec/fixtures/cookbooks/example_cookbook/.kitchen.yml +0 -26
@@ -1,5 +1,5 @@
|
|
1
|
-
require "retryable"
|
2
|
-
require "mixlib/archive"
|
1
|
+
require "retryable" unless defined?(Retryable)
|
2
|
+
require "mixlib/archive" unless defined?(Mixlib::Archive)
|
3
3
|
|
4
4
|
module Berkshelf
|
5
5
|
class CommunityREST
|
@@ -69,13 +69,13 @@ module Berkshelf
|
|
69
69
|
# how often we should pause between retries
|
70
70
|
def initialize(uri = V1_API, options = {})
|
71
71
|
options = options.dup
|
72
|
-
options
|
73
|
-
@api_uri
|
72
|
+
options = { retries: 5, retry_interval: 0.5, ssl: Berkshelf::Config.instance.ssl }.merge(options)
|
73
|
+
@api_uri = uri
|
74
74
|
options[:server_url] = uri
|
75
|
-
@retries
|
75
|
+
@retries = options.delete(:retries)
|
76
76
|
@retry_interval = options.delete(:retry_interval)
|
77
77
|
|
78
|
-
@connection = Berkshelf::RidleyCompatJSON.new(options)
|
78
|
+
@connection = Berkshelf::RidleyCompatJSON.new(**options)
|
79
79
|
end
|
80
80
|
|
81
81
|
# Download and extract target cookbook archive to the local file system,
|
data/lib/berkshelf/config.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require "mixlib/config"
|
2
|
-
require "openssl"
|
1
|
+
require "mixlib/config" unless defined?(Mixlib::Config)
|
2
|
+
require "openssl" unless defined?(OpenSSL)
|
3
3
|
|
4
4
|
# we need this method, but have to inject it into mixlib-config directly
|
5
5
|
# to have it available from config contexts
|
@@ -122,7 +122,7 @@ module Berkshelf
|
|
122
122
|
default :email, nil
|
123
123
|
default :license, nil
|
124
124
|
end
|
125
|
-
default :allowed_licenses,
|
125
|
+
default :allowed_licenses, []
|
126
126
|
default :raise_license_exception, false
|
127
127
|
config_context :vagrant do
|
128
128
|
config_context :vm do
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require "fileutils"
|
1
|
+
require "fileutils" unless defined?(FileUtils)
|
2
2
|
require "chef/exceptions"
|
3
3
|
|
4
4
|
module Berkshelf
|
@@ -49,9 +49,7 @@ module Berkshelf
|
|
49
49
|
|
50
50
|
# Destroy the contents of the initialized storage path.
|
51
51
|
def clean!
|
52
|
-
Dir.
|
53
|
-
FileUtils.rm_rf(Dir.glob("*"))
|
54
|
-
end
|
52
|
+
FileUtils.rm_rf(Dir.glob("#{storage_path}/*"))
|
55
53
|
end
|
56
54
|
|
57
55
|
# Import a cookbook found on the local filesystem into this instance of the cookbook store.
|
data/lib/berkshelf/core_ext.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require "fileutils"
|
1
|
+
require "fileutils" unless defined?(FileUtils)
|
2
2
|
|
3
3
|
module FileUtils
|
4
4
|
class << self
|
@@ -14,10 +14,10 @@ module FileUtils
|
|
14
14
|
# symlink on Linux
|
15
15
|
# @see {FileUtils::mv}
|
16
16
|
def mv(src, dest, options = {})
|
17
|
-
old_mv(src, dest, options)
|
17
|
+
old_mv(src, dest, **options)
|
18
18
|
rescue Errno::EACCES, Errno::ENOENT
|
19
19
|
options.delete(:force) if options.key?(:force)
|
20
|
-
FileUtils.cp_r(src, dest, options)
|
20
|
+
FileUtils.cp_r(src, dest, **options)
|
21
21
|
FileUtils.rm_rf(src)
|
22
22
|
end
|
23
23
|
end
|
data/lib/berkshelf/dependency.rb
CHANGED
data/lib/berkshelf/downloader.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
require "net/http"
|
2
|
-
require "mixlib/archive"
|
3
|
-
|
1
|
+
require "net/http" unless defined?(Net::HTTP)
|
2
|
+
require "mixlib/archive" unless defined?(Mixlib::Archive)
|
3
|
+
require_relative "ssl_policies"
|
4
|
+
require "faraday" unless defined?(Faraday)
|
4
5
|
|
5
6
|
module Berkshelf
|
6
7
|
class Downloader
|
@@ -83,7 +84,7 @@ module Berkshelf
|
|
83
84
|
client_key: source.options[:client_key] || Berkshelf::Config.instance.chef.client_key,
|
84
85
|
ssl: source.options[:ssl],
|
85
86
|
}
|
86
|
-
RidleyCompat.new_client(credentials) do |conn|
|
87
|
+
RidleyCompat.new_client(**credentials) do |conn|
|
87
88
|
cookbook = Chef::CookbookVersion.load(name, version)
|
88
89
|
manifest = cookbook.cookbook_manifest
|
89
90
|
manifest.by_parent_directory.each do |segment, files|
|
@@ -120,7 +121,7 @@ module Berkshelf
|
|
120
121
|
)
|
121
122
|
|
122
123
|
begin
|
123
|
-
url = URI(github_client.archive_link(cookbook_uri.path.gsub(
|
124
|
+
url = URI(github_client.archive_link(cookbook_uri.path.gsub(%r{^/}, ""), ref: "v#{version}"))
|
124
125
|
rescue Octokit::Unauthorized
|
125
126
|
return nil
|
126
127
|
end
|
@@ -131,6 +132,7 @@ module Berkshelf
|
|
131
132
|
http.verify_mode = (options["ssl_verify"].nil? || options["ssl_verify"]) ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
|
132
133
|
resp = http.get(url.request_uri)
|
133
134
|
return nil unless resp.is_a?(Net::HTTPSuccess)
|
135
|
+
|
134
136
|
open(archive_path, "wb") { |file| file.write(resp.body) }
|
135
137
|
|
136
138
|
Mixlib::Archive.new(archive_path).extract(unpack_dir)
|
@@ -143,7 +145,7 @@ module Berkshelf
|
|
143
145
|
|
144
146
|
File.join(unpack_dir, cookbook_directory)
|
145
147
|
when :uri
|
146
|
-
require "open-uri"
|
148
|
+
require "open-uri" unless defined?(OpenURI)
|
147
149
|
|
148
150
|
tmp_dir = Dir.mktmpdir
|
149
151
|
archive_path = Pathname.new(tmp_dir) + "#{name}-#{version}.tar.gz"
|
@@ -183,6 +185,7 @@ module Berkshelf
|
|
183
185
|
|
184
186
|
resp = connection.get(cookbook_uri.request_uri + "&private_token=" + options["private_token"])
|
185
187
|
return nil unless resp.status == 200
|
188
|
+
|
186
189
|
open(archive_path, "wb") { |file| file.write(resp.body) }
|
187
190
|
|
188
191
|
Mixlib::Archive.new(archive_path).extract(unpack_dir)
|
data/lib/berkshelf/errors.rb
CHANGED
@@ -83,7 +83,7 @@ module Berkshelf
|
|
83
83
|
|
84
84
|
def to_s
|
85
85
|
@original_exception.to_s +
|
86
|
-
"Unable to find a solution for demands: #{demands.join(
|
86
|
+
"Unable to find a solution for demands: #{demands.join(", ")}"
|
87
87
|
end
|
88
88
|
|
89
89
|
alias_method :message, :to_s
|
@@ -91,6 +91,7 @@ module Berkshelf
|
|
91
91
|
|
92
92
|
class CookbookSyntaxError < BerkshelfError; set_status_code(107); end
|
93
93
|
class ConstraintNotSatisfied < BerkshelfError; set_status_code(111); end
|
94
|
+
|
94
95
|
class BerksfileReadError < BerkshelfError
|
95
96
|
set_status_code(113)
|
96
97
|
|
@@ -254,6 +255,7 @@ module Berkshelf
|
|
254
255
|
end
|
255
256
|
|
256
257
|
class UploadFailure < BerkshelfError; end
|
258
|
+
|
257
259
|
class FrozenCookbook < UploadFailure
|
258
260
|
set_status_code(126)
|
259
261
|
|
@@ -372,7 +374,7 @@ module Berkshelf
|
|
372
374
|
|
373
375
|
def to_s
|
374
376
|
"Unknown license: '#{license}'\n" +
|
375
|
-
"Available licenses: #{CookbookGenerator::LICENSES.join(
|
377
|
+
"Available licenses: #{CookbookGenerator::LICENSES.join(", ")}"
|
376
378
|
end
|
377
379
|
|
378
380
|
alias_method :message, :to_s
|
@@ -436,6 +438,7 @@ module Berkshelf
|
|
436
438
|
end
|
437
439
|
|
438
440
|
class DuplicateDemand < BerkshelfError; set_status_code(138); end
|
441
|
+
|
439
442
|
class LockfileNotFound < BerkshelfError
|
440
443
|
set_status_code(140)
|
441
444
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require "fileutils"
|
1
|
+
require "fileutils" unless defined?(FileUtils)
|
2
2
|
|
3
3
|
module Berkshelf
|
4
4
|
module FileSyncer
|
@@ -24,8 +24,8 @@ module Berkshelf
|
|
24
24
|
# versions of windows points at 'C:\users'. Some users have their
|
25
25
|
# temp directory still referring to 'C:\Documents and Settings'.
|
26
26
|
#
|
27
|
-
def glob(pattern)
|
28
|
-
Dir.glob(pattern, File::FNM_DOTMATCH).sort.reject do |file|
|
27
|
+
def glob(pattern, **kwargs)
|
28
|
+
Dir.glob(pattern, File::FNM_DOTMATCH, **kwargs).sort.reject do |file|
|
29
29
|
basename = File.basename(file)
|
30
30
|
IGNORED_FILES.include?(basename)
|
31
31
|
end
|
@@ -65,11 +65,10 @@ module Berkshelf
|
|
65
65
|
[exclude, "#{exclude}/*"]
|
66
66
|
end.flatten
|
67
67
|
|
68
|
-
source_files =
|
69
|
-
glob("**/*").reject do |source_file|
|
68
|
+
source_files =
|
69
|
+
glob("**/*", base: source).reject do |source_file|
|
70
70
|
excludes.any? { |exclude| File.fnmatch?(exclude, source_file, File::FNM_DOTMATCH) }
|
71
71
|
end
|
72
|
-
end
|
73
72
|
|
74
73
|
# Ensure the destination directory exists
|
75
74
|
FileUtils.mkdir_p(destination) unless File.directory?(destination)
|
@@ -88,9 +87,7 @@ module Berkshelf
|
|
88
87
|
target = File.readlink(source_file)
|
89
88
|
|
90
89
|
destination = File.expand_path(destination)
|
91
|
-
|
92
|
-
FileUtils.ln_sf(target, "#{destination}/#{relative_path}")
|
93
|
-
end
|
90
|
+
FileUtils.ln_sf(target, "#{destination}/#{relative_path}")
|
94
91
|
when :file
|
95
92
|
FileUtils.cp(source_file, "#{destination}/#{relative_path}")
|
96
93
|
else
|
@@ -103,9 +100,7 @@ module Berkshelf
|
|
103
100
|
|
104
101
|
if options[:delete]
|
105
102
|
# Remove any files in the destination that are not in the source files
|
106
|
-
destination_files =
|
107
|
-
glob("**/*")
|
108
|
-
end
|
103
|
+
destination_files = glob("**/*", base: destination)
|
109
104
|
|
110
105
|
# Remove any extra files that are present in the destination, but are
|
111
106
|
# not in the source list
|
@@ -68,7 +68,7 @@ module Berkshelf
|
|
68
68
|
|
69
69
|
hash.each do |name, info|
|
70
70
|
info["remote"].each do |remote_source, remote_version|
|
71
|
-
out = " * #{name} (#{info[
|
71
|
+
out = " * #{name} (#{info["local"]} => #{remote_version})"
|
72
72
|
|
73
73
|
unless remote_source.default?
|
74
74
|
out << " [#{remote_source.uri}]"
|
@@ -8,11 +8,11 @@ module Berkshelf
|
|
8
8
|
def initialize
|
9
9
|
@output = {
|
10
10
|
cookbooks: [],
|
11
|
-
errors:
|
12
|
-
messages:
|
13
|
-
warnings:
|
11
|
+
errors: [],
|
12
|
+
messages: [],
|
13
|
+
warnings: [],
|
14
14
|
}
|
15
|
-
@cookbooks =
|
15
|
+
@cookbooks = {}
|
16
16
|
|
17
17
|
Berkshelf.ui.mute { super }
|
18
18
|
end
|
data/lib/berkshelf/installer.rb
CHANGED
data/lib/berkshelf/location.rb
CHANGED
@@ -28,9 +28,9 @@ module Berkshelf
|
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
# Load the correct location from the given options.
|
32
|
+
#
|
33
|
+
# @return [Class, nil]
|
34
34
|
def klass_from_options(options)
|
35
35
|
options.each do |key, _|
|
36
36
|
id = key.to_s.capitalize
|
@@ -37,28 +37,22 @@ module Berkshelf
|
|
37
37
|
scratch_path = Pathname.new(Dir.mktmpdir)
|
38
38
|
|
39
39
|
if cached?
|
40
|
-
|
41
|
-
git %{fetch --force --tags #{uri} "refs/heads/*:refs/heads/*"}
|
42
|
-
end
|
40
|
+
git(%{fetch --force --tags #{uri} "refs/heads/*:refs/heads/*"}, cwd: cache_path.to_s)
|
43
41
|
else
|
44
42
|
git %{clone #{uri} "#{cache_path}" --bare --no-hardlinks}
|
45
43
|
end
|
46
44
|
|
47
|
-
|
48
|
-
@revision ||= git %{rev-parse #{@rev_parse}}
|
49
|
-
end
|
45
|
+
@revision ||= git(%{rev-parse #{@rev_parse}}, cwd: cache_path.to_s)
|
50
46
|
|
51
47
|
# Clone into a scratch directory for validations
|
52
48
|
git %{clone --no-checkout "#{cache_path}" "#{scratch_path}"}
|
53
49
|
|
54
50
|
# Make sure the scratch directory is up-to-date and account for rel paths
|
55
|
-
|
56
|
-
|
57
|
-
git %{reset --hard #{@revision}}
|
51
|
+
git(%{fetch --force --tags "#{cache_path}"}, cwd: scratch_path.to_s)
|
52
|
+
git(%{reset --hard #{@revision}}, cwd: scratch_path.to_s)
|
58
53
|
|
59
|
-
|
60
|
-
|
61
|
-
end
|
54
|
+
if rel
|
55
|
+
git(%{filter-branch --subdirectory-filter "#{rel}" --force}, cwd: scratch_path.to_s)
|
62
56
|
end
|
63
57
|
|
64
58
|
# Validate the scratched path is a valid cookbook
|
data/lib/berkshelf/lockfile.rb
CHANGED
@@ -228,7 +228,7 @@ module Berkshelf
|
|
228
228
|
|
229
229
|
# @return [Array<CachedCookbook>]
|
230
230
|
def cached
|
231
|
-
graph.locks.values.collect
|
231
|
+
graph.locks.values.collect(&:cached_cookbook)
|
232
232
|
end
|
233
233
|
|
234
234
|
# The list of dependencies constrained in this lockfile.
|
@@ -511,13 +511,13 @@ module Berkshelf
|
|
511
511
|
"#<Berkshelf::Lockfile #{Pathname.new(filepath).basename}, dependencies: #{dependencies.inspect}>"
|
512
512
|
end
|
513
513
|
|
514
|
-
|
515
|
-
|
514
|
+
# The class responsible for parsing the lockfile and turning it into a
|
515
|
+
# useful data structure.
|
516
516
|
class LockfileParser
|
517
517
|
NAME_VERSION = '(?! )(.*?)(?: \(([^-]*)(?:-(.*))?\))?'.freeze
|
518
|
-
DEPENDENCY_PATTERN = /^ {2}#{NAME_VERSION}
|
519
|
-
DEPENDENCIES_PATTERN = /^ {4}#{NAME_VERSION}
|
520
|
-
OPTION_PATTERN = /^ {4}(.+)\: (.+)
|
518
|
+
DEPENDENCY_PATTERN = /^ {2}#{NAME_VERSION}$/.freeze
|
519
|
+
DEPENDENCIES_PATTERN = /^ {4}#{NAME_VERSION}$/.freeze
|
520
|
+
OPTION_PATTERN = /^ {4}(.+)\: (.+)/.freeze
|
521
521
|
|
522
522
|
# Create a new lockfile parser.
|
523
523
|
#
|
@@ -570,7 +570,7 @@ module Berkshelf
|
|
570
570
|
end
|
571
571
|
end
|
572
572
|
|
573
|
-
graph << " #{name} (#{info[
|
573
|
+
graph << " #{name} (#{info["locked_version"]})\n"
|
574
574
|
end
|
575
575
|
|
576
576
|
contents = "#{dependencies}\n#{graph}"
|
@@ -599,9 +599,9 @@ module Berkshelf
|
|
599
599
|
|
600
600
|
private
|
601
601
|
|
602
|
-
|
603
|
-
|
604
|
-
|
602
|
+
# Parse a dependency line.
|
603
|
+
#
|
604
|
+
# @param [String] line
|
605
605
|
def parse_dependency(line)
|
606
606
|
if line =~ DEPENDENCY_PATTERN
|
607
607
|
name, version = $1, $2
|
@@ -615,9 +615,9 @@ module Berkshelf
|
|
615
615
|
end
|
616
616
|
end
|
617
617
|
|
618
|
-
|
619
|
-
|
620
|
-
|
618
|
+
# Parse a graph line.
|
619
|
+
#
|
620
|
+
# @param [String] line
|
621
621
|
def parse_graph(line)
|
622
622
|
if line =~ DEPENDENCY_PATTERN
|
623
623
|
name, version = $1, $2
|
@@ -631,7 +631,7 @@ module Berkshelf
|
|
631
631
|
end
|
632
632
|
end
|
633
633
|
|
634
|
-
|
634
|
+
# The class representing an internal graph.
|
635
635
|
class Graph
|
636
636
|
include Enumerable
|
637
637
|
|
data/lib/berkshelf/logger.rb
CHANGED
@@ -3,7 +3,7 @@ module Berkshelf
|
|
3
3
|
def initialize(device = STDOUT)
|
4
4
|
super
|
5
5
|
self.level = Logger::WARN
|
6
|
-
@filter_params =
|
6
|
+
@filter_params = []
|
7
7
|
end
|
8
8
|
|
9
9
|
# Reimplements Logger#add adding message filtering. The info,
|
@@ -28,6 +28,7 @@ module Berkshelf
|
|
28
28
|
if @logdev.nil? || severity < (@level)
|
29
29
|
return true
|
30
30
|
end
|
31
|
+
|
31
32
|
progname ||= @progname
|
32
33
|
if message.nil?
|
33
34
|
if block_given?
|
@@ -38,7 +39,8 @@ module Berkshelf
|
|
38
39
|
end
|
39
40
|
end
|
40
41
|
@logdev.write(
|
41
|
-
format_message(format_severity(severity), Time.now, progname, filter(message))
|
42
|
+
format_message(format_severity(severity), Time.now, progname, filter(message))
|
43
|
+
)
|
42
44
|
true
|
43
45
|
end
|
44
46
|
|
data/lib/berkshelf/mixin/git.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative "../shell_out"
|
2
2
|
|
3
3
|
module Berkshelf
|
4
4
|
module Mixin
|
@@ -13,12 +13,12 @@ module Berkshelf
|
|
13
13
|
#
|
14
14
|
# @raise [String]
|
15
15
|
# the +$stdout+ from the command
|
16
|
-
def git(command, error = true)
|
16
|
+
def git(command, error = true, **kwargs)
|
17
17
|
unless Berkshelf.which("git") || Berkshelf.which("git.exe") || Berkshelf.which("git.bat")
|
18
18
|
raise GitNotInstalled.new
|
19
19
|
end
|
20
20
|
|
21
|
-
response = shell_out(%{git #{command}})
|
21
|
+
response = shell_out(%{git #{command}}, **kwargs)
|
22
22
|
|
23
23
|
if response.error?
|
24
24
|
raise GitCommandError.new(command, cache_path, response.stderr)
|
data/lib/berkshelf/packager.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require "archive/tar/minitar"
|
2
|
-
require "zlib"
|
2
|
+
require "zlib" unless defined?(Zlib)
|
3
3
|
|
4
4
|
module Berkshelf
|
5
5
|
# A class for archiving and compressing directory containing one or more cookbooks.
|
@@ -40,10 +40,8 @@ module Berkshelf
|
|
40
40
|
# @return [String]
|
41
41
|
# path to the generated archive
|
42
42
|
def run(source)
|
43
|
-
|
44
|
-
|
45
|
-
Archive::Tar::Minitar.pack(Dir.glob("*"), tgz)
|
46
|
-
end
|
43
|
+
tgz = Zlib::GzipWriter.new(File.open(out_file, "wb"))
|
44
|
+
Archive::Tar::Minitar.pack(Dir.glob("#{source}/*"), tgz)
|
47
45
|
|
48
46
|
out_file
|
49
47
|
rescue SystemCallError => ex
|
@@ -64,10 +62,10 @@ module Berkshelf
|
|
64
62
|
|
65
63
|
private
|
66
64
|
|
67
|
-
|
65
|
+
# @return [String]
|
68
66
|
attr_reader :out_dir
|
69
67
|
|
70
|
-
|
68
|
+
# @return [String]
|
71
69
|
attr_reader :filename
|
72
70
|
end
|
73
71
|
end
|