berkshelf 2.0.0.beta → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +19 -1
- data/CONTRIBUTING.md +1 -3
- data/Gemfile +0 -20
- data/Guardfile +3 -3
- data/LICENSE +6 -5
- data/README.md +1 -0
- data/Thorfile +48 -67
- data/berkshelf.gemspec +48 -37
- data/features/apply_command.feature +17 -11
- data/features/config.feature +11 -11
- data/features/configure_command.feature +8 -8
- data/features/contingent_command.feature +37 -8
- data/features/cookbook_command.feature +17 -14
- data/features/groups_install.feature +24 -20
- data/features/install_command.feature +24 -33
- data/features/licenses.feature +112 -0
- data/features/list_command.feature +17 -5
- data/features/lockfile.feature +307 -188
- data/features/outdated_command.feature +1 -4
- data/features/package_command.feature +41 -19
- data/features/shelf/list.feature +39 -0
- data/features/shelf/show.feature +152 -0
- data/features/shelf/uninstall.feature +103 -0
- data/features/show_command.feature +49 -17
- data/features/step_definitions/filesystem_steps.rb +12 -3
- data/features/step_definitions/utility_steps.rb +0 -1
- data/features/support/env.rb +11 -4
- data/features/update_command.feature +22 -10
- data/features/upload_command.feature +174 -127
- data/features/vendor_install.feature +6 -6
- data/generator_files/Berksfile.erb +1 -1
- data/generator_files/metadata.rb.erb +7 -7
- data/lib/berkshelf.rb +39 -27
- data/lib/berkshelf/base_generator.rb +2 -3
- data/lib/berkshelf/berksfile.rb +69 -17
- data/lib/berkshelf/cached_cookbook.rb +17 -1
- data/lib/berkshelf/chef.rb +2 -4
- data/lib/berkshelf/chef/config.rb +51 -75
- data/lib/berkshelf/chef/cookbook.rb +1 -2
- data/lib/berkshelf/chef/cookbook/chefignore.rb +1 -1
- data/lib/berkshelf/cli.rb +144 -194
- data/lib/berkshelf/command.rb +11 -12
- data/lib/berkshelf/commands/shelf.rb +130 -0
- data/lib/berkshelf/commands/test_command.rb +11 -0
- data/lib/berkshelf/community_rest.rb +1 -2
- data/lib/berkshelf/config.rb +14 -10
- data/lib/berkshelf/cookbook_generator.rb +30 -24
- data/lib/berkshelf/cookbook_source.rb +1 -1
- data/lib/berkshelf/cookbook_store.rb +0 -1
- data/lib/berkshelf/core_ext.rb +1 -1
- data/lib/berkshelf/core_ext/file.rb +1 -1
- data/lib/berkshelf/downloader.rb +3 -1
- data/lib/berkshelf/errors.rb +128 -53
- data/lib/berkshelf/formatters.rb +2 -6
- data/lib/berkshelf/formatters/human_readable.rb +8 -2
- data/lib/berkshelf/formatters/json.rb +7 -1
- data/lib/berkshelf/formatters/null.rb +0 -1
- data/lib/berkshelf/git.rb +16 -16
- data/lib/berkshelf/init_generator.rb +28 -26
- data/lib/berkshelf/location.rb +12 -11
- data/lib/berkshelf/locations/chef_api_location.rb +2 -2
- data/lib/berkshelf/locations/git_location.rb +0 -1
- data/lib/berkshelf/locations/github_location.rb +0 -1
- data/lib/berkshelf/locations/path_location.rb +1 -2
- data/lib/berkshelf/locations/site_location.rb +3 -2
- data/lib/berkshelf/lockfile.rb +29 -10
- data/lib/berkshelf/mixin/config.rb +155 -0
- data/lib/berkshelf/mixin/logging.rb +0 -1
- data/lib/berkshelf/mixin/shellout.rb +71 -0
- data/lib/berkshelf/resolver.rb +7 -4
- data/lib/berkshelf/test.rb +1 -3
- data/lib/berkshelf/ui.rb +8 -4
- data/lib/berkshelf/version.rb +1 -1
- data/lib/thor/monkies/shell.rb +0 -1
- data/spec/config/berkshelf.pem +27 -0
- data/spec/config/knife.rb +12 -0
- data/spec/config/validator.pem +27 -0
- data/spec/spec_helper.rb +4 -8
- data/spec/support/chef_api.rb +14 -9
- data/spec/support/chef_server.rb +3 -4
- data/spec/unit/berkshelf/berksfile_spec.rb +1 -1
- data/spec/unit/berkshelf/cookbook_generator_spec.rb +12 -6
- data/spec/unit/berkshelf/cookbook_source_spec.rb +13 -1
- data/spec/unit/berkshelf/init_generator_spec.rb +5 -0
- data/spec/unit/chef/config_spec.rb +9 -10
- metadata +216 -93
- data/features/info_command.feature +0 -39
- data/features/open_command.feature +0 -36
- data/lib/berkshelf/cli_commands/test_command.rb +0 -11
- data/lib/berkshelf/mixin.rb +0 -10
- data/lib/berkshelf/mixin/path_helpers.rb +0 -30
- data/spec/support/knife.rb +0 -18
data/lib/berkshelf/cli.rb
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
require 'berkshelf'
|
2
|
+
require_relative 'config'
|
3
|
+
require_relative 'init_generator'
|
4
|
+
require_relative 'cookbook_generator'
|
5
|
+
|
6
|
+
require 'berkshelf/commands/test_command'
|
7
|
+
require 'berkshelf/commands/shelf'
|
2
8
|
|
3
9
|
module Berkshelf
|
4
|
-
# @author Jamie Winsor <reset@riotgames.com>
|
5
10
|
class Cli < Thor
|
6
11
|
class << self
|
7
12
|
def dispatch(meth, given_args, given_opts, config)
|
@@ -15,7 +20,7 @@ module Berkshelf
|
|
15
20
|
end
|
16
21
|
else
|
17
22
|
super
|
18
|
-
Berkshelf.formatter.cleanup_hook unless config[:current_command].name ==
|
23
|
+
Berkshelf.formatter.cleanup_hook unless config[:current_command].name == 'help'
|
19
24
|
end
|
20
25
|
end
|
21
26
|
end
|
@@ -25,7 +30,7 @@ module Berkshelf
|
|
25
30
|
|
26
31
|
if @options[:config]
|
27
32
|
unless File.exist?(@options[:config])
|
28
|
-
raise
|
33
|
+
raise ConfigNotFound.new(:berkshelf, @options[:config])
|
29
34
|
end
|
30
35
|
Berkshelf::Config.path = @options[:config]
|
31
36
|
end
|
@@ -42,7 +47,7 @@ module Berkshelf
|
|
42
47
|
@options = options.dup # unfreeze frozen options Hash from Thor
|
43
48
|
end
|
44
49
|
|
45
|
-
namespace
|
50
|
+
namespace 'berkshelf'
|
46
51
|
|
47
52
|
map 'in' => :install
|
48
53
|
map 'up' => :upload
|
@@ -55,52 +60,52 @@ module Berkshelf
|
|
55
60
|
|
56
61
|
class_option :config,
|
57
62
|
type: :string,
|
58
|
-
desc:
|
59
|
-
aliases:
|
60
|
-
banner:
|
63
|
+
desc: 'Path to Berkshelf configuration to use.',
|
64
|
+
aliases: '-c',
|
65
|
+
banner: 'PATH'
|
61
66
|
class_option :format,
|
62
67
|
type: :string,
|
63
|
-
default:
|
64
|
-
desc:
|
65
|
-
aliases:
|
66
|
-
banner:
|
68
|
+
default: 'human',
|
69
|
+
desc: 'Output format to use.',
|
70
|
+
aliases: '-F',
|
71
|
+
banner: 'FORMAT'
|
67
72
|
class_option :quiet,
|
68
73
|
type: :boolean,
|
69
|
-
desc:
|
70
|
-
aliases:
|
74
|
+
desc: 'Silence all informational output.',
|
75
|
+
aliases: '-q',
|
71
76
|
default: false
|
72
77
|
class_option :debug,
|
73
78
|
type: :boolean,
|
74
|
-
desc:
|
75
|
-
aliases:
|
79
|
+
desc: 'Output debug information',
|
80
|
+
aliases: '-d',
|
76
81
|
default: false
|
77
82
|
|
78
83
|
method_option :force,
|
79
84
|
type: :boolean,
|
80
85
|
default: false,
|
81
|
-
desc:
|
86
|
+
desc: 'create a new configuration file even if one already exists.'
|
82
87
|
method_option :path,
|
83
88
|
type: :string,
|
84
89
|
default: Berkshelf::Config.path,
|
85
90
|
desc: 'The path to save the configuration file'
|
86
|
-
desc
|
91
|
+
desc 'configure', 'Create a new Berkshelf configuration file'
|
87
92
|
def configure
|
88
93
|
path = File.expand_path(options[:path])
|
89
94
|
|
90
95
|
if File.exist?(path) && !options[:force]
|
91
|
-
raise Berkshelf::ConfigExists,
|
96
|
+
raise Berkshelf::ConfigExists, 'A configuration file already exists. Re-run with the --force flag if you wish to overwrite it.'
|
92
97
|
end
|
93
98
|
|
94
99
|
@config = Berkshelf::Config.new(path)
|
95
100
|
|
96
101
|
[
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
102
|
+
'chef.chef_server_url',
|
103
|
+
'chef.node_name',
|
104
|
+
'chef.client_key',
|
105
|
+
'chef.validation_client_name',
|
106
|
+
'chef.validation_key_path',
|
107
|
+
'vagrant.vm.box',
|
108
|
+
'vagrant.vm.box_url',
|
104
109
|
].each do |attribute|
|
105
110
|
default = @config.get_attribute(attribute)
|
106
111
|
|
@@ -124,41 +129,26 @@ module Berkshelf
|
|
124
129
|
Berkshelf.formatter.msg "Config written to: '#{path}'"
|
125
130
|
end
|
126
131
|
|
127
|
-
desc "open NAME", "Opens the source directory of an installed cookbook"
|
128
|
-
def open(name)
|
129
|
-
editor = [ENV['BERKSHELF_EDITOR'], ENV['VISUAL'], ENV['EDITOR']].find{|e| !e.nil? && !e.empty? }
|
130
|
-
raise ArgumentError, "To open a cookbook, set $EDITOR or $BERKSHELF_EDITOR" unless editor
|
131
|
-
|
132
|
-
cookbook = Berkshelf.cookbook_store.cookbooks(name).last
|
133
|
-
raise CookbookNotFound, "Cookbook '#{name}' not found in any of the sources!" unless cookbook
|
134
|
-
|
135
|
-
Dir.chdir(cookbook.path) do
|
136
|
-
command = "#{editor} #{cookbook.path}"
|
137
|
-
success = system(command)
|
138
|
-
raise CommandUnsuccessful, "Could not run `#{command}`" unless success
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
132
|
method_option :except,
|
143
133
|
type: :array,
|
144
|
-
desc:
|
145
|
-
aliases:
|
134
|
+
desc: 'Exclude cookbooks that are in these groups.',
|
135
|
+
aliases: '-e'
|
146
136
|
method_option :only,
|
147
137
|
type: :array,
|
148
|
-
desc:
|
149
|
-
aliases:
|
138
|
+
desc: 'Only cookbooks that are in these groups.',
|
139
|
+
aliases: '-o'
|
150
140
|
method_option :berksfile,
|
151
141
|
type: :string,
|
152
142
|
default: Berkshelf::DEFAULT_FILENAME,
|
153
|
-
desc:
|
154
|
-
aliases:
|
155
|
-
banner:
|
143
|
+
desc: 'Path to a Berksfile to operate off of.',
|
144
|
+
aliases: '-b',
|
145
|
+
banner: 'PATH'
|
156
146
|
method_option :path,
|
157
147
|
type: :string,
|
158
|
-
desc:
|
159
|
-
aliases:
|
160
|
-
banner:
|
161
|
-
desc
|
148
|
+
desc: 'Path to install cookbooks to (i.e. vendor/cookbooks).',
|
149
|
+
aliases: '-p',
|
150
|
+
banner: 'PATH'
|
151
|
+
desc 'install', 'Install the cookbooks specified in the Berksfile'
|
162
152
|
def install
|
163
153
|
berksfile = ::Berkshelf::Berksfile.from_file(options[:berksfile])
|
164
154
|
berksfile.install(options)
|
@@ -167,18 +157,18 @@ module Berkshelf
|
|
167
157
|
method_option :berksfile,
|
168
158
|
type: :string,
|
169
159
|
default: File.join(Dir.pwd, Berkshelf::DEFAULT_FILENAME),
|
170
|
-
desc:
|
171
|
-
aliases:
|
172
|
-
banner:
|
160
|
+
desc: 'Path to a Berksfile to operate off of.',
|
161
|
+
aliases: '-b',
|
162
|
+
banner: 'PATH'
|
173
163
|
method_option :except,
|
174
164
|
type: :array,
|
175
|
-
desc:
|
176
|
-
aliases:
|
165
|
+
desc: 'Exclude cookbooks that are in these groups.',
|
166
|
+
aliases: '-e'
|
177
167
|
method_option :only,
|
178
168
|
type: :array,
|
179
|
-
desc:
|
180
|
-
aliases:
|
181
|
-
desc
|
169
|
+
desc: 'Only cookbooks that are in these groups.',
|
170
|
+
aliases: '-o'
|
171
|
+
desc 'update [COOKBOOKS]', 'Update the cookbooks (and dependencies) specified in the Berksfile'
|
182
172
|
def update(*cookbook_names)
|
183
173
|
berksfile = Berksfile.from_file(options[:berksfile])
|
184
174
|
|
@@ -192,44 +182,44 @@ module Berkshelf
|
|
192
182
|
method_option :berksfile,
|
193
183
|
type: :string,
|
194
184
|
default: File.join(Dir.pwd, Berkshelf::DEFAULT_FILENAME),
|
195
|
-
desc:
|
196
|
-
aliases:
|
197
|
-
banner:
|
185
|
+
desc: 'Path to a Berksfile to operate off of.',
|
186
|
+
aliases: '-b',
|
187
|
+
banner: 'PATH'
|
198
188
|
method_option :except,
|
199
189
|
type: :array,
|
200
|
-
desc:
|
201
|
-
aliases:
|
190
|
+
desc: 'Exclude cookbooks that are in these groups.',
|
191
|
+
aliases: '-e'
|
202
192
|
method_option :only,
|
203
193
|
type: :array,
|
204
|
-
desc:
|
205
|
-
aliases:
|
194
|
+
desc: 'Only cookbooks that are in these groups.',
|
195
|
+
aliases: '-o'
|
206
196
|
method_option :no_freeze,
|
207
197
|
type: :boolean,
|
208
198
|
default: false,
|
209
|
-
desc:
|
199
|
+
desc: 'Do not freeze uploaded cookbook(s).'
|
210
200
|
method_option :force,
|
211
201
|
type: :boolean,
|
212
202
|
default: false,
|
213
|
-
desc:
|
203
|
+
desc: 'Upload all cookbook(s) even if a frozen one exists on the Chef Server.'
|
214
204
|
method_option :ssl_verify,
|
215
205
|
type: :boolean,
|
216
206
|
default: nil,
|
217
|
-
desc:
|
207
|
+
desc: 'Disable/Enable SSL verification when uploading cookbooks.'
|
218
208
|
method_option :skip_syntax_check,
|
219
209
|
type: :boolean,
|
220
210
|
default: false,
|
221
|
-
desc:
|
222
|
-
aliases:
|
211
|
+
desc: 'Skip Ruby syntax check when uploading cookbooks.',
|
212
|
+
aliases: '-s'
|
223
213
|
method_option :skip_dependencies,
|
224
214
|
type: :boolean,
|
225
|
-
desc:
|
215
|
+
desc: 'Skip uploading dependent cookbook(s).',
|
226
216
|
default: false,
|
227
|
-
aliases:
|
217
|
+
aliases: '-D'
|
228
218
|
method_option :halt_on_frozen,
|
229
219
|
type: :boolean,
|
230
220
|
default: false,
|
231
|
-
desc:
|
232
|
-
desc
|
221
|
+
desc: 'Halt uploading and exit if the Chef Server has a frozen version of the cookbook(s).'
|
222
|
+
desc 'upload [COOKBOOKS]', 'Upload the cookbook specified in the Berksfile to the Chef Server'
|
233
223
|
def upload(*cookbook_names)
|
234
224
|
berksfile = ::Berkshelf::Berksfile.from_file(options[:berksfile])
|
235
225
|
|
@@ -243,14 +233,14 @@ module Berkshelf
|
|
243
233
|
method_option :berksfile,
|
244
234
|
type: :string,
|
245
235
|
default: File.join(Dir.pwd, Berkshelf::DEFAULT_FILENAME),
|
246
|
-
desc:
|
247
|
-
aliases:
|
248
|
-
banner:
|
236
|
+
desc: 'Path to a Berksfile to operate off of.',
|
237
|
+
aliases: '-b',
|
238
|
+
banner: 'PATH'
|
249
239
|
method_option :ssl_verify,
|
250
240
|
type: :boolean,
|
251
241
|
default: nil,
|
252
|
-
desc:
|
253
|
-
desc
|
242
|
+
desc: 'Disable/Enable SSL verification when locking cookbooks.'
|
243
|
+
desc 'apply ENVIRONMENT', 'Apply the cookbook version locks from Berksfile.lock to a Chef environment'
|
254
244
|
def apply(environment_name)
|
255
245
|
berksfile = ::Berkshelf::Berksfile.from_file(options[:berksfile])
|
256
246
|
lock_options = Hash[options].symbolize_keys
|
@@ -261,24 +251,24 @@ module Berkshelf
|
|
261
251
|
method_option :berksfile,
|
262
252
|
type: :string,
|
263
253
|
default: File.join(Dir.pwd, Berkshelf::DEFAULT_FILENAME),
|
264
|
-
desc:
|
265
|
-
aliases:
|
266
|
-
banner:
|
254
|
+
desc: 'Path to a Berksfile to operate off of.',
|
255
|
+
aliases: '-b',
|
256
|
+
banner: 'PATH'
|
267
257
|
method_option :except,
|
268
258
|
type: :array,
|
269
|
-
desc:
|
270
|
-
aliases:
|
259
|
+
desc: 'Exclude cookbooks that are in these groups.',
|
260
|
+
aliases: '-e'
|
271
261
|
method_option :only,
|
272
262
|
type: :array,
|
273
|
-
desc:
|
274
|
-
aliases:
|
275
|
-
desc
|
263
|
+
desc: 'Only cookbooks that are in these groups.',
|
264
|
+
aliases: '-o'
|
265
|
+
desc 'outdated [COOKBOOKS]', 'Show outdated cookbooks (from the community site)'
|
276
266
|
def outdated(*cookbook_names)
|
277
267
|
berksfile = ::Berkshelf::Berksfile.from_file(options[:berksfile])
|
278
|
-
Berkshelf.formatter.msg
|
279
|
-
Berkshelf.formatter.msg
|
280
|
-
Berkshelf.formatter.msg
|
281
|
-
Berkshelf.formatter.msg
|
268
|
+
Berkshelf.formatter.msg 'Listing outdated cookbooks with newer versions available...'
|
269
|
+
Berkshelf.formatter.msg 'BETA: this feature will only pull differences from the community site and will'
|
270
|
+
Berkshelf.formatter.msg 'BETA: ignore all other sources you may have defined'
|
271
|
+
Berkshelf.formatter.msg ''
|
282
272
|
|
283
273
|
outdated_options = {
|
284
274
|
cookbooks: cookbook_names
|
@@ -287,7 +277,7 @@ module Berkshelf
|
|
287
277
|
outdated = berksfile.outdated(outdated_options)
|
288
278
|
|
289
279
|
if outdated.empty?
|
290
|
-
Berkshelf.formatter.msg
|
280
|
+
Berkshelf.formatter.msg 'All cookbooks up to date'
|
291
281
|
else
|
292
282
|
outdated.each do |cookbook, latest_version|
|
293
283
|
Berkshelf.formatter.msg "Cookbook '#{cookbook.name} (#{cookbook.version_constraint})' is outdated (#{latest_version})"
|
@@ -295,10 +285,10 @@ module Berkshelf
|
|
295
285
|
end
|
296
286
|
end
|
297
287
|
|
298
|
-
desc
|
288
|
+
desc 'init [PATH]', 'Initialize Berkshelf in the given directory'
|
299
289
|
def init(path = Dir.pwd)
|
300
|
-
Berkshelf.formatter.deprecation
|
301
|
-
Berkshelf.formatter.deprecation
|
290
|
+
Berkshelf.formatter.deprecation '--git is now the default' if options[:git]
|
291
|
+
Berkshelf.formatter.deprecation '--vagrant is now the default' if options[:vagrant]
|
302
292
|
|
303
293
|
if File.chef_cookbook?(path)
|
304
294
|
options[:chefignore] = true
|
@@ -307,152 +297,105 @@ module Berkshelf
|
|
307
297
|
|
308
298
|
::Berkshelf::InitGenerator.new([path], options).invoke_all
|
309
299
|
|
310
|
-
::Berkshelf.formatter.msg
|
300
|
+
::Berkshelf.formatter.msg 'Successfully initialized'
|
311
301
|
end
|
312
|
-
tasks["init"].options = Berkshelf::InitGenerator.class_options
|
313
302
|
|
314
303
|
method_option :berksfile,
|
315
304
|
type: :string,
|
316
|
-
default:
|
317
|
-
desc:
|
318
|
-
aliases:
|
319
|
-
banner:
|
320
|
-
desc
|
305
|
+
default: Berkshelf::DEFAULT_FILENAME,
|
306
|
+
desc: 'Path to a Berksfile to operate off of.',
|
307
|
+
aliases: '-b',
|
308
|
+
banner: 'PATH'
|
309
|
+
desc 'list', 'List all cookbooks (and dependencies) specified in the Berksfile'
|
321
310
|
def list
|
322
|
-
berksfile =
|
311
|
+
berksfile = Berksfile.from_file(options[:berksfile])
|
312
|
+
sources = Berkshelf.ui.mute { berksfile.resolve(berksfile.sources)[:solution] }.sort
|
323
313
|
|
324
|
-
|
325
|
-
|
326
|
-
|
314
|
+
if sources.empty?
|
315
|
+
Berkshelf.formatter.msg 'There are no cookbooks installed by your Berksfile'
|
316
|
+
else
|
317
|
+
Berkshelf.formatter.msg 'Cookbooks installed by your Berksfile:'
|
318
|
+
print_list(sources)
|
327
319
|
end
|
328
320
|
end
|
329
321
|
|
330
322
|
method_option :berksfile,
|
331
323
|
type: :string,
|
332
|
-
default:
|
324
|
+
default: Berkshelf::DEFAULT_FILENAME,
|
333
325
|
desc: "Path to a Berksfile to operate off of.",
|
334
326
|
aliases: "-b",
|
335
327
|
banner: "PATH"
|
336
|
-
desc "show COOKBOOK", "Display
|
328
|
+
desc "show [COOKBOOK]", "Display name, author, copyright, and dependency information about a cookbook"
|
337
329
|
def show(name)
|
338
|
-
berksfile =
|
339
|
-
source = berksfile.find(name)
|
330
|
+
berksfile = Berksfile.from_file(options[:berksfile])
|
340
331
|
|
341
332
|
cookbook = Berkshelf.ui.mute {
|
342
|
-
berksfile.resolve(
|
333
|
+
berksfile.resolve(berksfile.find(name))[:solution].first
|
343
334
|
}
|
344
335
|
|
345
|
-
raise CookbookNotFound, "Cookbook '#{name}'
|
346
|
-
Berkshelf.formatter.msg(cookbook.path)
|
347
|
-
end
|
336
|
+
raise CookbookNotFound, "Cookbook '#{name}' is not installed by your Berksfile" unless cookbook
|
348
337
|
|
349
|
-
|
350
|
-
type: :string,
|
351
|
-
desc: 'The version of the cookbook to display.',
|
352
|
-
aliases: '-v'
|
353
|
-
desc "info [COOKBOOK]", "Display name, author, copyright, and dependency information about a cookbook"
|
354
|
-
def info(name)
|
355
|
-
if options[:version]
|
356
|
-
cookbook = Berkshelf.cookbook_store.cookbook(name, options[:version])
|
357
|
-
else
|
358
|
-
cookbook = Berkshelf.cookbook_store.cookbooks(name).sort_by(&:version).last
|
359
|
-
end
|
360
|
-
|
361
|
-
raise CookbookNotFound, "Cookbook '#{name}' was not installed by your Berksfile" if cookbook.nil?
|
362
|
-
Berkshelf.formatter.msg(cookbook.pretty_print)
|
338
|
+
Berkshelf.formatter.show(cookbook)
|
363
339
|
end
|
364
340
|
|
365
341
|
method_option :berksfile,
|
366
342
|
type: :string,
|
367
|
-
default:
|
368
|
-
desc:
|
369
|
-
aliases:
|
370
|
-
banner:
|
371
|
-
desc
|
343
|
+
default: Berkshelf::DEFAULT_FILENAME,
|
344
|
+
desc: 'Path to a Berksfile to operate off of.',
|
345
|
+
aliases: '-b',
|
346
|
+
banner: 'PATH'
|
347
|
+
desc 'contingent COOKBOOK', 'List all cookbooks that depend on the given cookbook'
|
372
348
|
def contingent(name)
|
373
|
-
berksfile =
|
349
|
+
berksfile = Berksfile.from_file(options[:berksfile])
|
374
350
|
|
375
|
-
Berkshelf.
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
351
|
+
sources = Berkshelf.ui.mute { berksfile.resolve(berksfile.sources)[:solution] }.sort
|
352
|
+
dependencies = sources.select { |cookbook| cookbook.dependencies.include?(name) }
|
353
|
+
|
354
|
+
if dependencies.empty?
|
355
|
+
Berkshelf.formatter.msg "There are no cookbooks contingent upon '#{name}' defined in this Berksfile"
|
356
|
+
else
|
357
|
+
Berkshelf.formatter.msg "Cookbooks in this Berksfile contingent upon #{name}:"
|
358
|
+
print_list(dependencies)
|
380
359
|
end
|
381
360
|
end
|
382
361
|
|
383
362
|
method_option :berksfile,
|
384
363
|
type: :string,
|
385
364
|
default: File.join(Dir.pwd, Berkshelf::DEFAULT_FILENAME),
|
386
|
-
desc:
|
387
|
-
aliases:
|
388
|
-
banner:
|
365
|
+
desc: 'Path to a Berksfile to operate off of.',
|
366
|
+
aliases: '-b',
|
367
|
+
banner: 'PATH'
|
389
368
|
method_option :output,
|
390
369
|
type: :string,
|
391
370
|
default: Dir.pwd,
|
392
|
-
desc:
|
393
|
-
aliases:
|
394
|
-
banner:
|
371
|
+
desc: 'Path to output the tarball',
|
372
|
+
aliases: '-o',
|
373
|
+
banner: 'PATH'
|
395
374
|
method_option :skip_dependencies,
|
396
375
|
type: :boolean,
|
397
|
-
desc:
|
376
|
+
desc: 'Skip packaging dependent cookbook(s).',
|
398
377
|
default: false
|
399
378
|
method_option :ignore_chefignore,
|
400
379
|
type: :boolean,
|
401
|
-
desc:
|
380
|
+
desc: 'Do not apply the chefignore to the packaged contents',
|
402
381
|
default: false
|
403
|
-
desc
|
382
|
+
desc 'package [COOKBOOK]', 'Package a cookbook (and dependencies) as a tarball'
|
404
383
|
def package(name = nil)
|
405
384
|
berksfile = Berkshelf::Berksfile.from_file(options[:berksfile])
|
406
385
|
berksfile.package(name, options)
|
407
386
|
end
|
408
387
|
|
409
|
-
desc
|
388
|
+
desc 'version', 'Display version and copyright information'
|
410
389
|
def version
|
411
390
|
Berkshelf.formatter.msg version_header
|
412
391
|
Berkshelf.formatter.msg "\n"
|
413
392
|
Berkshelf.formatter.msg license
|
414
393
|
end
|
415
394
|
|
416
|
-
|
417
|
-
type: :boolean,
|
418
|
-
desc: "Creates a Thorfile with Foodcritic support to lint test your cookbook"
|
419
|
-
method_option :chef_minitest,
|
420
|
-
type: :boolean,
|
421
|
-
desc: "Creates chef-minitest support files and directories, adds minitest-handler cookbook to run_list of Vagrantfile"
|
422
|
-
method_option :scmversion,
|
423
|
-
type: :boolean,
|
424
|
-
desc: "Creates a Thorfile with SCMVersion support to manage versions for continuous integration"
|
425
|
-
method_option :license,
|
426
|
-
type: :string,
|
427
|
-
desc: "License for cookbook (apachev2, gplv2, gplv3, mit, reserved)",
|
428
|
-
aliases: "-L"
|
429
|
-
method_option :maintainer,
|
430
|
-
type: :string,
|
431
|
-
desc: "Name of cookbook maintainer",
|
432
|
-
aliases: "-m"
|
433
|
-
method_option :maintainer_email,
|
434
|
-
type: :string,
|
435
|
-
desc: "Email address of cookbook maintainer",
|
436
|
-
aliases: "-e"
|
437
|
-
method_option :no_bundler,
|
438
|
-
type: :boolean,
|
439
|
-
desc: "Skips generation of a Gemfile and other Bundler specific support"
|
440
|
-
method_option :vagrant,
|
441
|
-
type: :boolean,
|
442
|
-
hide: true
|
443
|
-
method_option :skip_vagrant,
|
444
|
-
type: :boolean,
|
445
|
-
desc: "Skips adding a Vagrantfile and adding supporting gems to the Gemfile"
|
446
|
-
method_option :git,
|
447
|
-
type: :boolean,
|
448
|
-
hide: true
|
449
|
-
method_option :skip_git,
|
450
|
-
type: :boolean,
|
451
|
-
desc: "Skips adding a .gitignore and running git init in the cookbook directory"
|
452
|
-
desc "cookbook NAME", "Create a skeleton for a new cookbook"
|
395
|
+
desc 'cookbook NAME', 'Create a skeleton for a new cookbook'
|
453
396
|
def cookbook(name)
|
454
|
-
Berkshelf.formatter.deprecation
|
455
|
-
Berkshelf.formatter.deprecation
|
397
|
+
Berkshelf.formatter.deprecation '--git is now the default' if options[:git]
|
398
|
+
Berkshelf.formatter.deprecation '--vagrant is now the default' if options[:vagrant]
|
456
399
|
|
457
400
|
unless Config.instance.valid?
|
458
401
|
raise InvalidConfiguration.new(Config.instance.errors)
|
@@ -460,6 +403,7 @@ module Berkshelf
|
|
460
403
|
|
461
404
|
::Berkshelf::CookbookGenerator.new([File.join(Dir.pwd, name), name], options).invoke_all
|
462
405
|
end
|
406
|
+
tasks['cookbook'].options = Berkshelf::CookbookGenerator.class_options
|
463
407
|
|
464
408
|
private
|
465
409
|
|
@@ -470,10 +414,16 @@ module Berkshelf
|
|
470
414
|
def license
|
471
415
|
File.read(Berkshelf.root.join('LICENSE'))
|
472
416
|
end
|
473
|
-
end
|
474
|
-
end
|
475
417
|
|
476
|
-
|
477
|
-
|
418
|
+
# Print a list of the given cookbooks. This is used by various
|
419
|
+
# methods like {list} and {contingent}.
|
420
|
+
#
|
421
|
+
# @param [Array<CachedCookbook>] cookbooks
|
422
|
+
#
|
423
|
+
def print_list(cookbooks)
|
424
|
+
Array(cookbooks).each do |cookbook|
|
425
|
+
Berkshelf.formatter.msg " * #{cookbook.cookbook_name} (#{cookbook.version})"
|
426
|
+
end
|
427
|
+
end
|
428
|
+
end
|
478
429
|
end
|
479
|
-
|