Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2022-08-16 00:10:02 +00:00
parent a2fd863d3b
commit 5074a6923e
27 changed files with 174 additions and 55 deletions

View File

@ -92,6 +92,7 @@ Style/SymbolProc:
- 'db/migrate/20210318134427_delete_security_findings_without_uuid.rb'
- 'db/migrate/20210503105845_add_project_value_stream_id_to_project_stages.rb'
- 'db/post_migrate/20220119094503_populate_audit_event_streaming_verification_token.rb'
- 'db/post_migrate/20220803042352_cleanup_mr_attention_request_todos.rb'
- 'ee/app/helpers/ee/mirror_helper.rb'
- 'ee/app/helpers/ee/registrations_helper.rb'
- 'ee/app/models/concerns/epic_tree_sorting.rb'

View File

@ -578,8 +578,8 @@ GEM
retriable (>= 2.0, < 4.0)
rexml
signet (~> 0.12)
google-cloud-env (1.5.0)
faraday (>= 0.17.3, < 2.0)
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
google-protobuf (3.21.3)
googleapis-common-protos-types (1.3.0)
google-protobuf (~> 3.14)

View File

@ -80,4 +80,16 @@ class Projects::GoogleCloud::BaseController < Projects::ApplicationController
Gitlab::Tracking.event('Projects::GoogleCloud', action, **options)
end
def gcp_projects
google_api_client = GoogleApi::CloudPlatform::Client.new(token_in_session, nil)
google_api_client.list_projects
end
def refs
params = { per_page: 50 }
branches = BranchesFinder.new(project.repository, params).execute(gitaly_pagination: true)
tags = TagsFinder.new(project.repository, params).execute(gitaly_pagination: true)
(branches + tags).map(&:name)
end
end

View File

