Class: Vagrant::Action::Builtin::ConfigValidate

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant/action/builtin/config_validate.rb

Overview

This class validates the configuration and raises an exception if there are any validation errors.

Instance Method Summary collapse

Constructor Details

#initialize(app, env) ⇒ ConfigValidate

Returns a new instance of ConfigValidate.



12
13
14
# File 'lib/vagrant/action/builtin/config_validate.rb', line 12

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

Instance Method Details

#call(env) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/vagrant/action/builtin/config_validate.rb', line 16

def call(env)
  if !env.key?(:config_validate) || env[:config_validate]
    errors = env[:machine].config.validate(env[:machine], env[:ignore_provider])

    if errors && !errors.empty?
      raise Errors::ConfigInvalid,
        errors: Util::TemplateRenderer.render(
          "config/validation_failed",
          errors: errors)
    end
  end

  @app.call(env)
end