diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index e33a58d3771bf1933bafddbdb738228c95cb5e12..e0ccff52ebe2061405486b191c9d3c422132b449 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -13,49 +13,6 @@ class ApplicationSetting < ActiveRecord::Base [\r\n] # any number of newline characters }x - DEFAULTS_CE = { - after_sign_up_text: nil, - akismet_enabled: false, - container_registry_token_expire_delay: 5, - default_branch_protection: Settings.gitlab['default_branch_protection'], - default_project_visibility: Settings.gitlab.default_projects_features['visibility_level'], - default_projects_limit: Settings.gitlab['default_projects_limit'], - default_snippet_visibility: Settings.gitlab.default_projects_features['visibility_level'], - disabled_oauth_sign_in_sources: [], - domain_whitelist: Settings.gitlab['domain_whitelist'], - gravatar_enabled: Settings.gravatar['enabled'], - help_page_text: nil, - housekeeping_bitmaps_enabled: true, - housekeeping_enabled: true, - housekeeping_full_repack_period: 50, - housekeeping_gc_period: 200, - housekeeping_incremental_repack_period: 10, - import_sources: Gitlab::ImportSources.values, - koding_enabled: false, - koding_url: nil, - max_artifacts_size: Settings.artifacts['max_size'], - max_attachment_size: Settings.gitlab['max_attachment_size'], - plantuml_enabled: false, - plantuml_url: nil, - recaptcha_enabled: false, - repository_checks_enabled: true, - repository_storages: ['default'], - require_two_factor_authentication: false, - restricted_visibility_levels: Settings.gitlab['restricted_visibility_levels'], - session_expire_delay: Settings.gitlab['session_expire_delay'], - send_user_confirmation_email: false, - shared_runners_enabled: Settings.gitlab_ci['shared_runners_enabled'], - shared_runners_text: nil, - sidekiq_throttling_enabled: false, - sign_in_text: nil, - signin_enabled: Settings.gitlab['signin_enabled'], - signup_enabled: Settings.gitlab['signup_enabled'], - two_factor_grace_period: 48, - user_default_external: false - } - - DEFAULTS = DEFAULTS_CE - serialize :restricted_visibility_levels serialize :import_sources serialize :disabled_oauth_sign_in_sources, Array @@ -199,14 +156,64 @@ class ApplicationSetting < ActiveRecord::Base def self.expire Rails.cache.delete(CACHE_KEY) + rescue + # Gracefully handle when Redis is not available. For example, + # omnibus may fail here during assets:precompile. end def self.cached Rails.cache.fetch(CACHE_KEY) end + def self.defaults_ce + { + after_sign_up_text: nil, + akismet_enabled: false, + container_registry_token_expire_delay: 5, + default_branch_protection: Settings.gitlab['default_branch_protection'], + default_project_visibility: Settings.gitlab.default_projects_features['visibility_level'], + default_projects_limit: Settings.gitlab['default_projects_limit'], + default_snippet_visibility: Settings.gitlab.default_projects_features['visibility_level'], + disabled_oauth_sign_in_sources: [], + domain_whitelist: Settings.gitlab['domain_whitelist'], + gravatar_enabled: Settings.gravatar['enabled'], + help_page_text: nil, + housekeeping_bitmaps_enabled: true, + housekeeping_enabled: true, + housekeeping_full_repack_period: 50, + housekeeping_gc_period: 200, + housekeeping_incremental_repack_period: 10, + import_sources: Gitlab::ImportSources.values, + koding_enabled: false, + koding_url: nil, + max_artifacts_size: Settings.artifacts['max_size'], + max_attachment_size: Settings.gitlab['max_attachment_size'], + plantuml_enabled: false, + plantuml_url: nil, + recaptcha_enabled: false, + repository_checks_enabled: true, + repository_storages: ['default'], + require_two_factor_authentication: false, + restricted_visibility_levels: Settings.gitlab['restricted_visibility_levels'], + session_expire_delay: Settings.gitlab['session_expire_delay'], + send_user_confirmation_email: false, + shared_runners_enabled: Settings.gitlab_ci['shared_runners_enabled'], + shared_runners_text: nil, + sidekiq_throttling_enabled: false, + sign_in_text: nil, + signin_enabled: Settings.gitlab['signin_enabled'], + signup_enabled: Settings.gitlab['signup_enabled'], + two_factor_grace_period: 48, + user_default_external: false + } + end + + def self.defaults + defaults_ce + end + def self.create_from_defaults - create(DEFAULTS) + create(defaults) end def home_page_url_column_exist diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 906ec11f01252ad9b3db8843ffb00cafd05a6287..4f33aad8693af2617590816f85f0f12be10bd6e7 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -419,10 +419,4 @@ if Rails.env.test? end # Force a refresh of application settings at startup -begin - ApplicationSetting.expire - Ci::ApplicationSetting.expire -rescue - # Gracefully handle when Redis is not available. For example, - # omnibus may fail here during assets:precompile. -end +ApplicationSetting.expire diff --git a/config/initializers/5_backend.rb b/config/initializers/5_backend.rb index ed88c8ee1b827d043d1cb2a815112a3280a5a982..2bd159ca7f189b4ef4452858387a91fff3bd0f09 100644 --- a/config/initializers/5_backend.rb +++ b/config/initializers/5_backend.rb @@ -1,9 +1,3 @@ -# GIT over SSH -require_dependency Rails.root.join('lib/gitlab/backend/shell') - -# GitLab shell adapter -require_dependency Rails.root.join('lib/gitlab/backend/shell_adapter') - required_version = Gitlab::VersionInfo.parse(Gitlab::Shell.version_required) current_version = Gitlab::VersionInfo.parse(Gitlab::Shell.new.version) diff --git a/lib/gitlab/current_settings.rb b/lib/gitlab/current_settings.rb index 4ebd48a3fc71784273f24cec179d8d86ecc899b3..e20f5f6f5143f747e483a51844a37520fd3357d5 100644 --- a/lib/gitlab/current_settings.rb +++ b/lib/gitlab/current_settings.rb @@ -30,7 +30,7 @@ module Gitlab end def in_memory_application_settings - @in_memory_application_settings ||= ::ApplicationSetting.new(::ApplicationSetting::DEFAULTS) + @in_memory_application_settings ||= ::ApplicationSetting.new(::ApplicationSetting.defaults) # In case migrations the application_settings table is not created yet, # we fallback to a simple OpenStruct rescue ActiveRecord::StatementInvalid, ActiveRecord::UnknownAttributeError @@ -38,7 +38,7 @@ module Gitlab end def fake_application_settings - OpenStruct.new(::ApplicationSetting::DEFAULTS) + OpenStruct.new(::ApplicationSetting.defaults) end private diff --git a/lib/gitlab/backend/shell.rb b/lib/gitlab/shell.rb similarity index 100% rename from lib/gitlab/backend/shell.rb rename to lib/gitlab/shell.rb diff --git a/lib/gitlab/backend/shell_adapter.rb b/lib/gitlab/shell_adapter.rb similarity index 100% rename from lib/gitlab/backend/shell_adapter.rb rename to lib/gitlab/shell_adapter.rb