Class: Rundock::Configure
Constant Summary collapse
- CONFIGURE_TYPE =
%i[ssh]
- CONFIGURE_SSH_OPTIONS =
%i[port user keys passphrase ssh_config]
- CONFIGURE_SSH_OPTIONS_QUESTION =
[ 'ssh port', 'user name', 'private key path', 'private key passphrase', 'ssh config file path' ]
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options) ⇒ Configure
constructor
A new instance of Configure.
- #ssh ⇒ Object
Constructor Details
#initialize(options) ⇒ Configure
Returns a new instance of Configure.
27 28 29 |
# File 'lib/rundock/configure.rb', line 27 def initialize() @options = end |
Class Method Details
.start(options) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/rundock/configure.rb', line 17 def start() Logger.debug 'Starting Configure:' configure = self.new() CONFIGURE_TYPE.each do |type| configure.send(type) if [type] end end |
Instance Method Details
#ssh ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/rundock/configure.rb', line 31 def ssh cli = HighLine.new ssh_opts = { paranoid: false } CONFIGURE_SSH_OPTIONS.each_with_index do |opt, i| ans = if opt == :port cli.ask("#{CONFIGURE_SSH_OPTIONS_QUESTION[i]}:", Integer) { |q| q.in = 0..65535 } elsif opt == :user cli.ask("#{CONFIGURE_SSH_OPTIONS_QUESTION[i]}:") { |q| q.default = ENV['USER'] } elsif opt == :keys [cli.ask("#{CONFIGURE_SSH_OPTIONS_QUESTION[i]}:") { |q| q.default = '~/.ssh/id_rsa' }] elsif opt == :passphrase cli.ask("#{CONFIGURE_SSH_OPTIONS_QUESTION[i]}:") { |q| q.echo = '*' } elsif opt == :ssh_config cli.ask("#{CONFIGURE_SSH_OPTIONS_QUESTION[i]}:") { |q| q.default = '~/.ssh/config' } else cli.ask("#{CONFIGURE_SSH_OPTIONS_QUESTION[i]}:") end ssh_opts[opt] = ans unless ans.blank? end YAML.dump(ssh_opts, File.open(@options[:ssh_config_path], 'w')) end |