Sha256: 72001e810da3c29ee50223a0fe47c87d6335d0bfff228811f1a36f70556d89f4

Contents?: true

Size: 1022 Bytes

Versions: 9

Compression:

Stored size: 1022 Bytes

Contents

module Berkshelf
  module Vagrant
    module Action
      # @author Jamie Winsor <jamie@vialstudios.com>
      #
      # 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`.
      class Validate
        def initialize(app, env)
          @app = app
        end

        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
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
berkshelf-1.0.0.rc1 lib/berkshelf/vagrant/action/validate.rb
berkshelf-0.6.0.beta4 lib/berkshelf/vagrant/action/validate.rb
berkshelf-0.6.0.beta3 lib/berkshelf/vagrant/action/validate.rb
berkshelf-0.6.0.beta2 lib/berkshelf/vagrant/action/validate.rb
berkshelf-0.5.1 lib/berkshelf/vagrant/action/validate.rb
berkshelf-0.6.0.beta1 lib/berkshelf/vagrant/action/validate.rb
berkshelf-0.5.0 lib/berkshelf/vagrant/action/validate.rb
berkshelf-0.5.0.rc4 lib/berkshelf/vagrant/action/validate.rb
berkshelf-0.5.0.rc3 lib/berkshelf/vagrant/action/validate.rb