Sha256: 5ee4c86a61a17743aad97ef4bd8e3f812a6742edfc6219e6e24749a3da04ac93

Contents?: true

Size: 1015 Bytes

Versions: 3

Compression:

Stored size: 1015 Bytes

Contents

module Berkshelf::Vagrant
  module Action
    # @author Jamie Winsor <reset@riotgames.com>
    class Upload
      include Berkshelf::Vagrant::EnvHelpers

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

      def call(env)
        if chef_client?(env)
          upload(env)
        end

        @app.call(env)
      rescue Berkshelf::BerkshelfError => e
        raise VagrantWrapperError.new(e)
      end

      private

        def upload(env)
          provisioners(:chef_client, env).each do |provisioner|
            env[:berkshelf].ui.info "Uploading cookbooks to '#{provisioner.config.chef_server_url}'"
            env[:berkshelf].berksfile.upload(
              server_url: provisioner.config.chef_server_url,
              client_name: env[:berkshelf].config.chef.node_name,
              client_key: env[:berkshelf].config.chef.client_key,
              ssl: {
                verify: env[:berkshelf].config.ssl.verify
              }
            )
          end
        end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
berkshelf-vagrant-1.0.4 lib/berkshelf/vagrant/action/upload.rb
berkshelf-vagrant-1.0.3 lib/berkshelf/vagrant/action/upload.rb
berkshelf-vagrant-1.0.0.rc1 lib/berkshelf/vagrant/action/upload.rb