debian-mirror-gitlab/app/models/ci/runner_version.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
1,006 B
Ruby
Raw Normal View History

2022-08-13 15:12:31 +05:30
# frozen_string_literal: true
module Ci
class RunnerVersion < Ci::ApplicationRecord
include EachBatch
2023-05-27 22:25:52 +05:30
enum status: {
2022-08-13 15:12:31 +05:30
not_processed: nil,
invalid_version: -1,
2023-04-23 21:23:45 +05:30
unavailable: 1,
2022-08-13 15:12:31 +05:30
available: 2,
recommended: 3
}
STATUS_DESCRIPTIONS = {
invalid_version: 'Runner version is not valid.',
2023-04-23 21:23:45 +05:30
unavailable: 'Upgrade is not available for the runner.',
2022-08-13 15:12:31 +05:30
available: 'Upgrade is available for the runner.',
recommended: 'Upgrade is available and recommended for the runner.'
}.freeze
2023-06-20 00:43:36 +05:30
has_many :runner_managers, inverse_of: :runner_version, foreign_key: :version, class_name: 'Ci::RunnerManager'
2022-08-13 15:12:31 +05:30
# This scope returns all versions that might need recalculating. For instance, once a version is considered
# :recommended, it normally doesn't change status even if the instance is upgraded
2023-04-23 21:23:45 +05:30
scope :potentially_outdated, -> { where(status: [nil, :unavailable, :available]) }
2022-08-13 15:12:31 +05:30
validates :version, length: { maximum: 2048 }
end
end