2018-07-25 09:30:33 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-03-28 13:17:42 +00:00
|
|
|
class ProjectCiCdSetting < ApplicationRecord
|
2022-01-19 12:17:41 +00:00
|
|
|
include ChronicDurationAttribute
|
|
|
|
|
2018-05-03 12:37:01 +00:00
|
|
|
belongs_to :project, inverse_of: :ci_cd_settings
|
2018-04-12 12:07:44 +00:00
|
|
|
|
2022-01-17 15:16:12 +00:00
|
|
|
DEFAULT_GIT_DEPTH = 20
|
2019-05-30 06:40:53 +00:00
|
|
|
|
2019-06-06 11:08:01 +00:00
|
|
|
before_create :set_default_git_depth
|
2019-05-30 06:40:53 +00:00
|
|
|
|
|
|
|
validates :default_git_depth,
|
|
|
|
numericality: {
|
|
|
|
only_integer: true,
|
|
|
|
greater_than_or_equal_to: 0,
|
|
|
|
less_than_or_equal_to: 1000
|
|
|
|
},
|
|
|
|
allow_nil: true
|
|
|
|
|
2020-02-17 09:08:52 +00:00
|
|
|
default_value_for :forward_deployment_enabled, true
|
2022-05-14 03:09:09 +00:00
|
|
|
default_value_for :separated_caches, true
|
2020-02-17 09:08:52 +00:00
|
|
|
|
2022-01-19 12:17:41 +00:00
|
|
|
chronic_duration_attr :runner_token_expiration_interval_human_readable, :runner_token_expiration_interval
|
|
|
|
|
2020-02-17 09:08:52 +00:00
|
|
|
def forward_deployment_enabled?
|
2022-05-06 15:09:03 +00:00
|
|
|
super && ::Feature.enabled?(:forward_deployment_enabled, project)
|
2020-02-17 09:08:52 +00:00
|
|
|
end
|
|
|
|
|
2021-02-09 09:09:19 +00:00
|
|
|
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-05-30 06:40:53 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def set_default_git_depth
|
2019-06-06 12:39:46 +00:00
|
|
|
self.default_git_depth ||= DEFAULT_GIT_DEPTH
|
2019-05-30 06:40:53 +00:00
|
|
|
end
|
2018-04-12 12:07:44 +00:00
|
|
|
end
|
2019-09-13 13:26:31 +00:00
|
|
|
|
2021-05-11 21:10:21 +00:00
|
|
|
ProjectCiCdSetting.prepend_mod_with('ProjectCiCdSetting')
|