Sha256: 5913f003dbfe1f2a1622013ecaffbe3f48b8ea074341839c98ad5dda2dcb0b81

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

module Berkshelf
  module Vagrant
    module Action
      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

3 entries across 3 versions & 1 rubygems

Version Path
vagrant-berkshelf-2.0.1 lib/berkshelf/vagrant/action/upload.rb
vagrant-berkshelf-2.0.0.rc4 lib/berkshelf/vagrant/action/upload.rb
vagrant-berkshelf-2.0.0.rc3 lib/berkshelf/vagrant/action/upload.rb