Sha256: 0a5f897f9fec990fcde6f58d23b3266df336af4bd3ee70f481053c997f26af53

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

require 'securerandom'
require 'kontena/plugin/upcloud/prompts'

module Kontena::Plugin::Upcloud::Master
  class CreateCommand < Kontena::Command
    include Kontena::Cli::Common

    option "--name", "[NAME]", "Set Kontena Master name"

    include Kontena::Plugin::Upcloud::Prompts::Create

    option "--ssl-cert", "SSL CERT", "SSL certificate file (optional)"
    option "--vault-secret", "VAULT_SECRET", "Secret key for Vault (optional)"
    option "--vault-iv", "VAULT_IV", "Initialization vector for Vault (optional)"
    option "--mongodb-uri", "URI", "External MongoDB uri (optional)"

    def execute
      require_relative '../../../machine/upcloud'

      abort_unless_api_access

      provisioner.run!(
          name: self.name,
          ssh_key: ssh_key,
          ssl_cert: ssl_cert,
          plan: plan,
          zone: zone,
          version: version,
          vault_secret: vault_secret || SecureRandom.hex(24),
          vault_iv: vault_iv || SecureRandom.hex(24),
          initial_admin_code: SecureRandom.hex(16),
          mongodb_uri: mongodb_uri
      )
    end

    def provisioner
      Kontena::Machine::Upcloud::MasterProvisioner.new(username, password)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kontena-plugin-upcloud-0.3.1.rc1 lib/kontena/plugin/upcloud/master/create_command.rb