debian-mirror-gitlab/app/helpers/container_expiration_policies_helper.rb

33 lines
941 B
Ruby
Raw Normal View History

2020-01-01 13:55:28 +05:30
# frozen_string_literal: true
module ContainerExpirationPoliciesHelper
def cadence_options
ContainerExpirationPolicy.cadence_options.map do |key, val|
2020-03-13 15:44:24 +05:30
{ key: key.to_s, label: val }.tap do |base|
base[:default] = true if key.to_s == '1d'
end
2020-01-01 13:55:28 +05:30
end
end
def keep_n_options
ContainerExpirationPolicy.keep_n_options.map do |key, val|
2020-03-13 15:44:24 +05:30
{ key: key, label: val }.tap do |base|
base[:default] = true if key == 10
end
2020-01-01 13:55:28 +05:30
end
end
def older_than_options
ContainerExpirationPolicy.older_than_options.map do |key, val|
2020-03-13 15:44:24 +05:30
{ key: key.to_s, label: val }.tap do |base|
2020-04-22 19:07:51 +05:30
base[:default] = true if key.to_s == '90d'
2020-03-13 15:44:24 +05:30
end
2020-01-01 13:55:28 +05:30
end
end
2021-01-03 14:25:43 +05:30
def container_expiration_policies_historic_entry_enabled?(project)
Gitlab::CurrentSettings.container_expiration_policies_enable_historic_entries ||
Feature.enabled?(:container_expiration_policies_historic_entry, project)
end
2020-01-01 13:55:28 +05:30
end