berkshelf 3.0.0.beta4 → 3.0.0.beta5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +6 -0
- data/README.md +3 -0
- data/berkshelf-complete.sh +10 -3
- data/berkshelf.gemspec +12 -11
- data/features/berksfile.feature +0 -2
- data/features/commands/apply.feature +0 -1
- data/features/commands/contingent.feature +0 -3
- data/features/commands/cookbook.feature +0 -3
- data/features/commands/init.feature +0 -2
- data/features/commands/install.feature +42 -35
- data/features/commands/list.feature +0 -3
- data/features/commands/outdated.feature +0 -4
- data/features/commands/package.feature +2 -39
- data/features/commands/shelf/list.feature +0 -2
- data/features/commands/shelf/show.feature +0 -5
- data/features/commands/shelf/uninstall.feature +0 -5
- data/features/commands/show.feature +0 -3
- data/features/commands/update.feature +0 -3
- data/features/commands/upload.feature +0 -13
- data/features/commands/vendor.feature +0 -5
- data/features/community_site.feature +0 -2
- data/features/config.feature +0 -6
- data/features/json_formatter.feature +0 -5
- data/features/licenses.feature +0 -5
- data/features/lockfile.feature +0 -20
- data/features/step_definitions/chef_server_steps.rb +8 -2
- data/generator_files/Gemfile.erb +2 -2
- data/lib/berkshelf.rb +0 -4
- data/lib/berkshelf/berksfile.rb +21 -51
- data/lib/berkshelf/cli.rb +26 -15
- data/lib/berkshelf/config.rb +4 -0
- data/lib/berkshelf/cookbook_generator.rb +1 -1
- data/lib/berkshelf/cookbook_store.rb +8 -0
- data/lib/berkshelf/core_ext/file.rb +2 -2
- data/lib/berkshelf/core_ext/pathname.rb +5 -7
- data/lib/berkshelf/dependency.rb +8 -1
- data/lib/berkshelf/downloader.rb +37 -0
- data/lib/berkshelf/errors.rb +1 -0
- data/lib/berkshelf/formatters.rb +1 -0
- data/lib/berkshelf/formatters/human_readable.rb +23 -9
- data/lib/berkshelf/formatters/json.rb +7 -9
- data/lib/berkshelf/git.rb +0 -1
- data/lib/berkshelf/init_generator.rb +1 -1
- data/lib/berkshelf/installer.rb +43 -19
- data/lib/berkshelf/location.rb +8 -13
- data/lib/berkshelf/locations/git_location.rb +12 -19
- data/lib/berkshelf/locations/mercurial_location.rb +5 -18
- data/lib/berkshelf/locations/path_location.rb +7 -0
- data/lib/berkshelf/lockfile.rb +5 -1
- data/lib/berkshelf/packager.rb +73 -0
- data/lib/berkshelf/resolver.rb +7 -5
- data/lib/berkshelf/resolver/graph.rb +7 -0
- data/lib/berkshelf/source.rb +22 -2
- data/lib/berkshelf/ui.rb +0 -2
- data/lib/berkshelf/version.rb +1 -1
- data/spec/support/git.rb +1 -0
- data/spec/support/mercurial.rb +37 -36
- data/spec/unit/berkshelf/berksfile_spec.rb +2 -34
- data/spec/unit/berkshelf/cli_spec.rb +3 -2
- data/spec/unit/berkshelf/config_spec.rb +3 -3
- data/spec/unit/berkshelf/core_ext/pathname_spec.rb +46 -0
- data/spec/unit/berkshelf/dependency_spec.rb +3 -3
- data/spec/unit/berkshelf/formatters_spec.rb +4 -4
- data/spec/unit/berkshelf/git_spec.rb +8 -8
- data/spec/unit/berkshelf/installer_spec.rb +2 -2
- data/spec/unit/berkshelf/locations/git_location_spec.rb +2 -8
- data/spec/unit/berkshelf/locations/mercurial_location_spec.rb +4 -23
- data/spec/unit/berkshelf/lockfile_spec.rb +1 -1
- data/spec/unit/berkshelf/mercurial_spec.rb +6 -7
- data/spec/unit/berkshelf/packager_spec.rb +39 -0
- data/spec/unit/berkshelf/ui_spec.rb +2 -2
- data/spec/unit/berkshelf_spec.rb +2 -2
- metadata +37 -24
- data/lib/berkshelf/api_client.rb +0 -65
- data/lib/berkshelf/api_client/remote_cookbook.rb +0 -55
- data/spec/unit/berkshelf/api_client/remote_cookbook_spec.rb +0 -23
- data/spec/unit/berkshelf/api_client_spec.rb +0 -57
data/features/licenses.feature
CHANGED
@@ -8,7 +8,6 @@ Feature: Installing cookbooks with specific licenses
|
|
8
8
|
cookbook 'fake', '1.0.0'
|
9
9
|
"""
|
10
10
|
|
11
|
-
|
12
11
|
Scenario: when licenses is defined
|
13
12
|
Given the cookbook store has the cookbooks:
|
14
13
|
| fake | 1.0.0 | mit |
|
@@ -22,7 +21,6 @@ Feature: Installing cookbooks with specific licenses
|
|
22
21
|
is not in your list of allowed licenses
|
23
22
|
"""
|
24
23
|
|
25
|
-
|
26
24
|
Scenario: when a license is not listed
|
27
25
|
Given the cookbook store has the cookbooks:
|
28
26
|
| fake | 1.0.0 | mit |
|
@@ -36,7 +34,6 @@ Feature: Installing cookbooks with specific licenses
|
|
36
34
|
'mit' is not in your list of allowed licenses
|
37
35
|
"""
|
38
36
|
|
39
|
-
|
40
37
|
Scenario: when raise_license_exception is defined
|
41
38
|
Given the cookbook store has the cookbooks:
|
42
39
|
| fake | 1.0.0 | mit |
|
@@ -50,7 +47,6 @@ Feature: Installing cookbooks with specific licenses
|
|
50
47
|
is not in your list of allowed licenses
|
51
48
|
"""
|
52
49
|
|
53
|
-
|
54
50
|
Scenario: when raise_license_exception is defined and a license is not listed
|
55
51
|
Given the cookbook store has the cookbooks:
|
56
52
|
| fake | 1.0.0 | mit |
|
@@ -65,7 +61,6 @@ Feature: Installing cookbooks with specific licenses
|
|
65
61
|
"""
|
66
62
|
And the exit status should be "LicenseNotAllowed"
|
67
63
|
|
68
|
-
|
69
64
|
Scenario: when the cookbook is a path location
|
70
65
|
Given the cookbook store has the cookbooks:
|
71
66
|
| fake | 0.1.0 | mit |
|
data/features/lockfile.feature
CHANGED
@@ -11,7 +11,6 @@ Feature: Creating and reading the Berkshelf lockfile
|
|
11
11
|
| berkshelf-cookbook-fixture | 1.0.0 | a97b9447cbd41a5fe58eee2026e48ccb503bd3bc |
|
12
12
|
| berkshelf-cookbook-fixture | 1.0.0 | 93f5768b7d14df45e10d16c8bf6fe98ba3ff809a |
|
13
13
|
|
14
|
-
|
15
14
|
Scenario: Writing the Berksfile.lock
|
16
15
|
Given I have a Berksfile pointing at the local Berkshelf API with:
|
17
16
|
"""
|
@@ -21,7 +20,6 @@ Feature: Creating and reading the Berkshelf lockfile
|
|
21
20
|
Then the Lockfile should have:
|
22
21
|
| fake | 1.0.0 |
|
23
22
|
|
24
|
-
|
25
23
|
Scenario: Writing the Berksfile.lock when a 1.0 lockfile is present
|
26
24
|
Given I have a Berksfile pointing at the local Berkshelf API with:
|
27
25
|
"""
|
@@ -36,7 +34,6 @@ Feature: Creating and reading the Berkshelf lockfile
|
|
36
34
|
And the Lockfile should have:
|
37
35
|
| fake | 1.0.0 |
|
38
36
|
|
39
|
-
|
40
37
|
Scenario: Writing the Berksfile.lock when a 1.0 lockfile is present and contains a full path
|
41
38
|
Given a cookbook named "fake"
|
42
39
|
And I have a Berksfile pointing at the local Berkshelf API with:
|
@@ -52,7 +49,6 @@ Feature: Creating and reading the Berkshelf lockfile
|
|
52
49
|
Then the Lockfile should have:
|
53
50
|
| fake | ./fake |
|
54
51
|
|
55
|
-
|
56
52
|
Scenario: Writing the Berksfile.lock when a 2.0 lockfile is present
|
57
53
|
Given I have a Berksfile pointing at the local Berkshelf API with:
|
58
54
|
"""
|
@@ -72,7 +68,6 @@ Feature: Creating and reading the Berkshelf lockfile
|
|
72
68
|
Then the Lockfile should have:
|
73
69
|
| fake | 1.0.0 |
|
74
70
|
|
75
|
-
|
76
71
|
Scenario: Reading the Berksfile.lock when it contains an invalid path location
|
77
72
|
Given I have a Berksfile pointing at the local Berkshelf API with:
|
78
73
|
"""
|
@@ -84,7 +79,6 @@ Feature: Creating and reading the Berkshelf lockfile
|
|
84
79
|
Then the Lockfile should have:
|
85
80
|
| fake | 1.0.0 |
|
86
81
|
|
87
|
-
|
88
82
|
Scenario: Installing a cookbook with dependencies
|
89
83
|
Given the cookbook store has the cookbooks:
|
90
84
|
| dep | 1.0.0 |
|
@@ -99,7 +93,6 @@ Feature: Creating and reading the Berkshelf lockfile
|
|
99
93
|
| fake | 1.0.0 |
|
100
94
|
| dep | 1.0.0 |
|
101
95
|
|
102
|
-
|
103
96
|
Scenario: Writing the Berksfile.lock with a pessimistic lock
|
104
97
|
And I have a Berksfile pointing at the local Berkshelf API with:
|
105
98
|
"""
|
@@ -111,7 +104,6 @@ Feature: Creating and reading the Berkshelf lockfile
|
|
111
104
|
Then the Lockfile should have:
|
112
105
|
| fake | 1.0.0 |
|
113
106
|
|
114
|
-
|
115
107
|
Scenario: Updating with a Berksfile.lock with pessimistic lock
|
116
108
|
Given I have a Berksfile pointing at the local Berkshelf API with:
|
117
109
|
"""
|
@@ -123,7 +115,6 @@ Feature: Creating and reading the Berkshelf lockfile
|
|
123
115
|
Then the Lockfile should have:
|
124
116
|
| fake | 0.2.0 |
|
125
117
|
|
126
|
-
|
127
118
|
Scenario: Updating with a Berksfile.lock with hard lock
|
128
119
|
And I have a Berksfile pointing at the local Berkshelf API with:
|
129
120
|
"""
|
@@ -135,7 +126,6 @@ Feature: Creating and reading the Berkshelf lockfile
|
|
135
126
|
Then the Lockfile should have:
|
136
127
|
| fake | 0.1.0 |
|
137
128
|
|
138
|
-
|
139
129
|
Scenario: Updating a Berksfile.lock with a git location
|
140
130
|
Given I have a Berksfile pointing at the local Berkshelf API with:
|
141
131
|
"""
|
@@ -145,7 +135,6 @@ Feature: Creating and reading the Berkshelf lockfile
|
|
145
135
|
Then the Lockfile should have:
|
146
136
|
| berkshelf-cookbook-fixture | 1.0.0 | 919afa0c402089df23ebdf36637f12271b8a96b4 |
|
147
137
|
|
148
|
-
|
149
138
|
Scenario: Updating a Berksfile.lock with a git location and a branch
|
150
139
|
Given I have a Berksfile pointing at the local Berkshelf API with:
|
151
140
|
"""
|
@@ -155,7 +144,6 @@ Feature: Creating and reading the Berkshelf lockfile
|
|
155
144
|
Then the Lockfile should have:
|
156
145
|
| berkshelf-cookbook-fixture | 1.0.0 | a97b9447cbd41a5fe58eee2026e48ccb503bd3bc |
|
157
146
|
|
158
|
-
|
159
147
|
Scenario: Updating a Berksfile.lock with a git location and a branch
|
160
148
|
Given I have a Berksfile pointing at the local Berkshelf API with:
|
161
149
|
"""
|
@@ -165,7 +153,6 @@ Feature: Creating and reading the Berkshelf lockfile
|
|
165
153
|
Then the Lockfile should have:
|
166
154
|
| berkshelf-cookbook-fixture | 0.2.0 | 70a527e17d91f01f031204562460ad1c17f972ee |
|
167
155
|
|
168
|
-
|
169
156
|
Scenario: Updating a Berksfile.lock with a GitHub location
|
170
157
|
Given I have a Berksfile pointing at the local Berkshelf API with:
|
171
158
|
"""
|
@@ -175,7 +162,6 @@ Feature: Creating and reading the Berkshelf lockfile
|
|
175
162
|
Then the Lockfile should have:
|
176
163
|
| berkshelf-cookbook-fixture | 1.0.0 | 919afa0c402089df23ebdf36637f12271b8a96b4 |
|
177
164
|
|
178
|
-
|
179
165
|
Scenario: Updating a Berksfile.lock when a git location with :rel
|
180
166
|
Given I have a Berksfile pointing at the local Berkshelf API with:
|
181
167
|
"""
|
@@ -185,7 +171,6 @@ Feature: Creating and reading the Berkshelf lockfile
|
|
185
171
|
Then the Lockfile should have:
|
186
172
|
| berkshelf-cookbook-fixture | 1.0.0 | 93f5768b7d14df45e10d16c8bf6fe98ba3ff809a | cookbooks/berkshelf-cookbook-fixture |
|
187
173
|
|
188
|
-
|
189
174
|
Scenario: Updating a Berksfile.lock with a path location
|
190
175
|
Given a cookbook named "fake"
|
191
176
|
And I have a Berksfile pointing at the local Berkshelf API with:
|
@@ -196,7 +181,6 @@ Feature: Creating and reading the Berkshelf lockfile
|
|
196
181
|
Then the Lockfile should have:
|
197
182
|
| fake | ./fake |
|
198
183
|
|
199
|
-
|
200
184
|
Scenario: Installing a Berksfile with a metadata location
|
201
185
|
Given a cookbook named "fake"
|
202
186
|
And I cd to "fake"
|
@@ -208,7 +192,6 @@ Feature: Creating and reading the Berkshelf lockfile
|
|
208
192
|
Then the Lockfile should have:
|
209
193
|
| fake | . |
|
210
194
|
|
211
|
-
|
212
195
|
Scenario: Installing a Berksfile with a metadata location
|
213
196
|
Given a cookbook named "fake"
|
214
197
|
And I cd to "fake"
|
@@ -222,7 +205,6 @@ Feature: Creating and reading the Berkshelf lockfile
|
|
222
205
|
Then the Lockfile should have:
|
223
206
|
| fake | . |
|
224
207
|
|
225
|
-
|
226
208
|
Scenario: Installing when the locked version is no longer satisfied
|
227
209
|
Given I have a Berksfile pointing at the local Berkshelf API with:
|
228
210
|
"""
|
@@ -244,7 +226,6 @@ Feature: Creating and reading the Berkshelf lockfile
|
|
244
226
|
"""
|
245
227
|
And the exit status should be "OutdatedDependency"
|
246
228
|
|
247
|
-
|
248
229
|
Scenario: Installing when the Lockfile is empty
|
249
230
|
Given I have a Berksfile pointing at the local Berkshelf API with:
|
250
231
|
"""
|
@@ -257,7 +238,6 @@ Feature: Creating and reading the Berkshelf lockfile
|
|
257
238
|
Using fake (1.0.0)
|
258
239
|
"""
|
259
240
|
|
260
|
-
|
261
241
|
Scenario: Installing when the Lockfile is in a bad state
|
262
242
|
Given I have a Berksfile pointing at the local Berkshelf API with:
|
263
243
|
"""
|
@@ -5,8 +5,14 @@ Given(/^the Chef Server is empty$/) do
|
|
5
5
|
end
|
6
6
|
|
7
7
|
Given /^the Chef Server has cookbooks:$/ do |cookbooks|
|
8
|
-
cookbooks.raw.each do |name, version|
|
9
|
-
|
8
|
+
cookbooks.raw.each do |name, version, dependencies|
|
9
|
+
metadata = []
|
10
|
+
metadata << "version '#{version}'"
|
11
|
+
dependencies.to_s.split(',').map { |d| d.split(' ', 2) }.each do |(name, constraint)|
|
12
|
+
metadata << "depends '#{name}', '#{constraint}'"
|
13
|
+
end
|
14
|
+
|
15
|
+
chef_cookbook(name, { 'metadata.rb' => metadata.join("\n") })
|
10
16
|
end
|
11
17
|
end
|
12
18
|
|
data/generator_files/Gemfile.erb
CHANGED
@@ -5,9 +5,9 @@ gem 'berkshelf'
|
|
5
5
|
# Uncomment these lines (and the ones in the generated Vagrantfile) if you want
|
6
6
|
# to live on the Edge:
|
7
7
|
#
|
8
|
-
# gem "berkshelf", github: "
|
8
|
+
# gem "berkshelf", github: "berkshelf/berkshelf"
|
9
9
|
# gem "vagrant", github: "mitchellh/vagrant", tag: "v1.3.5"
|
10
|
-
# gem "vagrant-berkshelf", github: "
|
10
|
+
# gem "vagrant-berkshelf", github: "berkshelf/vagrant-berkshelf"
|
11
11
|
# gem "vagrant-omnibus", github: "schisamo/vagrant-omnibus", tag: "v1.1.2"
|
12
12
|
|
13
13
|
<% if options[:foodcritic] -%>
|
data/lib/berkshelf.rb
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
require 'buff/extensions'
|
2
|
-
require 'archive/tar/minitar'
|
3
2
|
require 'digest/md5'
|
4
3
|
require 'forwardable'
|
5
|
-
require 'hashie'
|
6
4
|
require 'json'
|
7
5
|
require 'pathname'
|
8
6
|
require 'ridley'
|
@@ -10,7 +8,6 @@ require 'solve'
|
|
10
8
|
require 'thor'
|
11
9
|
require 'tmpdir'
|
12
10
|
require 'uri'
|
13
|
-
require 'zlib'
|
14
11
|
|
15
12
|
JSON.create_id = nil
|
16
13
|
|
@@ -170,7 +167,6 @@ module Berkshelf
|
|
170
167
|
end
|
171
168
|
|
172
169
|
require_relative 'berkshelf/lockfile'
|
173
|
-
require_relative 'berkshelf/api_client'
|
174
170
|
require_relative 'berkshelf/base_generator'
|
175
171
|
require_relative 'berkshelf/berksfile'
|
176
172
|
require_relative 'berkshelf/cached_cookbook'
|
data/lib/berkshelf/berksfile.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative "packager"
|
2
|
+
|
1
3
|
module Berkshelf
|
2
4
|
class Berksfile
|
3
5
|
class << self
|
@@ -500,7 +502,6 @@ module Berkshelf
|
|
500
502
|
force: false,
|
501
503
|
freeze: true,
|
502
504
|
halt_on_frozen: false,
|
503
|
-
skip_dependencies: false,
|
504
505
|
cookbooks: [],
|
505
506
|
validate: true
|
506
507
|
}.merge(options)
|
@@ -516,64 +517,33 @@ module Berkshelf
|
|
516
517
|
# name attribute is not given, all cookbooks in the Berksfile will be
|
517
518
|
# packaged.
|
518
519
|
#
|
519
|
-
# @param [String]
|
520
|
-
# the
|
521
|
-
# @param [Hash] options
|
522
|
-
# a list of options
|
520
|
+
# @param [String] path
|
521
|
+
# the path where the tarball will be created
|
523
522
|
#
|
524
|
-
# @option options [
|
525
|
-
#
|
526
|
-
#
|
527
|
-
#
|
523
|
+
# @option options [Symbol, Array] :except
|
524
|
+
# Group(s) to exclude which will cause any dependencies marked as a member of the
|
525
|
+
# group to not be installed
|
526
|
+
# @option options [Symbol, Array] :only
|
527
|
+
# Group(s) to include which will cause any dependencies marked as a member of the
|
528
|
+
# group to be installed and all others to be ignored
|
529
|
+
#
|
530
|
+
# @raise [Berkshelf::PackageError]
|
528
531
|
#
|
529
532
|
# @return [String]
|
530
533
|
# the path to the package
|
531
|
-
def package(
|
532
|
-
|
533
|
-
|
534
|
+
def package(path, options = {})
|
535
|
+
packager = Packager.new(path)
|
536
|
+
packager.validate!
|
534
537
|
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
+
outdir = Dir.mktmpdir do |temp_dir|
|
539
|
+
source = Berkshelf.ui.mute do
|
540
|
+
vendor(File.join(temp_dir, "cookbooks"), options.slice(:only, :except))
|
538
541
|
end
|
539
|
-
|
540
|
-
options[:cookbooks] = name
|
541
|
-
Berkshelf.ui.mute { install(options) }
|
542
|
-
else
|
543
|
-
Berkshelf.ui.mute { install(options) }
|
542
|
+
packager.run(source)
|
544
543
|
end
|
545
544
|
|
546
|
-
|
547
|
-
|
548
|
-
Dir.mktmpdir do |tmp|
|
549
|
-
cookbooks_dir = File.join(tmp, 'cookbooks')
|
550
|
-
FileUtils.mkdir_p(cookbooks_dir)
|
551
|
-
|
552
|
-
cached_cookbooks.each do |cookbook|
|
553
|
-
path = cookbook.path.to_s
|
554
|
-
destination = File.join(cookbooks_dir, cookbook.cookbook_name)
|
555
|
-
|
556
|
-
FileUtils.cp_r(path, destination)
|
557
|
-
|
558
|
-
unless options[:ignore_chefignore]
|
559
|
-
chefignore = Ridley::Chef::Chefignore.new(destination) rescue nil
|
560
|
-
Dir["#{destination}/**/*"].each do |path|
|
561
|
-
FileUtils.rm_rf(path) if chefignore.ignored?(path)
|
562
|
-
end if chefignore
|
563
|
-
end
|
564
|
-
end
|
565
|
-
|
566
|
-
FileUtils.mkdir_p(options[:output])
|
567
|
-
|
568
|
-
Dir.chdir(tmp) do |dir|
|
569
|
-
tgz = Zlib::GzipWriter.new(File.open(output, 'wb'))
|
570
|
-
Archive::Tar::Minitar.pack('.', tgz)
|
571
|
-
end
|
572
|
-
end
|
573
|
-
|
574
|
-
Berkshelf.formatter.package(name, output)
|
575
|
-
|
576
|
-
output
|
545
|
+
Berkshelf.formatter.package(outdir)
|
546
|
+
outdir
|
577
547
|
end
|
578
548
|
|
579
549
|
# Install the Berksfile or Berksfile.lock and then copy the cached cookbooks into
|
data/lib/berkshelf/cli.rb
CHANGED
@@ -67,6 +67,7 @@ module Berkshelf
|
|
67
67
|
end
|
68
68
|
|
69
69
|
if @options[:debug]
|
70
|
+
ENV["BERKSHELF_DEBUG"] = "true"
|
70
71
|
Berkshelf.logger.level = ::Logger::DEBUG
|
71
72
|
end
|
72
73
|
|
@@ -127,11 +128,17 @@ module Berkshelf
|
|
127
128
|
banner: 'PATH'
|
128
129
|
method_option :path,
|
129
130
|
type: :string,
|
130
|
-
desc: 'Path to install cookbooks to (i.e. vendor/cookbooks).',
|
131
131
|
aliases: '-p',
|
132
|
-
|
132
|
+
hide: true
|
133
133
|
desc 'install', 'Install the cookbooks specified in the Berksfile'
|
134
134
|
def install
|
135
|
+
if options[:path]
|
136
|
+
# TODO: Remove in Berkshelf 4.0
|
137
|
+
Berkshelf.formatter.deprecation "`berks install --path [PATH}` has been replaced by `berks vendor`."
|
138
|
+
Berkshelf.formatter.deprecation "Re-run your command as `berks vendor [PATH]` or see `berks help vendor`."
|
139
|
+
exit(1)
|
140
|
+
end
|
141
|
+
|
135
142
|
berksfile = Berkshelf::Berksfile.from_file(options[:berksfile])
|
136
143
|
berksfile.install(options)
|
137
144
|
end
|
@@ -319,20 +326,24 @@ module Berkshelf
|
|
319
326
|
desc: 'Path to a Berksfile to operate off of.',
|
320
327
|
aliases: '-b',
|
321
328
|
banner: 'PATH'
|
322
|
-
method_option :
|
323
|
-
type: :
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
329
|
+
method_option :except,
|
330
|
+
type: :array,
|
331
|
+
desc: "Exclude cookbooks that are in these groups.",
|
332
|
+
aliases: "-e"
|
333
|
+
method_option :only,
|
334
|
+
type: :array,
|
335
|
+
desc: "Only cookbooks that are in these groups.",
|
336
|
+
aliases: "-o"
|
337
|
+
desc "package [PATH]", "Vendor and archive the dependencies of a Berksfile"
|
338
|
+
def package(path = nil)
|
339
|
+
if path.nil?
|
340
|
+
path ||= File.join(Dir.pwd, "cookbooks-#{Time.now.to_i}.tar.gz")
|
341
|
+
else
|
342
|
+
path = File.expand_path(path)
|
343
|
+
end
|
344
|
+
|
334
345
|
berksfile = Berkshelf::Berksfile.from_file(options[:berksfile])
|
335
|
-
berksfile.package(
|
346
|
+
berksfile.package(path, options)
|
336
347
|
end
|
337
348
|
|
338
349
|
method_option :except,
|
data/lib/berkshelf/config.rb
CHANGED
@@ -95,6 +95,14 @@ module Berkshelf
|
|
95
95
|
# @return [Array<Berkshelf::CachedCookbook>]
|
96
96
|
def cookbooks(filter = nil)
|
97
97
|
cookbooks = storage_path.children.collect do |path|
|
98
|
+
begin
|
99
|
+
Solve::Version.split(File.basename(path).slice(CachedCookbook::DIRNAME_REGEXP, 2))
|
100
|
+
rescue Solve::Errors::InvalidVersionFormat
|
101
|
+
# Skip cookbooks that were downloaded by an SCM location. These can not be considered
|
102
|
+
# complete cookbooks.
|
103
|
+
next
|
104
|
+
end
|
105
|
+
|
98
106
|
CachedCookbook.from_store_path(path)
|
99
107
|
end.compact
|
100
108
|
|
@@ -1,13 +1,13 @@
|
|
1
1
|
class File
|
2
2
|
class << self
|
3
|
-
# Returns true or false if the given path
|
3
|
+
# Returns true or false if the given path contains a Chef Cookbook
|
4
4
|
#
|
5
5
|
# @param [#to_s] path
|
6
6
|
# path of directory to reflect on
|
7
7
|
#
|
8
8
|
# @return [Boolean]
|
9
9
|
def cookbook?(path)
|
10
|
-
File.exists?(File.join(path,
|
10
|
+
File.exists?(File.join(path, "metadata.json")) || File.exists?(File.join(path, "metadata.rb"))
|
11
11
|
end
|
12
12
|
alias_method :chef_cookbook?, :cookbook?
|
13
13
|
end
|