Sha256: 186d3eb57467bbc2846ce9e058b37e151d95f2885e1606ea6c7210a017e51f6f

Contents?: true

Size: 1.22 KB

Versions: 14

Compression:

Stored size: 1.22 KB

Contents

require_relative 'common'

module Kontena::Cli::Apps
  class ScaleCommand < Kontena::Command
    include Kontena::Cli::Common
    include Kontena::Cli::GridOptions
    include Common

    option ['-f', '--file'], 'FILE', 'Specify an alternate Kontena compose file', attribute_name: :filename, default: 'kontena.yml'
    option ['-p', '--project-name'], 'NAME', 'Specify an alternate project name (default: directory name)'

    parameter "SERVICE", "Service to show"
    parameter "INSTANCES", "Scales service to given number of instances"

    attr_reader :services

    def execute
      require_config_file(filename)
      yml_service = services_from_yaml(filename, [service], service_prefix, true)
      if yml_service[service]
        options = yml_service[service]
        exit_with_error("Service has already instances defined in #{filename}. Please update #{filename} and deploy service instead") if options['container_count']
        spinner "Scaling #{service.colorize(:cyan)} " do
          scale_service(require_token, prefixed_name(service), instances)
          wait_for_deploy_to_finish(token, parse_service_id(prefixed_name(service)))
        end

      else
        exit_with_error("Service not found")
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
kontena-cli-0.16.3 lib/kontena/cli/apps/scale_command.rb
kontena-cli-0.16.3.rc1 lib/kontena/cli/apps/scale_command.rb
kontena-cli-0.16.2 lib/kontena/cli/apps/scale_command.rb
kontena-cli-0.16.2.rc1 lib/kontena/cli/apps/scale_command.rb
kontena-cli-0.16.1 lib/kontena/cli/apps/scale_command.rb
kontena-cli-0.16.1.rc3 lib/kontena/cli/apps/scale_command.rb
kontena-cli-0.16.1.rc2 lib/kontena/cli/apps/scale_command.rb
kontena-cli-0.16.1.rc1 lib/kontena/cli/apps/scale_command.rb
kontena-cli-0.16.0 lib/kontena/cli/apps/scale_command.rb
kontena-cli-0.16.0.rc3 lib/kontena/cli/apps/scale_command.rb
kontena-cli-0.16.0.rc2 lib/kontena/cli/apps/scale_command.rb
kontena-cli-0.16.0.rc1 lib/kontena/cli/apps/scale_command.rb
kontena-cli-0.16.0.pre9 lib/kontena/cli/apps/scale_command.rb
kontena-cli-0.16.0.pre8 lib/kontena/cli/apps/scale_command.rb