diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-04-27 15:33:25 +0000 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2017-04-28 17:36:24 +0800 |
commit | 07b4c1b28ffcaa97dd4050ea1235ebc518f4879d (patch) | |
tree | 8342b8ffa2109e7f8f21cbfa183e36f9c1acc5aa /app | |
parent | d3123f67f1ee891a284e1a37a02c8efcffbee0f0 (diff) | |
download | gitlab-ce-07b4c1b28ffcaa97dd4050ea1235ebc518f4879d.tar.gz |
Merge branch '2246-uuid-is-nil-for-new-installation' into 'master'
Lazily set UUID in ApplicationSetting for new installations
Closes gitlab-ee#2246
See merge request !10893
Diffstat (limited to 'app')
-rw-r--r-- | app/models/application_setting.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index dd1a6922968..cf042717c95 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -28,6 +28,8 @@ class ApplicationSetting < ActiveRecord::Base attr_accessor :domain_whitelist_raw, :domain_blacklist_raw + validates :uuid, presence: true + validates :session_expire_delay, presence: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 } @@ -159,6 +161,7 @@ class ApplicationSetting < ActiveRecord::Base end end + before_validation :ensure_uuid! before_save :ensure_runners_registration_token before_save :ensure_health_check_access_token @@ -344,6 +347,12 @@ class ApplicationSetting < ActiveRecord::Base private + def ensure_uuid! + return if uuid? + + self.uuid = SecureRandom.uuid + end + def check_repository_storages invalid = repository_storages - Gitlab.config.repositories.storages.keys errors.add(:repository_storages, "can't include: #{invalid.join(", ")}") unless |