2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
class ProjectCiCdSetting < ApplicationRecord
|
2022-03-02 08:16:31 +05:30
|
|
|
include ChronicDurationAttribute
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
belongs_to :project, inverse_of: :ci_cd_settings
|
|
|
|
|
2022-03-02 08:16:31 +05:30
|
|
|
DEFAULT_GIT_DEPTH = 20
|
2019-09-04 21:01:54 +05:30
|
|
|
|
|
|
|
before_create :set_default_git_depth
|
|
|
|
|
|
|
|
validates :default_git_depth,
|
|
|
|
numericality: {
|
|
|
|
only_integer: true,
|
|
|
|
greater_than_or_equal_to: 0,
|
|
|
|
less_than_or_equal_to: 1000
|
|
|
|
},
|
|
|
|
allow_nil: true
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
default_value_for :forward_deployment_enabled, true
|
2022-06-21 17:19:12 +05:30
|
|
|
default_value_for :separated_caches, true
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2022-03-02 08:16:31 +05:30
|
|
|
chronic_duration_attr :runner_token_expiration_interval_human_readable, :runner_token_expiration_interval
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
def forward_deployment_enabled?
|
2022-07-16 23:28:13 +05:30
|
|
|
super && ::Feature.enabled?(:forward_deployment_enabled, project)
|
2020-03-13 15:44:24 +05:30
|
|
|
end
|
|
|
|
|
2021-03-11 19:13:27 +05:30
|
|
|
def keep_latest_artifacts_available?
|
|
|
|
# The project level feature can only be enabled when the feature is enabled instance wide
|
|
|
|
Gitlab::CurrentSettings.current_application_settings.keep_latest_artifact? && keep_latest_artifact?
|
|
|
|
end
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
private
|
|
|
|
|
|
|
|
def set_default_git_depth
|
|
|
|
self.default_git_depth ||= DEFAULT_GIT_DEPTH
|
|
|
|
end
|
2018-10-15 14:42:47 +05:30
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
ProjectCiCdSetting.prepend_mod_with('ProjectCiCdSetting')
|