Sha256: 3747425c0a54af71a98e15956476a31b4c9eeb33961dde22850825a82b784a1b

Contents?: true

Size: 838 Bytes

Versions: 6

Compression:

Stored size: 838 Bytes

Contents

# frozen_string_literal: true

module Dkdeploy
  module InteractionHandler
    # Interaction handler for password
    class Password
      # Interaction handler for password
      #
      # @attr [String] password The password to send to terminal
      def initialize(password)
        @password = password
      end

      # Method to send password to terminal
      #
      # @param [SSHKit::Command] _command
      # @param [Symbol] _stream_name
      # @param [String] data
      # @param [Net::SSH::Connection::Channel] channel
      def on_data(_command, _stream_name, data, channel)
        if data =~ /.*password.*/i
          channel.send_data("#{@password}\n")
        else
          channel.close
          raise 'Unexpected data from stream. Can not send password to undefined stream.'
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dkdeploy-core-10.0.0 lib/dkdeploy/interaction_handler/password.rb
dkdeploy-core-9.3.1 lib/dkdeploy/interaction_handler/password.rb
dkdeploy-core-9.2.4 lib/dkdeploy/interaction_handler/password.rb
dkdeploy-core-9.3.0 lib/dkdeploy/interaction_handler/password.rb
dkdeploy-core-9.2.3 lib/dkdeploy/interaction_handler/password.rb
dkdeploy-core-9.2.2 lib/dkdeploy/interaction_handler/password.rb