Sha256: 730db78992c250700867b7fcaf8c397a775555c418e8c27a5c92fb46a37ceaa8
Contents?: true
Size: 1.1 KB
Versions: 14
Compression:
Stored size: 1.1 KB
Contents
require_relative 'services_helper' module Kontena::Cli::Services class ListCommand < Clamp::Command include Kontena::Cli::Common include Kontena::Cli::GridOptions include ServicesHelper def execute require_api_url token = require_token grids = client(token).get("grids/#{current_grid}/services") services = grids['services'].sort_by{|s| s['updated_at'] }.reverse titles = ['NAME', 'INSTANCES', 'STATEFUL', 'STATE', 'EXPOSED PORTS'] puts "%-60s %-10s %-8s %-10s %-50s" % titles services.each do |service| stateful = service['stateful'] ? 'yes' : 'no' running = service['instances']['running'] desired = service['container_count'] instances = "#{running} / #{desired}" ports = service['ports'].map{|p| "#{p['ip']}:#{p['node_port']}->#{p['container_port']}/#{p['protocol']}" }.join(", ") vars = [ service['name'], instances, stateful, service['state'], ports ] puts "%-60.60s %-10.10s %-8s %-10s %-50s" % vars end end end end
Version data entries
14 entries across 14 versions & 1 rubygems