Add custom websocket header to strategy class
This commit is contained in:
@ -17,7 +17,7 @@ class Runner::Connection
|
|||||||
# Internally, Faye::WebSocket uses EventMachine and the `ping` value is used to wake the EventMachine thread
|
# Internally, Faye::WebSocket uses EventMachine and the `ping` value is used to wake the EventMachine thread
|
||||||
# The `tls` option is used to customize the validation of TLS connections.
|
# The `tls` option is used to customize the validation of TLS connections.
|
||||||
# Passing `nil` as a `root_cert_file` is okay and done so for the DockerContainerPool.
|
# Passing `nil` as a `root_cert_file` is okay and done so for the DockerContainerPool.
|
||||||
@socket = Faye::WebSocket::Client.new(url, [], ping: 0.1, tls: {root_cert_file: Runner.strategy_class.config[:ca_file]})
|
@socket = Faye::WebSocket::Client.new(url, [], strategy.websocket_header.merge(ping: 0.1))
|
||||||
@strategy = strategy
|
@strategy = strategy
|
||||||
@status = :established
|
@status = :established
|
||||||
@event_loop = event_loop
|
@event_loop = event_loop
|
||||||
|
@ -28,4 +28,8 @@ class Runner::Strategy
|
|||||||
def attach_to_execution(_command)
|
def attach_to_execution(_command)
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def websocket_header
|
||||||
|
raise NotImplementedError
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -76,6 +76,10 @@ class Runner::Strategy::DockerContainerPool < Runner::Strategy
|
|||||||
socket
|
socket
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def websocket_header
|
||||||
|
{}
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def container
|
def container
|
||||||
|
@ -121,6 +121,13 @@ class Runner::Strategy::Poseidon < Runner::Strategy
|
|||||||
raise Runner::Error::FaradayError.new("Request to Poseidon failed: #{e.inspect}")
|
raise Runner::Error::FaradayError.new("Request to Poseidon failed: #{e.inspect}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def websocket_header
|
||||||
|
{
|
||||||
|
tls: {root_cert_file: self.class.config[:ca_file]},
|
||||||
|
headers: {'Poseidon-Token' => self.class.config[:token]},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def execute_command(command)
|
def execute_command(command)
|
||||||
|
Reference in New Issue
Block a user