Sha256: f871cafd5bf41ea9b4e404ef92dfe26c11c7406168e97a72e0bc434c80a79d86

Contents?: true

Size: 1.76 KB

Versions: 2

Compression:

Stored size: 1.76 KB

Contents

require 'kontena/plugin/packet/token_option'
require 'kontena/plugin/packet/project_option'
require 'kontena/plugin/packet/type_option'
require 'kontena/plugin/packet/facility_option'
require 'kontena/plugin/packet/ssh_key_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
    include Kontena::Plugin::Packet::SshKeyOption

    option "--name", "[NAME]", "Set master name"
    option "--ssl-cert", "PATH", "SSL certificate file (optional)"
    option "--billing", "BILLING", "Billing cycle", default: 'hourly'
    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 'securerandom'
      require 'kontena/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

2 entries across 2 versions & 1 rubygems

Version Path
kontena-plugin-packet-0.2.7 lib/kontena/plugin/packet/master/create_command.rb
kontena-plugin-packet-0.2.7.rc1 lib/kontena/plugin/packet/master/create_command.rb