Sha256: 09617aef4a38b58c0f6435f4a55847848bc6ac40318cd32e2230217f6350c9d9

Contents?: true

Size: 1.31 KB

Versions: 8

Compression:

Stored size: 1.31 KB

Contents

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

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

        def call(env)
          if provision_disabled?(env)
            return @app.call(env)
          end

          unless berkshelf_enabled?(env)
            return @app.call(env)
          end

          if chef_client?(env)
            upload(env)
          end

          @app.call(env)
        rescue Berkshelf::BerkshelfError => e
          raise Berkshelf::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
                },
                force: true,
                freeze: false
              )
            end
          end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
vagrant-berkshelf-2.0.0.rc2 lib/berkshelf/vagrant/action/upload.rb
vagrant-berkshelf-2.0.0.rc1 lib/berkshelf/vagrant/action/upload.rb
vagrant-berkshelf-1.3.7 lib/berkshelf/vagrant/action/upload.rb
vagrant-berkshelf-1.3.6 lib/berkshelf/vagrant/action/upload.rb
vagrant-berkshelf-1.3.5 lib/berkshelf/vagrant/action/upload.rb
vagrant-berkshelf-1.4.0.dev1 lib/berkshelf/vagrant/action/upload.rb
vagrant-berkshelf-1.3.4 lib/berkshelf/vagrant/action/upload.rb
vagrant-berkshelf-1.3.3 lib/berkshelf/vagrant/action/upload.rb