Sha256: 0d9abc4b92cf3705aecfd0f8373f11e86bb2d1823ca0808131e6f8b5cb942844

Contents?: true

Size: 680 Bytes

Versions: 8

Compression:

Stored size: 680 Bytes

Contents

module Kontena::Cli::Master
  class UseCommand < Clamp::Command
    include Kontena::Cli::Common

    parameter "NAME", "Master name to use"

    def execute
      master = find_master_by_name(name)
      if !master.nil?
        self.current_master = master['name']
        puts "Using master: #{master['name'].cyan}"
        puts "URL: #{master['url'].cyan}"
      else
        abort "Could not resolve master by name [#{name}]. For a list of known masters please run: kontena master list".colorize(:red)
      end
    end

    def find_master_by_name(name)
      settings['servers'].each do |server|
        return server if server['name'] == name
      end
    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
kontena-cli-0.11.7 lib/kontena/cli/master/use_command.rb
kontena-cli-0.11.6 lib/kontena/cli/master/use_command.rb
kontena-cli-0.11.5 lib/kontena/cli/master/use_command.rb
kontena-cli-0.11.4 lib/kontena/cli/master/use_command.rb
kontena-cli-0.11.3 lib/kontena/cli/master/use_command.rb
kontena-cli-0.11.2 lib/kontena/cli/master/use_command.rb
kontena-cli-0.11.1 lib/kontena/cli/master/use_command.rb
kontena-cli-0.11.0 lib/kontena/cli/master/use_command.rb