class HyperDock::Resource::Container
Public Instance Methods
attributes()
click to toggle source
# File lib/hyperdock/resource/container.rb, line 22 def attributes @attributes ||= container.info end
container()
click to toggle source
# File lib/hyperdock/resource/container.rb, line 8 def container @container ||= ::Docker::Container.all.select do |container| container.id == request.path_info[:container] end.first #::Docker::Container.get id end
links()
click to toggle source
# File lib/hyperdock/resource/container.rb, line 60 def links @links ||= { networks: network_links, volumes: volume_links, ports: { href: "/#{request.disp_path}/ports" } }.merge(named_links) end
named_links()
click to toggle source
# File lib/hyperdock/resource/container.rb, line 50 def named_links @named_links ||= [ network_links .map { |network| { "network:#{network[:name]}" => network } }, volume_links .map { |volume| { "volume:#{volume[:name]}" => volume } } ].flatten.reduce(&:merge) end
network_links()
click to toggle source
# File lib/hyperdock/resource/container.rb, line 32 def network_links @network_links ||= networks.flat_map do |name, network| { name: name, href: "/network/#{network['NetworkID']}" } end end
networks()
click to toggle source
# File lib/hyperdock/resource/container.rb, line 27 def networks @networks ||= attributes.dig('NetworkSettings', 'Networks') || {} end
resource_exists?()
click to toggle source
# File lib/hyperdock/resource/container.rb, line 16 def resource_exists? !container.nil? rescue ::Docker::Error::NotFoundError false end
volume_links()
click to toggle source
# File lib/hyperdock/resource/container.rb, line 44 def volume_links @volume_links ||= volumes.map do |volume| { name: volume['Destination'], href: "/volume/#{volume['Name']}" } end end
volumes()
click to toggle source
# File lib/hyperdock/resource/container.rb, line 39 def volumes @volumes ||= attributes.fetch('Mounts') { [] } end