diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-10 12:08:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-10 12:08:10 +0300 |
commit | 82fa8a3d1e8466ef36b58604d20fcc145ea12118 (patch) | |
tree | c5c0286537405c2fa7719ecce3ed0d73d947c555 /lib | |
parent | 232655bf32cd474d54de357b65ef43d77271117c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/deploy_tokens.rb | 32 | ||||
-rw-r--r-- | lib/api/entities/deploy_token_with_token.rb | 9 | ||||
-rw-r--r-- | lib/gitlab/background_migration/remove_undefined_vulnerability_severity_level.rb | 13 | ||||
-rw-r--r-- | lib/gitlab/database/batch_count.rb | 2 | ||||
-rw-r--r-- | lib/gitlab/gitaly_client.rb | 12 |
5 files changed, 66 insertions, 2 deletions
diff --git a/lib/api/deploy_tokens.rb b/lib/api/deploy_tokens.rb index e10a12b6c46..1631425ec1b 100644 --- a/lib/api/deploy_tokens.rb +++ b/lib/api/deploy_tokens.rb @@ -4,6 +4,17 @@ module API class DeployTokens < Grape::API include PaginationParams + helpers do + def scope_params + scopes = params.delete(:scopes) + + result_hash = {} + result_hash[:read_registry] = scopes.include?('read_registry') + result_hash[:read_repository] = scopes.include?('read_repository') + result_hash + end + end + desc 'Return all deploy tokens' do detail 'This feature was introduced in GitLab 12.9.' success Entities::DeployToken @@ -33,6 +44,27 @@ module API present paginate(user_project.deploy_tokens), with: Entities::DeployToken end + + params do + requires :name, type: String, desc: "New deploy token's name" + requires :expires_at, type: DateTime, desc: 'Expiration date for the deploy token. Does not expire if no value is provided.' + requires :username, type: String, desc: 'Username for deploy token. Default is `gitlab+deploy-token-{n}`' + requires :scopes, type: Array[String], values: ::DeployToken::AVAILABLE_SCOPES.map(&:to_s), + desc: 'Indicates the deploy token scopes. Must be at least one of "read_repository" or "read_registry".' + end + desc 'Create a project deploy token' do + detail 'This feature was introduced in GitLab 12.9' + success Entities::DeployTokenWithToken + end + post ':id/deploy_tokens' do + authorize!(:create_deploy_token, user_project) + + deploy_token = ::Projects::DeployTokens::CreateService.new( + user_project, current_user, scope_params.merge(declared(params, include_missing: false, include_parent_namespaces: false)) + ).execute + + present deploy_token, with: Entities::DeployTokenWithToken + end end params do diff --git a/lib/api/entities/deploy_token_with_token.rb b/lib/api/entities/deploy_token_with_token.rb new file mode 100644 index 00000000000..11efe3720fa --- /dev/null +++ b/lib/api/entities/deploy_token_with_token.rb @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +module API + module Entities + class DeployTokenWithToken < Entities::DeployToken + expose :token + end + end +end diff --git a/lib/gitlab/background_migration/remove_undefined_vulnerability_severity_level.rb b/lib/gitlab/background_migration/remove_undefined_vulnerability_severity_level.rb new file mode 100644 index 00000000000..95540cd5f49 --- /dev/null +++ b/lib/gitlab/background_migration/remove_undefined_vulnerability_severity_level.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true +# rubocop:disable Style/Documentation + +module Gitlab + module BackgroundMigration + class RemoveUndefinedVulnerabilitySeverityLevel + def perform(start_id, stop_id) + end + end + end +end + +Gitlab::BackgroundMigration::RemoveUndefinedVulnerabilitySeverityLevel.prepend_if_ee('EE::Gitlab::BackgroundMigration::RemoveUndefinedVulnerabilitySeverityLevel') diff --git a/lib/gitlab/database/batch_count.rb b/lib/gitlab/database/batch_count.rb index a9d4665bc5f..728e0d423af 100644 --- a/lib/gitlab/database/batch_count.rb +++ b/lib/gitlab/database/batch_count.rb @@ -28,7 +28,7 @@ module Gitlab class BatchCounter FALLBACK = -1 - MIN_REQUIRED_BATCH_SIZE = 2_000 + MIN_REQUIRED_BATCH_SIZE = 1_250 MAX_ALLOWED_LOOPS = 10_000 SLEEP_TIME_IN_SECONDS = 0.01 # 10 msec sleep # Each query should take <<500ms https://gitlab.com/gitlab-org/gitlab/-/merge_requests/22705 diff --git a/lib/gitlab/gitaly_client.rb b/lib/gitlab/gitaly_client.rb index 4b5455c0ec9..3b9402da0dd 100644 --- a/lib/gitlab/gitaly_client.rb +++ b/lib/gitlab/gitaly_client.rb @@ -42,7 +42,7 @@ module Gitlab klass = stub_class(name) addr = stub_address(storage) creds = stub_creds(storage) - klass.new(addr, creds, interceptors: interceptors) + klass.new(addr, creds, interceptors: interceptors, channel_args: channel_args) end end end @@ -54,6 +54,16 @@ module Gitlab end private_class_method :interceptors + def self.channel_args + # These values match the go Gitaly client + # https://gitlab.com/gitlab-org/gitaly/-/blob/bf9f52bc/client/dial.go#L78 + { + 'grpc.keepalive_time_ms': 20000, + 'grpc.keepalive_permit_without_calls': 1 + } + end + private_class_method :channel_args + def self.stub_cert_paths cert_paths = Dir["#{OpenSSL::X509::DEFAULT_CERT_DIR}/*"] cert_paths << OpenSSL::X509::DEFAULT_CERT_FILE if File.exist? OpenSSL::X509::DEFAULT_CERT_FILE |