Class: VagrantPlugins::Berkshelf::Action::Clean

Inherits:
Base
  • Object
show all
Defined in:
lib/vagrant-berkshelf/action/clean.rb

Instance Method Summary collapse

Methods inherited from Base

clean, #initialize, provision, setup

Methods included from Helpers

#berks, #berks_bin, #berkshelf_enabled?, #chef_client?, #chef_solo?, #chef_zero?, #datafile_path, #provision_enabled?, #provisioners, #with_clean_env

Constructor Details

This class inherits a constructor from VagrantPlugins::Berkshelf::Action::Base

Instance Method Details

#call(env) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/vagrant-berkshelf/action/clean.rb', line 7

def call(env)
  if !berkshelf_enabled?(env)
    @logger.info "Berkshelf disabled, skipping"
    return @app.call(env)
  end

  env[:machine].ui.info "Running cleanup tasks for 'berkshelf'..."

  if env[:berkshelf].shelf
    if File.exist?(env[:berkshelf].shelf)
      FileUtils.rm_rf(env[:berkshelf].shelf)
      env[:berkshelf].shelf = nil
    else
      @logger.warn "The Berkshelf shelf did not exist for cleanup!"
    end
  end

  @app.call(env)
end