Class: VagrantHiera::Middleware::Prepare

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-hiera/middleware/prepare.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ Prepare

Returns a new instance of Prepare.



5
6
7
8
# File 'lib/vagrant-hiera/middleware/prepare.rb', line 5

def initialize(app, env)
  @app = app
  @env = env
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/vagrant-hiera/middleware/prepare.rb', line 10

def call(env)
  @env = env
  if @env[:vm].config.hiera.set?
    create_shared_folders
  end
  @app.call(env)
end

#create_shared_foldersObject



18
19
20
21
22
23
# File 'lib/vagrant-hiera/middleware/prepare.rb', line 18

def create_shared_folders
  @env[:ui].info I18n.t('vagrant.plugins.hiera.middleware.prepare.shared_folders')
  folders = [{:name => 'vagrant-hiera-config', :hostpath => @env[:vm].config.hiera.config_path},
             {:name => 'vagrant-hiera-data', :hostpath => @env[:vm].config.hiera.data_path}]
  @env[:vm].driver.share_folders(folders)
end