Class: Berkshelf::Vagrant::Action::Validate
- Inherits:
-
Object
- Object
- Berkshelf::Vagrant::Action::Validate
- Defined in:
- lib/berkshelf/vagrant/action/validate.rb
Overview
As of Vagrant 1.0.5 it is not possible to validate configuration values of a configuraiton that was not explicitly described in a Vagrant::Config.run block.
In our case we want some values set for our middleware stacks even if the user does not explicitly set values for settings in ‘config.berkshelf`.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ Validate
constructor
A new instance of Validate.
Constructor Details
#initialize(app, env) ⇒ Validate
Returns a new instance of Validate.
12 13 14 |
# File 'lib/berkshelf/vagrant/action/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 |
# File 'lib/berkshelf/vagrant/action/validate.rb', line 16 def call(env) recorder = ::Vagrant::Config::ErrorRecorder.new env[:vm].config.berkshelf.validate(env[:vm].env, recorder) unless recorder.errors.empty? raise ::Vagrant::Errors::ConfigValidationFailed, messages: ::Vagrant::Util::TemplateRenderer.render("config/validation_failed", errors: { berkshelf: recorder }) end @app.call(env) end |