Sha256: 28e92458fde60fa930d40d0c3814ff9328a79b698040486dd1a6f05bf468c796
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
# frozen_string_literal: true require 'text-table' module MKIt module ServicesHelper def format_response(data, _verbose = false) table = Text::Table.new table.head = %w[id name addr ports pods status] if data.respond_to? 'each' data.each do |srv| ports = srv.service_port&.each.map { |p| "#{p.mode}/#{p.external_port}" }.join(',') pods = srv.pod.each.map { |p| p.name.to_s }.join(' ') table.rows << [srv.id, srv.name, srv.lease&.ip, ports, pods, srv.status] end else ports = data.service_port&.each.map { |p| "#{p.mode}/#{p.external_port}" }.join(',') pods = data.pod.each.map { |p| p.name.to_s }.join(' ') table.rows << [data.id, data.name, data.lease&.ip, ports, pods, data.status] end table.to_s end def find_by_id_or_name srv = Service.find_by_id(params[:id]) srv ||= Service.find_by_name(params[:id]) error 404, "Couldn't find Service '#{params[:id]}'\n" unless srv srv end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mkit-0.4.2 | lib/mkit/app/helpers/services_helper.rb |