Sha256: 34c88559951af6d0a1de46459459899b1746d356156b5c58cbf5f38aac624f63

Contents?: true

Size: 1.73 KB

Versions: 6

Compression:

Stored size: 1.73 KB

Contents

require 'securerandom'
require_relative '../token_option'
require_relative '../project_option'
require_relative '../type_option'
require_relative '../facility_option'

module Kontena::Plugin::Packet::Master
  class CreateCommand < Kontena::Command
    include Kontena::Cli::Common
    include Kontena::Plugin::Packet::TokenOption
    include Kontena::Plugin::Packet::ProjectOption
    include Kontena::Plugin::Packet::TypeOption
    include Kontena::Plugin::Packet::FacilityOption

    option "--name", "[NAME]", "Set master name"
    option "--ssl-cert", "PATH", "SSL certificate file (optional)"
    option "--billing", "BILLING", "Billing cycle", default: 'hourly'
    option "--ssh-key", "PATH", "Path to ssh public key", default: File.join(Dir.home, '.ssh', 'id_rsa.pub')
    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)"
    option "--version", "VERSION", "Define installed Kontena version", default: 'latest'

    def execute
      require_relative '../../../machine/packet'

      provisioner = provisioner(token)
      provisioner.run!(
          project: project,
          billing: billing,
          ssh_key: ssh_key,
          ssl_cert: ssl_cert,
          plan: plan,
          facility: facility,
          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

    # @param [String] token
    def provisioner(token)
      Kontena::Machine::Packet::MasterProvisioner.new(token)
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
kontena-plugin-packet-0.2.5 lib/kontena/plugin/packet/master/create_command.rb
kontena-plugin-packet-0.2.4 lib/kontena/plugin/packet/master/create_command.rb
kontena-plugin-packet-0.2.3 lib/kontena/plugin/packet/master/create_command.rb
kontena-plugin-packet-0.2.2 lib/kontena/plugin/packet/master/create_command.rb
kontena-plugin-packet-0.2.1 lib/kontena/plugin/packet/master/create_command.rb
kontena-plugin-packet-0.2.0 lib/kontena/plugin/packet/master/create_command.rb