lib/mkit/app/helpers/services_helper.rb in mkit-0.5.0 vs lib/mkit/app/helpers/services_helper.rb in mkit-0.6.0
- old
+ new
@@ -22,11 +22,30 @@
error 404, "Couldn't find Service '#{params[:id]}'\n" unless srv
srv
end
def build_table_row(data)
- ports = data.service_port&.each.map { |p| "#{p.mode}/#{p.external_port}" }.join(',')
+ ports = data.service_port&.each.map { |p| build_port(p) }.join(',')
pods = data.pod.each.map { |p| p.name.to_s }.join(' ')
[data.id, data.name, data.lease&.ip, ports, pods, data.status]
+ end
+
+ def build_port(p)
+ case p.mode
+ when 'http'
+ if p.ssl?
+ "#{p.mode}s/#{p.external_port}"
+ else
+ "#{p.mode}/#{p.external_port}"
+ end
+ when 'tcp'
+ if p.ssl?
+ "s#{p.mode}/#{p.external_port}"
+ else
+ "#{p.mode}/#{p.external_port}"
+ end
+ else
+ "#{p.mode}/#{p.external_port}"
+ end
end
end
end