Cache results for Docker bindings
This commit is contained in:
@ -7,10 +7,15 @@ module DockerContainerMixin
|
|||||||
attr_accessor :docker_client
|
attr_accessor :docker_client
|
||||||
|
|
||||||
def binds
|
def binds
|
||||||
json['HostConfig']['Binds']
|
host_config['Binds']
|
||||||
end
|
end
|
||||||
|
|
||||||
def port_bindings
|
def port_bindings
|
||||||
|
# Don't use cached version as this might be changed during runtime
|
||||||
json['HostConfig']['PortBindings'].try(:map) { |key, value| [key.to_i, value.first['HostPort'].to_i] }.to_h
|
json['HostConfig']['PortBindings'].try(:map) { |key, value| [key.to_i, value.first['HostPort'].to_i] }.to_h
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def host_config
|
||||||
|
@host_config ||= json['HostConfig']
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user