Sha256: b129a8d1e0db36d6450093ddc520f669751803d22ae7b26544399a7f879c9c72

Contents?: true

Size: 1.11 KB

Versions: 7

Compression:

Stored size: 1.11 KB

Contents

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

        def initialize(app, env)
          @app       = app
          @berksfile = Berksfile.from_file(env[:vm].config.berkshelf.berksfile_path)
        end

        def call(env)
          if Berkshelf::Vagrant.chef_client?(env[:vm].config)
            upload(env)
          end

          @app.call(env)
        end

        private

          def upload(env)
            Berkshelf::Vagrant.provisioners(:chef_client, env[:vm].config).each do |provisioner|
              Berkshelf.formatter.msg "uploading cookbooks to '#{provisioner.config.chef_server_url}'"
              berksfile.upload(
                server_url: provisioner.config.chef_server_url,
                client_name: Berkshelf::Config.instance.chef.node_name,
                client_key: Berkshelf::Config.instance.chef.client_key,
                ssl: {
                  verify: Berkshelf::Config.instance.ssl.verify
                }
              )
            end
          end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

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