caterer 0.10.0 → 0.11.0

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.
@@ -12,7 +12,7 @@ module Caterer
12
12
 
13
13
  def call(env)
14
14
 
15
- if env[:provisioner].is_a? Caterer::Provisioner::ChefSolo
15
+ if env[:provisioner].is_a? Caterer::Provisioner::ChefSolo or env[:force_berks_clean]
16
16
  ::Berkshelf.formatter.msg "cleaning Caterer's shelf"
17
17
  FileUtils.remove_dir(shelf, fore: true)
18
18
  end
@@ -22,13 +22,14 @@ module Caterer
22
22
 
23
23
  if env[:provisioner].is_a? Caterer::Provisioner::ChefSolo
24
24
  configure_cookbooks_path(env[:provisioner])
25
- if needs_update?
26
- ::Berkshelf.formatter.msg "installing cookbooks..."
27
- install(env)
28
- update_cache
29
- else
30
- ::Berkshelf.formatter.msg "up-to-date"
31
- end
25
+ end
26
+
27
+ if needs_update? or env[:force_berks_install]
28
+ ::Berkshelf.formatter.msg "installing cookbooks..."
29
+ install(env)
30
+ update_cache
31
+ else
32
+ ::Berkshelf.formatter.msg "up-to-date"
32
33
  end
33
34
 
34
35
  @app.call(env)
@@ -38,8 +39,9 @@ module Caterer
38
39
 
39
40
  def shelf_digest
40
41
  berks_content = ::File.read(berksfile.filepath) rescue nil
42
+ lock_content = ::File.read("#{berksfile.filepath}.lock") rescue nil
41
43
  shelf_content = ::Dir.glob("#{shelf}/[^\.]*")
42
- ::Digest::MD5.hexdigest("#{berks_content}/#{shelf_content}")
44
+ ::Digest::MD5.hexdigest("#{berks_content}/#{lock_content}/#{shelf_content}")
43
45
  end
44
46
 
45
47
  def needs_update?
@@ -27,6 +27,8 @@ module Caterer
27
27
 
28
28
  def init!
29
29
 
30
+ Caterer.commands.register(:berks) { Caterer::Command::Berks }
31
+
30
32
  Caterer.config_keys.register(:berkshelf) { Config::Berkshelf }
31
33
 
32
34
  [ :provision, :up ].each do |action|
@@ -35,6 +37,14 @@ module Caterer
35
37
 
36
38
  Caterer.actions[:clean].use clean
37
39
 
40
+ Caterer.actions.register(:berks_install) do
41
+ install
42
+ end
43
+
44
+ Caterer.actions.register(:berks_clean) do
45
+ clean
46
+ end
47
+
38
48
  end
39
49
 
40
50
  end
@@ -0,0 +1,43 @@
1
+ module Caterer
2
+ module Command
3
+ class Berks < Vli::Command::Base
4
+
5
+ def execute
6
+ options = {}
7
+ opts = OptionParser.new do |opts|
8
+ opts.banner = "Usage: cater berks install|update|clean"
9
+ end
10
+
11
+ # Parse the options
12
+ argv = parse_options(opts)
13
+ if not argv.any?
14
+ safe_puts(opts.help)
15
+ return
16
+ end
17
+
18
+ case argv.first
19
+ when 'install'
20
+ run_action :berks_install
21
+ when 'update'
22
+ run_action :berks_install, {force_berks_install: true}
23
+ when 'clean'
24
+ run_action :berks_clean, {force_berks_clean: true}
25
+ else
26
+ safe_puts(opts.help)
27
+ end
28
+
29
+ 0
30
+ end
31
+
32
+ def run_action(name, options=nil)
33
+ options = {
34
+ :ui => @env.ui,
35
+ :config => @env.config
36
+ }.merge(options || {})
37
+
38
+ @env.action_runner.run(name, options)
39
+ end
40
+
41
+ end
42
+ end
43
+ end
@@ -2,6 +2,7 @@ module Caterer
2
2
  module Command
3
3
  autoload :Base, 'caterer/command/base'
4
4
  autoload :Clean, 'caterer/command/clean'
5
+ autoload :Berks, 'caterer/command/berks'
5
6
  autoload :Bootstrap, 'caterer/command/bootstrap'
6
7
  autoload :Lock, 'caterer/command/lock'
7
8
  autoload :Provision, 'caterer/command/provision'
@@ -1,3 +1,3 @@
1
1
  module Caterer
2
- VERSION = "0.10.0"
2
+ VERSION = "0.11.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caterer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -214,6 +214,7 @@ files:
214
214
  - lib/caterer/cli.rb
215
215
  - lib/caterer/command.rb
216
216
  - lib/caterer/command/base.rb
217
+ - lib/caterer/command/berks.rb
217
218
  - lib/caterer/command/bootstrap.rb
218
219
  - lib/caterer/command/clean.rb
219
220
  - lib/caterer/command/lock.rb
@@ -262,7 +263,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
262
263
  version: '0'
263
264
  segments:
264
265
  - 0
265
- hash: -4253641693695072200
266
+ hash: -4401693944212608239
266
267
  required_rubygems_version: !ruby/object:Gem::Requirement
267
268
  none: false
268
269
  requirements:
@@ -271,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
271
272
  version: '0'
272
273
  segments:
273
274
  - 0
274
- hash: -4253641693695072200
275
+ hash: -4401693944212608239
275
276
  requirements: []
276
277
  rubyforge_project:
277
278
  rubygems_version: 1.8.23