2018-08-03 03:15:25 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-07-05 09:55:10 -04:00
|
|
|
module Ci
|
|
|
|
# The purpose of this class is to store Build related runner session.
|
|
|
|
# Data will be removed after transitioning from running to any state.
|
|
|
|
class BuildRunnerSession < ActiveRecord::Base
|
|
|
|
extend Gitlab::Ci::Model
|
|
|
|
|
|
|
|
self.table_name = 'ci_builds_runner_session'
|
|
|
|
|
|
|
|
belongs_to :build, class_name: 'Ci::Build', inverse_of: :runner_session
|
|
|
|
|
|
|
|
validates :build, presence: true
|
|
|
|
validates :url, url: { protocols: %w(https) }
|
|
|
|
|
|
|
|
def terminal_specification
|
|
|
|
return {} unless url.present?
|
|
|
|
|
|
|
|
{
|
|
|
|
subprotocols: ['terminal.gitlab.com'].freeze,
|
|
|
|
url: "#{url}/exec".sub("https://", "wss://"),
|
2018-07-24 08:05:48 -04:00
|
|
|
headers: { Authorization: [authorization.presence] }.compact,
|
2018-07-05 09:55:10 -04:00
|
|
|
ca_pem: certificate.presence
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|