class HyperDock::Resource::ProjectService
Constants
- PROJECT_LABEL
- SERVICE_LABEL
Public Instance Methods
attributes()
click to toggle source
# File lib/hyperdock/resource/project_service.rb, line 53 def attributes { name: service } end
container_links()
click to toggle source
# File lib/hyperdock/resource/project_service.rb, line 32 def container_links @container_links ||= containers.flat_map do |container| # TODO: Determine how this should be presented. [container.info.fetch('Names').first].map do |name| { name: name, href: "/container/#{container.id}" } end end end
containers()
click to toggle source
# File lib/hyperdock/resource/project_service.rb, line 26 def containers @containers ||= ::Docker::Container.all.select do |container| matches_project?(container) && matches_service?(container) end end
links()
click to toggle source
# File lib/hyperdock/resource/project_service.rb, line 47 def links @links ||= { containers: container_links }.merge(named_links) end
matches_project?(container)
click to toggle source
# File lib/hyperdock/resource/project_service.rb, line 18 def matches_project?(container) container.info.dig('Labels', PROJECT_LABEL) == project end
matches_service?(container)
click to toggle source
# File lib/hyperdock/resource/project_service.rb, line 22 def matches_service?(container) container.info.dig('Labels', SERVICE_LABEL) == service end
named_links()
click to toggle source
# File lib/hyperdock/resource/project_service.rb, line 41 def named_links @named_links ||= container_links.map do |container| { "container:#{container[:name]}" => container } end.reduce(&:merge) end
project()
click to toggle source
# File lib/hyperdock/resource/project_service.rb, line 10 def project @project ||= request.path_info[:project] end
service()
click to toggle source
# File lib/hyperdock/resource/project_service.rb, line 14 def service @service ||= request.path_info[:service] end