Welcome to mirror list, hosted at ThFree Co, Russian Federation.

runner_namespace.rb « ci « models « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 82390ccc538da33e89c8e3d2eb7b093d80d72f83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# frozen_string_literal: true

module Ci
  class RunnerNamespace < Ci::ApplicationRecord
    include Limitable

    self.limit_name = 'ci_registered_group_runners'
    self.limit_scope = :group
    self.limit_relation = :recent_runners

    belongs_to :runner, inverse_of: :runner_namespaces
    belongs_to :namespace, inverse_of: :runner_namespaces, class_name: '::Namespace'
    belongs_to :group, class_name: '::Group', foreign_key: :namespace_id

    validates :runner_id, uniqueness: { scope: :namespace_id }
    validate :group_runner_type

    def recent_runners
      ::Ci::Runner.belonging_to_group(namespace_id).recent
    end

    private

    def group_runner_type
      errors.add(:runner, 'is not a group runner') unless runner&.group_type?
    end
  end
end