Class: Dkdeploy::InteractionHandler::Password

Inherits:
Object
  • Object
show all
Defined in:
lib/dkdeploy/interaction_handler/password.rb

Overview

Interaction handler for password

Instance Method Summary collapse

Constructor Details

#initialize(password) ⇒ Password

Interaction handler for password



10
11
12
# File 'lib/dkdeploy/interaction_handler/password.rb', line 10

def initialize(password)
  @password = password
end

Instance Method Details

#on_data(_command, _stream_name, data, channel) ⇒ Object

Method to send password to terminal

Parameters:

  • _command (SSHKit::Command)
  • _stream_name (Symbol)
  • data (String)
  • channel (Net::SSH::Connection::Channel)


20
21
22
23
24
25
26
27
# File 'lib/dkdeploy/interaction_handler/password.rb', line 20

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