Class: Chef::Knife::PinningsWipe
- Inherits:
-
Chef::Knife
- Object
- Chef::Knife
- Chef::Knife::PinningsWipe
- Defined in:
- lib/chef/knife/pinnings_wipe.rb
Overview
This class implements knife pinnings wipe [‘environment’] [‘cookbook_regex’]
Instance Method Summary collapse
Instance Method Details
#run ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/chef/knife/pinnings_wipe.rb', line 22 def run if name_args.length < 1 ui.fatal('You must specify an environment to wipe (and optionally a cookbook regex)') exit 255 end cookbook_regex = name_args[1] || '.*' environment = Environment.load(name_args[0]) display_environments([environment], cookbook_regex) ui.msg('') ui.confirm("Do you want to wipe cookbook constraints in #{environment.name}") ui.msg('') wipe(environment, cookbook_regex) end |
#wipe(environment, cookbook_regex) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/chef/knife/pinnings_wipe.rb', line 37 def wipe(environment, cookbook_regex) environment.cookbook_versions.delete_if do |name, _| name =~ /#{cookbook_regex}/ end environment.save ui.msg("Cookbook constraints wiped from #{environment.name}") end |