Sha256: 0c29c58bc269ce1e7827e11ecade078b6a705134be23657147ade5e571535751

Contents?: true

Size: 1.22 KB

Versions: 18

Compression:

Stored size: 1.22 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, name: name)
      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

18 entries across 18 versions & 1 rubygems

Version Path
kontena-cli-1.1.0.pre1 lib/kontena/cli/stacks/install_command.rb
kontena-cli-1.0.6 lib/kontena/cli/stacks/install_command.rb
kontena-cli-1.0.6.rc1 lib/kontena/cli/stacks/install_command.rb
kontena-cli-1.0.5 lib/kontena/cli/stacks/install_command.rb
kontena-cli-1.0.5.rc1 lib/kontena/cli/stacks/install_command.rb
kontena-cli-1.0.5.pre1 lib/kontena/cli/stacks/install_command.rb
kontena-cli-1.0.4 lib/kontena/cli/stacks/install_command.rb
kontena-cli-1.0.4.rc2 lib/kontena/cli/stacks/install_command.rb
kontena-cli-1.0.4.rc1 lib/kontena/cli/stacks/install_command.rb
kontena-cli-1.0.3 lib/kontena/cli/stacks/install_command.rb
kontena-cli-1.0.3.rc1 lib/kontena/cli/stacks/install_command.rb
kontena-cli-1.0.2 lib/kontena/cli/stacks/install_command.rb
kontena-cli-1.0.2.rc2 lib/kontena/cli/stacks/install_command.rb
kontena-cli-1.0.2.rc1 lib/kontena/cli/stacks/install_command.rb
kontena-cli-1.0.2.pre1 lib/kontena/cli/stacks/install_command.rb
kontena-cli-1.0.1 lib/kontena/cli/stacks/install_command.rb
kontena-cli-1.0.1.rc3 lib/kontena/cli/stacks/install_command.rb
kontena-cli-1.0.1.rc2 lib/kontena/cli/stacks/install_command.rb