Sha256: c82d14006c0b4a209b948e665167924299a63d4c23ef1b59326ae6c20e9d026f

Contents?: true

Size: 911 Bytes

Versions: 7

Compression:

Stored size: 911 Bytes

Contents

require_relative 'common'

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

    parameter "[FILE]", "Kontena stack file", 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'

    def execute
      require_api_url
      token = require_token
      require_config_file(filename)
      stack = stack_from_yaml(filename)
      stack['name'] = name if name
      spinner "Creating stack #{pastel.cyan(stack['name'])} " do
        create_stack(token, stack)
      end
      Kontena.run("stack deploy #{stack['name']}") if deploy?
    end

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
kontena-cli-1.0.0.pre2 lib/kontena/cli/stacks/install_command.rb
kontena-cli-1.0.0.pre1 lib/kontena/cli/stacks/install_command.rb
kontena-cli-0.17.0.pre5 lib/kontena/cli/stacks/install_command.rb
kontena-cli-0.17.0.pre4 lib/kontena/cli/stacks/install_command.rb
kontena-cli-0.17.0.pre3 lib/kontena/cli/stacks/install_command.rb
kontena-cli-0.17.0.pre2 lib/kontena/cli/stacks/install_command.rb
kontena-cli-0.17.0.pre1 lib/kontena/cli/stacks/install_command.rb