Class: VagrantPlugins::DNS::Action::SetupEnv

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-dns/action/setup_env.rb

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ SetupEnv

Returns a new instance of SetupEnv.



5
6
7
# File 'lib/vagrant-dns/action/setup_env.rb', line 5

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

Instance Method Details

#call(env) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/vagrant-dns/action/setup_env.rb', line 9

def call(env)
  unless env[:machine].config.dns.enabled
    return @app.call(env)
  end

  env[:dns].tmp_path    = File.join(env[:tmp_path], DNS.namespace)
  env[:dns].daemon_path = File.join(env[:dns].tmp_path, "daemon")
  env[:dns].config_file = File.join(env[:dns].tmp_path, "config")
  env[:dns].dns_server  = DNSServer.new \
                            dir:    env[:dns].daemon_path,
                            config: env[:dns].config_file

  @app.call(env)
end