Sha256: e1007b79b79c92bce17c9ec27c6a215eb532ada3dc082ea36ec9cdc46e48c8c1

Contents?: true

Size: 1.21 KB

Versions: 5

Compression:

Stored size: 1.21 KB

Contents

require_relative 'common'

module Kontena::Cli::Stacks
  class InstallCommand < Kontena::Command
    include Kontena::Cli::Common
    include Kontena::Cli::GridOptions
    include Common

    banner "Installs a stack to a grid on Kontena Master"

    parameter "[FILE]", "Kontena stack file or a registry stack name (user/stack or user/stack:version)", default: "kontena.yml", attribute_name: :filename

    option ['-n', '--name'], 'NAME', 'Define stack name (by default comes from stack file)'
    option '--deploy', :flag, 'Deploy after installation'

    requires_current_master
    requires_current_master_token

    def execute

      if !File.exist?(filename) && filename =~ /\A[a-zA-Z0-9\_\.\-]+\/[a-zA-Z0-9\_\.\-]+(?::.*)?\z/
        from_registry = true
      else
        from_registry = false
        require_config_file(filename)
      end

      stack = stack_from_yaml(filename, from_registry: from_registry)
      stack['name'] = name if name
      spinner "Creating stack #{pastel.cyan(stack['name'])} " do
        create_stack(stack)
      end
      Kontena.run("stack deploy #{stack['name']}") if deploy?
    end

    def create_stack(stack)
      client.post("grids/#{current_grid}/stacks", stack)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
kontena-cli-1.0.1.rc1 lib/kontena/cli/stacks/install_command.rb
kontena-cli-1.0.0 lib/kontena/cli/stacks/install_command.rb
kontena-cli-1.0.0.rc2 lib/kontena/cli/stacks/install_command.rb
kontena-cli-1.0.0.rc1 lib/kontena/cli/stacks/install_command.rb
kontena-cli-1.0.0.pre4 lib/kontena/cli/stacks/install_command.rb