Sha256: 72e4914b0bbe2a2c0ed33a7212c636b9b8d480c0c47af5d122e852680e91efc4

Contents?: true

Size: 807 Bytes

Versions: 1

Compression:

Stored size: 807 Bytes

Contents

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

1 entries across 1 versions & 1 rubygems

Version Path
dkdeploy-core-9.2.1 lib/dkdeploy/interaction_handler/password.rb