Class: NamespaceSetting
Constant Summary
collapse
- NAMESPACE_SETTINGS_PARAMS =
i[
emails_enabled
default_branch_name
resource_access_token_creation_allowed
prevent_sharing_groups_outside_hierarchy
new_user_signups_cap
setup_for_company
seat_control
jobs_to_be_done
runner_token_expiration_interval
enabled_git_access_protocol
subgroup_runner_token_expiration_interval
project_runner_token_expiration_interval
default_branch_protection_defaults
math_rendering_limits_enabled
lock_math_rendering_limits_enabled
jwt_ci_cd_job_token_enabled
].freeze
- DEFAULT_BRANCH_PROTECTIONS_DEFAULT_MAX_SIZE =
matches the size set in the database constraint
1.kilobyte
ApplicationRecord::MAX_PLUCK
HasCheckConstraints::NOT_NULL_CHECK_PATTERN
ResetOnColumnErrors::MAX_RESET_PERIOD
Class Method Summary
collapse
Instance Method Summary
collapse
#chronic_duration_attributes, #output_chronic_duration_attribute
===, cached_column_list, #create_or_load_association, current_transaction, declarative_enum, default_select_columns, delete_all_returning, #deleted_from_database?, id_in, id_not_in, iid_in, nullable_column?, primary_key_in, #readable_by?, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, #to_ability_name, underscore, where_exists, where_not_exists, with_fast_read_statement_timeout, without_order
#sharding_organization
#reset_on_union_error, #reset_on_unknown_attribute_error
#serializable_hash
Class Method Details
.allowed_namespace_settings_params ⇒ Object
113
114
115
|
# File 'app/models/namespace_setting.rb', line 113
def self.allowed_namespace_settings_params
NAMESPACE_SETTINGS_PARAMS
end
|
.declarative_policy_class ⇒ Object
109
110
111
|
# File 'app/models/namespace_setting.rb', line 109
def self.declarative_policy_class
"Ci::NamespaceSettingPolicy"
end
|
.enterprise_bypass_max_date ⇒ Object
121
122
123
|
# File 'app/models/namespace_setting.rb', line 121
def self.enterprise_bypass_max_date
Date.current.advance(years: 1, days: -1).end_of_day
end
|
.enterprise_bypass_min_date ⇒ Object
117
118
119
|
# File 'app/models/namespace_setting.rb', line 117
def self.enterprise_bypass_min_date
Date.current.tomorrow.beginning_of_day
end
|
Instance Method Details
#all_ancestors_have_runner_registration_enabled? ⇒ Boolean
157
158
159
160
161
162
163
|
# File 'app/models/namespace_setting.rb', line 157
def all_ancestors_have_runner_registration_enabled?
return false unless Gitlab::CurrentSettings.valid_runner_registrars.include?('group')
return true unless namespace.has_parent?
!self.class.where(namespace_id: namespace.ancestors, runner_registration_enabled: false).exists?
end
|
#allow_runner_registration_token? ⇒ Boolean
165
166
167
168
169
|
# File 'app/models/namespace_setting.rb', line 165
def allow_runner_registration_token?
settings = Gitlab::CurrentSettings.current_application_settings
settings.allow_runner_registration_token && namespace.root_ancestor.allow_runner_registration_token
end
|
#emails_enabled? ⇒ Boolean
140
141
142
143
144
|
# File 'app/models/namespace_setting.rb', line 140
def emails_enabled?
return emails_enabled unless namespace.has_parent?
all_ancestors_have_emails_enabled?
end
|
#enterprise_placeholder_bypass_enabled? ⇒ Boolean
177
178
179
|
# File 'app/models/namespace_setting.rb', line 177
def enterprise_placeholder_bypass_enabled?
allow_enterprise_bypass_placeholder_confirmation? && enterprise_bypass_expires_at.present? && enterprise_bypass_expires_at.future?
end
|
#jwt_ci_cd_job_token_enabled? ⇒ Boolean
171
172
173
174
175
|
# File 'app/models/namespace_setting.rb', line 171
def jwt_ci_cd_job_token_enabled?
return true if Feature.enabled?(:ci_job_token_jwt, namespace) && !jwt_ci_cd_job_token_opted_out?
super
end
|
#pipeline_variables_default_role ⇒ Object
131
132
133
134
135
136
137
138
|
# File 'app/models/namespace_setting.rb', line 131
def pipeline_variables_default_role
return namespace.root_ancestor.pipeline_variables_default_role unless namespace.root?
super
end
|
#prevent_sharing_groups_outside_hierarchy ⇒ Object
125
126
127
128
129
|
# File 'app/models/namespace_setting.rb', line 125
def prevent_sharing_groups_outside_hierarchy
return super if namespace.root?
namespace.root_ancestor.prevent_sharing_groups_outside_hierarchy
end
|
#runner_registration_enabled? ⇒ Boolean
153
154
155
|
# File 'app/models/namespace_setting.rb', line 153
def runner_registration_enabled?
runner_registration_enabled && all_ancestors_have_runner_registration_enabled?
end
|
#show_diff_preview_in_email? ⇒ Boolean
Where this function is used, a returned “nil” is considered a truthy value
147
148
149
150
151
|
# File 'app/models/namespace_setting.rb', line 147
def show_diff_preview_in_email?
return show_diff_preview_in_email unless namespace.has_parent?
all_ancestors_allow_diff_preview_in_email?
end
|
#step_up_auth_required_oauth_provider_from_self_or_inherited ⇒ Object
Returns the active/effective step-up auth provider, considering inheritance from parent groups
203
204
205
|
# File 'app/models/namespace_setting.rb', line 203
def step_up_auth_required_oauth_provider_from_self_or_inherited
step_up_auth_required_oauth_provider_inherited_namespace_setting&.step_up_auth_required_oauth_provider || step_up_auth_required_oauth_provider
end
|
#step_up_auth_required_oauth_provider_inherited_namespace_setting ⇒ Object
Returns the namespace_setting that provides the inherited step-up auth provider (excluding self) This is the base method that all other inheritance methods build upon
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
# File 'app/models/namespace_setting.rb', line 183
def step_up_auth_required_oauth_provider_inherited_namespace_setting
ancestor_ids = namespace.traversal_ids[0..-2]
return if ancestor_ids.empty?
@step_up_auth_inherited_setting ||= self.class
.joins(:namespace)
.where(namespace_id: ancestor_ids)
.where.not(step_up_auth_required_oauth_provider: nil)
.order(Arel.sql("array_position(ARRAY[#{ancestor_ids.join(',')}]::bigint[], namespace_settings.namespace_id)"))
.includes(:namespace)
.first
end
|