Sha256: fcbd222b33940de49d112e746f508f596e929ca1e9e42d3a8faebe78df3751e0

Contents?: true

Size: 1.54 KB

Versions: 35

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

require 'logging'
require 'bolt/result'
require 'bolt/shell'
require 'bolt/transport/base'

module Bolt
  module Transport
    # A simple transport has a single connection per target and delegates its
    # operation to a target-specific shell.
    class Simple < Base
      def with_connection(_target)
        raise NotImplementedError, "with_connection() must be implemented by the transport class"
      end

      def connected?(target)
        with_connection(target) { true }
      rescue Bolt::Node::ConnectError
        false
      end

      def run_command(target, command, options = {}, position = [])
        with_connection(target) do |conn|
          conn.shell.run_command(command, options, position)
        end
      end

      def upload(target, source, destination, options = {})
        with_connection(target) do |conn|
          conn.shell.upload(source, destination, options)
        end
      end

      def download(target, source, destination, options = {})
        with_connection(target) do |conn|
          conn.shell.download(source, destination, options)
        end
      end

      def run_script(target, script, arguments, options = {}, position = [])
        with_connection(target) do |conn|
          conn.shell.run_script(script, arguments, options, position)
        end
      end

      def run_task(target, task, arguments, options = {}, position = [])
        with_connection(target) do |conn|
          conn.shell.run_task(task, arguments, options, position)
        end
      end
    end
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
bolt-3.17.0 lib/bolt/transport/simple.rb
bolt-3.16.1 lib/bolt/transport/simple.rb
bolt-3.16.0 lib/bolt/transport/simple.rb
bolt-3.15.0 lib/bolt/transport/simple.rb
bolt-3.14.1 lib/bolt/transport/simple.rb
bolt-3.13.0 lib/bolt/transport/simple.rb
bolt-3.12.0 lib/bolt/transport/simple.rb
bolt-3.11.0 lib/bolt/transport/simple.rb
bolt-3.10.0 lib/bolt/transport/simple.rb
bolt-3.9.2 lib/bolt/transport/simple.rb
bolt-3.9.1 lib/bolt/transport/simple.rb
bolt-3.9.0 lib/bolt/transport/simple.rb
bolt-3.8.1 lib/bolt/transport/simple.rb
bolt-3.8.0 lib/bolt/transport/simple.rb
bolt-3.7.1 lib/bolt/transport/simple.rb
bolt-3.7.0 lib/bolt/transport/simple.rb
bolt-3.6.1 lib/bolt/transport/simple.rb
bolt-3.6.0 lib/bolt/transport/simple.rb
bolt-3.5.0 lib/bolt/transport/simple.rb
bolt-3.4.0 lib/bolt/transport/simple.rb