Sha256: 586e75e79e2f6f97efcc6cb2a913962c8df214327c627ed913d2fceb5c567caa

Contents?: true

Size: 1.23 KB

Versions: 15

Compression:

Stored size: 1.23 KB

Contents

require_relative 'common'

module Kontena::Cli::Grids
  class CreateCommand < Kontena::Command
    include Kontena::Cli::Common
    include Common

    parameter "NAME", "Grid name"

    option "--initial-size", "INITIAL_SIZE", "Initial grid size (number of nodes)", default: 1
    option "--silent", :flag, "Reduce output verbosity"
    option "--token", "[TOKEN]", "Set grid token"
    option "--default-affinity", "[AFFINITY]", "Default affinity rule for the grid", multivalued: true

    requires_current_master_token

    def execute
      payload = {
        name: name
      }
      payload[:token] = self.token if self.token
      payload[:initial_size] = self.initial_size if self.initial_size
      payload[:default_affinity] = self.default_affinity_list unless self.default_affinity_list.empty?
      grid = nil
      if initial_size == 1
        warning "Option --initial-size=1 is only recommended for test/dev usage" unless running_silent?
      end
      spinner "Creating #{pastel.cyan(name)} grid " do
        grid = client.post('grids', payload)
      end
      if grid
        spinner "Switching scope to #{pastel.cyan(name)} grid " do
          config.current_grid = grid['name']
          config.write
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
kontena-cli-1.1.6 lib/kontena/cli/grids/create_command.rb
kontena-cli-1.1.5 lib/kontena/cli/grids/create_command.rb
kontena-cli-1.1.5.rc3 lib/kontena/cli/grids/create_command.rb
kontena-cli-1.1.5.rc2 lib/kontena/cli/grids/create_command.rb
kontena-cli-1.1.5.rc1 lib/kontena/cli/grids/create_command.rb
kontena-cli-1.1.4 lib/kontena/cli/grids/create_command.rb
kontena-cli-1.1.3 lib/kontena/cli/grids/create_command.rb
kontena-cli-1.1.2 lib/kontena/cli/grids/create_command.rb
kontena-cli-1.1.2.rc2 lib/kontena/cli/grids/create_command.rb
kontena-cli-1.1.2.rc1 lib/kontena/cli/grids/create_command.rb
kontena-cli-1.1.1 lib/kontena/cli/grids/create_command.rb
kontena-cli-1.1.1.rc1 lib/kontena/cli/grids/create_command.rb
kontena-cli-1.1.0 lib/kontena/cli/grids/create_command.rb
kontena-cli-1.1.0.rc2 lib/kontena/cli/grids/create_command.rb
kontena-cli-1.1.0.rc1 lib/kontena/cli/grids/create_command.rb