Class: Gitlab::Ci::Matching::RunnerMatcher
- Inherits:
-
Object
- Object
- Gitlab::Ci::Matching::RunnerMatcher
- Defined in:
- lib/gitlab/ci/matching/runner_matcher.rb
Overview
This class is used to check if a build can be picked by a runner:
runner = Ci::Runner.find(id) build = Ci::Build.find(id) runner.runner_matcher.matches?(build.build_matcher)
There are also class level methods to build matchers:
‘project.builds.build_matchers(project)` returns a distinct collection of build matchers. `Ci::Runner.runner_matchers` returns a distinct collection of runner matchers.
Constant Summary collapse
- ATTRIBUTES =
%i[ runner_ids runner_type public_projects_minutes_cost_factor private_projects_minutes_cost_factor run_untagged access_level tag_list ].freeze
Instance Method Summary collapse
-
#initialize(params) ⇒ RunnerMatcher
constructor
A new instance of RunnerMatcher.
- #instance_type? ⇒ Boolean
- #matches?(build_matcher) ⇒ Boolean
Constructor Details
#initialize(params) ⇒ RunnerMatcher
Returns a new instance of RunnerMatcher.
32 33 34 35 36 |
# File 'lib/gitlab/ci/matching/runner_matcher.rb', line 32 def initialize(params) ATTRIBUTES.each do |attribute| instance_variable_set("@#{attribute}", params.fetch(attribute)) end end |
Instance Method Details
#instance_type? ⇒ Boolean
45 46 47 |
# File 'lib/gitlab/ci/matching/runner_matcher.rb', line 45 def instance_type? runner_type.to_sym == :instance_type end |
#matches?(build_matcher) ⇒ Boolean
38 39 40 41 42 43 |
# File 'lib/gitlab/ci/matching/runner_matcher.rb', line 38 def matches?(build_matcher) ensure_build_matcher_instance!(build_matcher) return false if ref_protected? && !build_matcher.protected? (build_matcher) end |