Module: Kontena::Plugin::Upcloud::Prompts::Create

Included in:
Master::CreateCommand, Nodes::CreateCommand
Defined in:
lib/kontena/plugin/upcloud/prompts.rb

Defined Under Namespace

Modules: Defaults

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



59
60
61
62
63
64
65
66
# File 'lib/kontena/plugin/upcloud/prompts.rb', line 59

def self.included(base)
  base.include Common
  base.prepend Defaults
  base.option "--ssh-key", "SSH_KEY", "Path to ssh public key", attribute_name: :ssh_key_path
  base.option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
  base.option "--zone", "ZONE", "Zone", required: true
  base.option "--plan", "PLAN", "Server size", required: true
end

Instance Method Details

#ssh_keyObject



68
69
70
71
72
73
74
# File 'lib/kontena/plugin/upcloud/prompts.rb', line 68

def ssh_key
  return File.read(ssh_key_path).strip unless ssh_key_path.nil?
  default = File.read(Defaults::DEFAULT_SSH_KEY_PATH).strip rescue nil
  prompt.ask('SSH public key: (enter an ssh key in OpenSSH format "ssh-xxx xxxxx key_name")', default: default) do |q|
    q.validate /^ssh-rsa \S+ \S+$/
  end
end