diff options
Diffstat (limited to 'lib/bulk_imports/clients/http.rb')
-rw-r--r-- | lib/bulk_imports/clients/http.rb | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/bulk_imports/clients/http.rb b/lib/bulk_imports/clients/http.rb index f98d4a5eb14..90414a875c6 100644 --- a/lib/bulk_imports/clients/http.rb +++ b/lib/bulk_imports/clients/http.rb @@ -3,6 +3,8 @@ module BulkImports module Clients class HTTP + include Gitlab::Utils::StrongMemoize + API_VERSION = 'v4' DEFAULT_PAGE = 1 DEFAULT_PER_PAGE = 30 @@ -52,24 +54,32 @@ module BulkImports Gitlab::Utils.append_path(api_url, resource) end - def validate_instance_version! - return if @compatible_instance_version + def instance_version + strong_memoize(:instance_version) do + response = with_error_handling do + Gitlab::HTTP.get(resource_url(:version), default_options) + end - response = with_error_handling do - Gitlab::HTTP.get(resource_url(:version), default_options) + Gitlab::VersionInfo.parse(response.parsed_response['version']) end + end + + def compatible_for_project_migration? + instance_version >= BulkImport.min_gl_version_for_project_migration + end - version = Gitlab::VersionInfo.parse(response.parsed_response['version']) + private + + def validate_instance_version! + return if @compatible_instance_version - if version.major < BulkImport::MINIMUM_GITLAB_MAJOR_VERSION + if instance_version.major < BulkImport::MIN_MAJOR_VERSION raise ::BulkImports::Error.unsupported_gitlab_version else @compatible_instance_version = true end end - private - # rubocop:disable GitlabSecurity/PublicSend def request(method, resource, options = {}, &block) validate_instance_version! |