Extract EE specific files/lines for lib/gitlab (easier but more)
We have the following files containing EE specific code. We should move them to ee/
lib/gitlab/access.rb
diff --git a/lib/gitlab/access.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/lib/gitlab/access.rb
index ec090aea784..bc54f4e3f18 100644
--- a/lib/gitlab/access.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/lib/gitlab/access.rb
@@ -7,6 +7,8 @@
#
module Gitlab
module Access
+ extend ::EE::Gitlab::Access # rubocop: disable Cop/InjectEnterpriseEditionModule
+
AccessDeniedError = Class.new(StandardError)
NO_ACCESS = 0
@@ -17,6 +19,7 @@ module Gitlab
# @deprecated
MASTER = MAINTAINER
OWNER = 50
+ ADMIN = 60
# Branch protection settings
PROTECTION_NONE = 0
lib/gitlab/database.rb
diff --git a/lib/gitlab/database.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/lib/gitlab/database.rb
index b6ca777e029..abf5105eb8f 100644
--- a/lib/gitlab/database.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/lib/gitlab/database.rb
@@ -11,6 +11,10 @@ module Gitlab
# https://dev.mysql.com/doc/refman/5.7/en/datetime.html
MAX_TIMESTAMP_VALUE = Time.at((1 << 31) - 1).freeze
+ class << self
+ prepend EE::Gitlab::Database # rubocop: disable Cop/InjectEnterpriseEditionModule
+ end
+
def self.config
ActiveRecord::Base.configurations[Rails.env]
end
lib/gitlab/exclusive_lease.rb
diff --git a/lib/gitlab/exclusive_lease.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/lib/gitlab/exclusive_lease.rb
index d466d2a514c..dc88334bdb9 100644
--- a/lib/gitlab/exclusive_lease.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/lib/gitlab/exclusive_lease.rb
@@ -68,6 +68,18 @@ module Gitlab
end
end
+ # Try to obtain the lease. Returns the UUID and current TTL, which will be
+ # zero if it's not taken.
+ def try_obtain_with_ttl
+ Gitlab::Redis::SharedState.with do |redis|
+ output = redis.set(@redis_shared_state_key, @uuid, nx: true, ex: @timeout) && @uuid
+
+ ttl = output ? 0 : redis.ttl(@redis_shared_state_key)
+
+ { ttl: [ttl, 0].max, uuid: output }
+ end
+ end
+
# Try to renew an existing lease. Return lease UUID on success,
# false if the lease is taken by a different UUID or inexistent.
def renew
@@ -94,5 +106,12 @@ module Gitlab
ttl if ttl.positive?
end
end
+
+ # Returns true if the UUID for the key hasn't changed.
+ def same_uuid?
+ Gitlab::Redis::SharedState.with do |redis|
+ redis.get(@redis_shared_state_key) == @uuid
+ end
+ end
end
end
lib/gitlab/favicon.rb
diff --git a/lib/gitlab/favicon.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/lib/gitlab/favicon.rb
index 1ae2f9dfd93..c6dc0e1a1a8 100644
--- a/lib/gitlab/favicon.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/lib/gitlab/favicon.rb
@@ -10,7 +10,7 @@ module Gitlab
elsif Gitlab::Utils.to_boolean(ENV['CANARY'])
'favicon-yellow.png'
elsif Rails.env.development?
- 'favicon-blue.png'
+ 'favicon-green.png'
else
'favicon.png'
end
lib/gitlab/path_regex.rb
diff --git a/lib/gitlab/path_regex.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/lib/gitlab/path_regex.rb
index 3c888be0710..eace1e49889 100644
--- a/lib/gitlab/path_regex.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/lib/gitlab/path_regex.rb
@@ -233,6 +233,10 @@ module Gitlab
}x
end
+ def saml_callback_regex
+ @saml_callback_regex ||= %r(\A\/groups\/(?<group>#{full_namespace_route_regex})\/\-\/saml\/callback\z).freeze
+ end
+
private
def single_line_regexp(regex)
lib/gitlab/sidekiq_config.rb
diff --git a/lib/gitlab/sidekiq_config.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/lib/gitlab/sidekiq_config.rb
index 3b8de64913b..fb303e3fb0c 100644
--- a/lib/gitlab/sidekiq_config.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/lib/gitlab/sidekiq_config.rb
@@ -48,7 +48,9 @@ module Gitlab
end
def self.workers
- @workers ||= find_workers(Rails.root.join('app', 'workers'))
+ @workers ||=
+ find_workers(Rails.root.join('app', 'workers')) +
+ find_workers(Rails.root.join('ee', 'app', 'workers'))
end
def self.find_workers(root)
lib/gitlab/utils.rb
diff --git a/lib/gitlab/utils.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/lib/gitlab/utils.rb
index 99fa65e0e90..622d67cfb81 100644
--- a/lib/gitlab/utils.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/lib/gitlab/utils.rb
@@ -104,6 +104,13 @@ module Gitlab
nil
end
+ # EE below
+ def try_megabytes_to_bytes(size)
+ Integer(size).megabytes
+ rescue ArgumentError
+ size
+ end
+
def bytes_to_megabytes(bytes)
bytes.to_f / Numeric::MEGABYTE
end
Edited by Dave Smith