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.

32 lines
1 KiB
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
include EnumWithNil
enum_with_nil status: {
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-04-23 21:23:45 +05:30
has_many :runner_machines, inverse_of: :runner_version, foreign_key: :version, class_name: 'Ci::RunnerMachine'
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