Sha256: 7a7b24db12e006d88708aea370b18be3de38bab5f4408fbece5b75ad635095de

Contents?: true

Size: 1.64 KB

Versions: 16

Compression:

Stored size: 1.64 KB

Contents

module VagrantPlugins
  module FileUpload
    class Provisioner < Vagrant.plugin("2", :provisioner)
      def provision
        @machine.communicate.tap do |comm|
          source = File.expand_path(config.source, @machine.env.cwd)
          destination = expand_guest_path(config.destination)

          # If the source is a directory determine if any path modifications
          # need to be applied to the source for upload behavior. If the original
          # source value ends with a "." or if the original source does not end
          # with a "." but the original destination ends with a file separator
          # then append a "." character to the new source. This ensures that
          # the contents of the directory are uploaded to the destination and
          # not folder itself.
          if File.directory?(source)
            if config.source.end_with?(".") ||
                (!config.destination.end_with?(File::SEPARATOR) &&
                !config.source.end_with?("#{File::SEPARATOR}."))
              source = File.join(source, ".")
            end
          end

          @machine.ui.detail(I18n.t("vagrant.actions.vm.provision.file.locations",
                                   src: config.source, dst: config.destination))
          # now upload the file
          comm.upload(source, destination)
        end
      end

      private

      # Expand the guest path if the guest has the capability
      def expand_guest_path(destination)
        if machine.guest.capability?(:shell_expand_guest_path)
          machine.guest.capability(:shell_expand_guest_path, destination)
        else
          destination
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
vagrant-unbundled-2.3.6.0 plugins/provisioners/file/provisioner.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/provisioners/file/provisioner.rb
vagrant-unbundled-2.3.3.0 plugins/provisioners/file/provisioner.rb
vagrant-unbundled-2.3.2.0 plugins/provisioners/file/provisioner.rb
vagrant-unbundled-2.2.19.0 plugins/provisioners/file/provisioner.rb
vagrant-unbundled-2.2.18.0 plugins/provisioners/file/provisioner.rb
vagrant-unbundled-2.2.16.0 plugins/provisioners/file/provisioner.rb
vagrant-unbundled-2.2.14.0 plugins/provisioners/file/provisioner.rb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/plugins/provisioners/file/provisioner.rb
vagrant-unbundled-2.2.10.0 plugins/provisioners/file/provisioner.rb
vagrant-unbundled-2.2.9.0 plugins/provisioners/file/provisioner.rb
vagrant-unbundled-2.2.8.0 plugins/provisioners/file/provisioner.rb
vagrant-unbundled-2.2.7.0 plugins/provisioners/file/provisioner.rb
vagrant-unbundled-2.2.6.2 plugins/provisioners/file/provisioner.rb
vagrant-unbundled-2.2.6.1 plugins/provisioners/file/provisioner.rb
vagrant-unbundled-2.2.6.0 plugins/provisioners/file/provisioner.rb