Sha256: ae4041e3d9bf46a846d75f0b4ad540cba2f9d658cf3767b6012ee9a99f8e3b38

Contents?: true

Size: 1.33 KB

Versions: 3

Compression:

Stored size: 1.33 KB

Contents

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

        def initialize(app, env)
          @app = app
          @node_name  = env[:global_config].berkshelf.node_name
          @client_key = env[:global_config].berkshelf.client_key
          @ssl_verify = env[:global_config].berkshelf.ssl_verify
          @berksfile  = Berksfile.from_file(env[:global_config].berkshelf.berksfile_path)
        end

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

          @app.call(env)
        end

        private

          def upload(env)
            Berkshelf::Vagrant.provisioners(:chef_client, env[:global_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: self.node_name,
                client_key: self.client_key,
                ssl: {
                  verify: self.ssl_verify
                }
              )
            end
          end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
berkshelf-0.6.0.beta1 lib/berkshelf/vagrant/action/upload.rb
berkshelf-0.5.0 lib/berkshelf/vagrant/action/upload.rb
berkshelf-0.5.0.rc4 lib/berkshelf/vagrant/action/upload.rb