@ -4,7 +4,6 @@ module Projects
module GoogleCloud
class ConfigurationController < Projects::GoogleCloud::BaseController
def index
@google_cloud_path = project_google_cloud_configuration_path(project)
js_data = {
configurationUrl: project_google_cloud_configuration_path(project),
deploymentsUrl: project_google_cloud_deployments_path(project),

View File

@ -4,7 +4,6 @@ module Projects
module GoogleCloud
class DatabasesController < Projects::GoogleCloud::BaseController
def index
@google_cloud_path = project_google_cloud_configuration_path(project)
js_data = {
configurationUrl: project_google_cloud_configuration_path(project),
deploymentsUrl: project_google_cloud_deployments_path(project),

View File

@ -4,7 +4,6 @@ class Projects::GoogleCloud::DeploymentsController < Projects::GoogleCloud::Base
before_action :validate_gcp_token!
def index
@google_cloud_path = project_google_cloud_configuration_path(project)
js_data = {
configurationUrl: project_google_cloud_configuration_path(project),
deploymentsUrl: project_google_cloud_deployments_path(project),

View File

@ -9,11 +9,6 @@ class Projects::GoogleCloud::GcpRegionsController < Projects::GoogleCloud::BaseC
GCP_REGION_CI_VAR_KEY = 'GCP_REGION'
def index
@google_cloud_path = project_google_cloud_configuration_path(project)
params = { per_page: 50 }
branches = BranchesFinder.new(project.repository, params).execute(gitaly_pagination: true)
tags = TagsFinder.new(project.repository, params).execute(gitaly_pagination: true)
refs = (branches + tags).map(&:name)
js_data = {
availableRegions: AVAILABLE_REGIONS,
refs: refs,

View File

@ -4,19 +4,11 @@ class Projects::GoogleCloud::ServiceAccountsController < Projects::GoogleCloud::
before_action :validate_gcp_token!
def index
@google_cloud_path = project_google_cloud_configuration_path(project)
google_api_client = GoogleApi::CloudPlatform::Client.new(token_in_session, nil)
gcp_projects = google_api_client.list_projects
if gcp_projects.empty?
track_event('service_accounts#index', 'error_form', 'no_gcp_projects')
flash[:warning] = _('No Google Cloud projects - You need at least one Google Cloud project')
redirect_to project_google_cloud_configuration_path(project)
else
params = { per_page: 50 }
branches = BranchesFinder.new(project.repository, params).execute(gitaly_pagination: true)
tags = TagsFinder.new(project.repository, params).execute(gitaly_pagination: true)
refs = (branches + tags).map(&:name)
js_data = {
gcpProjects: gcp_projects,
refs: refs,

View File

@ -22,6 +22,14 @@ module Admin
def saml_group_link(identity)
'-'
end
def identity_cells_to_render?(identities, _user)
identities.present?
end
def scim_identities_collection(_user)
[]
end
end
end

View File

@ -11,8 +11,10 @@
%th{ class: 'gl-border-t-0!' }= _('Group')
%th{ class: 'gl-border-t-0!' }= _('Identifier')
%th{ class: 'gl-border-t-0!' }= _('Actions')
= render @identities
- if @identities.blank?
- if identity_cells_to_render?(@identities, @user)
= render_if_exists partial: 'admin/identities/scim_identity', collection: scim_identities_collection(@user)
= render @identities
- else
%tbody
%tr
%td{ colspan: '5' }

View File

@ -1,4 +1,4 @@
- add_to_breadcrumbs _('Google Cloud'), @google_cloud_path
- add_to_breadcrumbs _('Google Cloud'), project_google_cloud_path(@project)
- breadcrumb_title s_('CloudSeed|Configuration')
- page_title s_('CloudSeed|Configuration')

View File

@ -1,4 +1,4 @@
- add_to_breadcrumbs _('Google Cloud'), @google_cloud_path
- add_to_breadcrumbs _('Google Cloud'), project_google_cloud_path(@project)
- breadcrumb_title s_('CloudSeed|Databases')
- page_title s_('CloudSeed|Databases')

View File

@ -1,4 +1,4 @@
- add_to_breadcrumbs _('Google Cloud'), @google_cloud_path
- add_to_breadcrumbs _('Google Cloud'), project_google_cloud_path(@project)
- breadcrumb_title s_('CloudSeed|Deployments')
- page_title s_('CloudSeed|Deployments')

View File

@ -1,4 +1,4 @@
- add_to_breadcrumbs _('Google Cloud'), @google_cloud_path
- add_to_breadcrumbs _('Google Cloud'), project_google_cloud_path(@project)
- breadcrumb_title _('CloudSeed|Regions')
- page_title s_('CloudSeed|Regions')

View File

@ -1,4 +1,4 @@
- add_to_breadcrumbs _('Google Cloud'), @google_cloud_path
- add_to_breadcrumbs _('Google Cloud'), project_google_cloud_path(@project)
- breadcrumb_title s_('CloudSeed|Service Account')
- page_title s_('CloudSeed|Service Account')

View File

@ -298,6 +298,8 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources :terraform, only: [:index]
namespace :google_cloud do
get '/', to: redirect('%{namespace_id}/%{project_id}/-/google_cloud/configuration')
get '/configuration', to: 'configuration#index'
resources :revoke_oauth, only: [:create]

View File

@ -0,0 +1,18 @@
# frozen_string_literal: true
class AddTmpIndexTodosAttentionRequestAction < Gitlab::Database::Migration[2.0]
INDEX_NAME = "tmp_index_todos_attention_request_action"
ATTENTION_REQUESTED = 10
disable_ddl_transaction!
def up
add_concurrent_index :todos, [:id],
where: "action = #{ATTENTION_REQUESTED}",
name: INDEX_NAME
end
def down
remove_concurrent_index_by_name :todos, INDEX_NAME
end
end

View File

@ -0,0 +1,24 @@
# frozen_string_literal: true
class CleanupMrAttentionRequestTodos < Gitlab::Database::Migration[2.0]
disable_ddl_transaction!
restrict_gitlab_migration gitlab_schema: :gitlab_main
class Todo < MigrationRecord
self.table_name = 'todos'
include ::EachBatch
ATTENTION_REQUESTED = 10
end
def up
Todo.where(action: Todo::ATTENTION_REQUESTED).each_batch do |todos_batch|
todos_batch.delete_all
end
end
def down
# Attention request feature has been reverted.
end
end

View File

@ -0,0 +1 @@
50c58b03d92451753cbdcb2e820e7d1ca9644f914027db46b57d2206e7832ec7

View File

@ -0,0 +1 @@
03d95257a9169a33a90baf28a6737f68fb999f920450a1cb90732820490be1c4

View File

@ -30514,6 +30514,8 @@ CREATE INDEX tmp_index_on_vulnerabilities_non_dismissed ON vulnerabilities USING
CREATE INDEX tmp_index_project_statistics_cont_registry_size ON project_statistics USING btree (project_id) WHERE (container_registry_size = 0);
CREATE INDEX tmp_index_todos_attention_request_action ON todos USING btree (id) WHERE (action = 10);
CREATE INDEX tmp_index_vulnerability_occurrences_on_id_and_scanner_id ON vulnerability_occurrences USING btree (id, scanner_id) WHERE (report_type = ANY (ARRAY[7, 99]));
CREATE UNIQUE INDEX uniq_pkgs_deb_grp_architectures_on_distribution_id_and_name ON packages_debian_group_architectures USING btree (distribution_id, name);

View File

@ -423,23 +423,6 @@ projects = Project.find_by_sql("SELECT * FROM projects WHERE name LIKE '%ject'")
=> [#<Project id:12 root/my-first-project>>, #<Project id:13 root/my-second-project>>]
```
## Wikis
### Recreate
WARNING:
This is a destructive operation, the Wiki becomes empty.
A Projects Wiki can be recreated by this command:
```ruby
p = Project.find_by_full_path('<username-or-group>/<project-name>') ### enter your projects path
GitlabShellWorker.perform_in(0, :remove_repository, p.repository_storage, p.wiki.disk_path) ### deletes the wiki project from the filesystem
p.create_wiki ### creates the wiki project on the filesystem
```
## Issue boards
### In case of issue boards not loading properly and it's getting time out. Call the Issue Rebalancing service to fix this

View File

@ -382,3 +382,26 @@ In GitLab 14.9 and later, page slugs are now encoded using the
[`ERB::Util.url_encode`](https://www.rubydoc.info/stdlib/erb/ERB%2FUtil.url_encode) method.
If you use an Apache reverse proxy, you can add a `nocanon` argument to the `ProxyPass`
line of your Apache configuration to ensure your page slugs render correctly.
### Recreate a project wiki with the Rails console **(FREE SELF)**
WARNING:
This operation deletes all data in the wiki.
To clear all data from a project wiki and recreate it in a blank state:
1. [Start a Rails console session](../../../administration/operations/rails_console.md#starting-a-rails-console-session).
1. Run these commands:
```ruby
# Enter your project's path
p = Project.find_by_full_path('<username-or-group>/<project-name>')
# This command deletes the wiki project from the filesystem.
GitlabShellWorker.perform_in(0, :remove_repository, p.repository_storage, p.wiki.disk_path)
# Refresh the wiki repository state.
p.wiki.repository.expire_exists_cache
```
All data from the wiki has been cleared, and the wiki is ready for use.

View File

@ -166,10 +166,7 @@ module GoogleApi
end
def list_cloudsql_databases(gcp_project_id, instance_name)
service = Google::Apis::SqladminV1beta4::SQLAdminService.new
service.authorization = access_token
service.list_databases(gcp_project_id, instance_name, options: user_agent_header)
sql_admin_service.list_databases(gcp_project_id, instance_name, options: user_agent_header)
end
def create_cloudsql_database(gcp_project_id, instance_name, database_name)
@ -178,10 +175,7 @@ module GoogleApi
end
def list_cloudsql_users(gcp_project_id, instance_name)
service = Google::Apis::SqladminV1beta4::SQLAdminService.new
service.authorization = access_token
service.list_users(gcp_project_id, instance_name, options: user_agent_header)
sql_admin_service.list_users(gcp_project_id, instance_name, options: user_agent_header)
end
def create_cloudsql_user(gcp_project_id, instance_name, username, password)
@ -204,9 +198,7 @@ module GoogleApi
settings: Google::Apis::SqladminV1beta4::Settings.new(tier: tier)
)
service = Google::Apis::SqladminV1beta4::SQLAdminService.new
service.authorization = access_token
service.insert_instance(gcp_project_id, database_instance)
sql_admin_service.insert_instance(gcp_project_id, database_instance)
end
private

View File

@ -148,8 +148,8 @@ GEM
google-apis-core (>= 0.4, < 2.a)
google-apis-storage_v1 (0.9.0)
google-apis-core (>= 0.4, < 2.a)
google-cloud-env (1.5.0)
faraday (>= 0.17.3, < 2.0)
google-cloud-env (1.6.0)
faraday (>= 0.17.3, < 3.0)
googleauth (1.1.0)
faraday (>= 0.17.3, < 2.0)
jwt (>= 1.4, < 3.0)

View File

@ -35,4 +35,24 @@ RSpec.describe Admin::IdentitiesHelper do
expect(helper.saml_group_link(identity)).to eq '-'
end
end
describe '#identity_cells_to_render?' do
context 'without identities' do
it 'returns false' do
expect(helper.identity_cells_to_render?([], user)).to eq false
end
end
context 'with identities' do
it 'returns true' do
expect(helper.identity_cells_to_render?(identity, user)).to eq true
end
end
end
describe '#scim_identities_collection' do
it 'returns empty array' do
expect(helper.scim_identities_collection(user)).to eq []
end
end
end

View File

@ -0,0 +1,46 @@
# frozen_string_literal: true
require 'spec_helper'
require_migration!
RSpec.describe CleanupMrAttentionRequestTodos, :migration do
let(:projects) { table(:projects) }
let(:namespaces) { table(:namespaces) }
let(:users) { table(:users) }
let(:todos) { table(:todos) }
let(:author) { users.create!(projects_limit: 1) }
let(:namespace) { namespaces.create!(name: 'test', path: 'test') }
let(:project) do
projects.create!(
namespace_id: namespace.id,
project_namespace_id: namespace.id,
name: 'test-project'
)
end
let(:attention_requested) { 10 }
let(:todo_attrs) do
{
project_id: project.id,
author_id: author.id,
user_id: author.id,
target_type: 'TestType',
state: 'pending'
}
end
let!(:todo1) { todos.create!(todo_attrs.merge(action: Todo::ASSIGNED)) }
let!(:todo2) { todos.create!(todo_attrs.merge(action: Todo::MENTIONED)) }
let!(:todo3) { todos.create!(todo_attrs.merge(action: Todo::REVIEW_REQUESTED)) }
let!(:todo4) { todos.create!(todo_attrs.merge(action: attention_requested)) }
let!(:todo5) { todos.create!(todo_attrs.merge(action: attention_requested)) }
describe '#up' do
it 'clean up attention request todos' do
expect { migrate! }.to change(todos, :count).by(-2)
expect(todos.all).to include(todo1, todo2, todo3)
end
end
end