Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2022-10-24 09:11:03 +00:00
parent 4bb7b91adf
commit fda0e422a7
24 changed files with 183 additions and 14 deletions

View File

@ -12,6 +12,8 @@ module Types
field :id, ::Types::GlobalIDType[::Packages::Package], null: false, description: 'ID of the package.'
field :_links, Types::Packages::PackageLinksType, null: false, method: :itself,
description: 'Map of links to perform actions on the package.'
field :can_destroy, GraphQL::Types::Boolean, null: false, description: 'Whether the user can destroy the package.'
field :created_at, Types::TimeType, null: false, description: 'Date of creation.'
field :metadata, Types::Packages::MetadataType,

View File

@ -0,0 +1,19 @@
# frozen_string_literal: true
module Types
module Packages
class PackageLinksType < BaseObject
graphql_name 'PackageLinks'
description 'Represents links to perform actions on the package'
authorize :read_package
include ::Routing::PackagesHelper
field :web_path, GraphQL::Types::String, null: true, description: 'Path to the package details page.'
def web_path
package_path(object)
end
end
end
end

View File

@ -17,6 +17,7 @@ module GitlabRoutingHelper
include ::Routing::WikiHelper
include ::Routing::GraphqlHelper
include ::Routing::PseudonymizationHelper
include ::Routing::PackagesHelper
included do
Gitlab::Routing.includes_helpers(self)
end

View File

@ -0,0 +1,9 @@
# frozen_string_literal: true
module Routing
module PackagesHelper
def package_path(package, **options)
Gitlab::UrlBuilder.build(package, only_path: true, **options)
end
end
end

View File

@ -5,6 +5,7 @@ module Ci
include Ci::HasVariable
include Presentable
include Ci::Maskable
include Ci::RawVariable
prepend HasEnvironmentScope
belongs_to :group, class_name: "::Group"

View File

@ -5,6 +5,7 @@ module Ci
extend Gitlab::ProcessMemoryCache::Helper
include Ci::NewHasVariable
include Ci::Maskable
include Ci::RawVariable
include Limitable
self.limit_name = 'ci_instance_level_variables'

View File

@ -3,6 +3,7 @@
module Ci
class JobVariable < Ci::ApplicationRecord
include Ci::NewHasVariable
include Ci::RawVariable
include BulkInsertSafe
belongs_to :job, class_name: "Ci::Build", foreign_key: :job_id

View File

@ -3,6 +3,7 @@
module Ci
class PipelineScheduleVariable < Ci::ApplicationRecord
include Ci::HasVariable
include Ci::RawVariable
belongs_to :pipeline_schedule

View File

@ -4,6 +4,7 @@ module Ci
class PipelineVariable < Ci::ApplicationRecord
include Ci::Partitionable
include Ci::HasVariable
include Ci::RawVariable
belongs_to :pipeline

View File

@ -5,6 +5,7 @@ module Ci
include Ci::HasVariable
include Presentable
include Ci::Maskable
include Ci::RawVariable
prepend HasEnvironmentScope
belongs_to :project

View File

@ -0,0 +1,17 @@
# frozen_string_literal: true
module Ci
module RawVariable
extend ActiveSupport::Concern
included do
validates :raw, inclusion: { in: [true, false] }
end
private
def uncached_runner_variable
super.merge(raw: raw?)
end
end
end

View File

@ -54,7 +54,7 @@
= hidden_field_tag "filter", h(params[:filter])
.search-holder
.search-field-holder.gl-mb-4
= search_field_tag :search_query, params[:search_query], placeholder: s_('AdminUsers|Search by name, email or username'), class: 'form-control search-text-input js-search-input', spellcheck: false, data: { qa_selector: 'user_search_field' }
= search_field_tag :search_query, params[:search_query], placeholder: s_('AdminUsers|Search by name, email, or username'), class: 'form-control search-text-input js-search-input', spellcheck: false, data: { qa_selector: 'user_search_field' }
- if @sort.present?
= hidden_field_tag :sort, @sort
= sprite_icon('search', css_class: 'search-icon')

View File

@ -15696,6 +15696,7 @@ Represents a package with pipelines in the Package Registry.
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="package_links"></a>`_links` | [`PackageLinks!`](#packagelinks) | Map of links to perform actions on the package. |
| <a id="packagecandestroy"></a>`canDestroy` | [`Boolean!`](#boolean) | Whether the user can destroy the package. |
| <a id="packagecreatedat"></a>`createdAt` | [`Time!`](#time) | Date of creation. |
| <a id="packageid"></a>`id` | [`PackagesPackageID!`](#packagespackageid) | ID of the package. |
@ -15717,6 +15718,7 @@ Represents a package in the Package Registry.
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="packagebase_links"></a>`_links` | [`PackageLinks!`](#packagelinks) | Map of links to perform actions on the package. |
| <a id="packagebasecandestroy"></a>`canDestroy` | [`Boolean!`](#boolean) | Whether the user can destroy the package. |
| <a id="packagebasecreatedat"></a>`createdAt` | [`Time!`](#time) | Date of creation. |
| <a id="packagebaseid"></a>`id` | [`PackagesPackageID!`](#packagespackageid) | ID of the package. |
@ -15775,6 +15777,7 @@ Represents a package details in the Package Registry.
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="packagedetailstype_links"></a>`_links` | [`PackageLinks!`](#packagelinks) | Map of links to perform actions on the package. |
| <a id="packagedetailstypecandestroy"></a>`canDestroy` | [`Boolean!`](#boolean) | Whether the user can destroy the package. |
| <a id="packagedetailstypecomposerconfigrepositoryurl"></a>`composerConfigRepositoryUrl` | [`String`](#string) | Url of the Composer setup endpoint. |
| <a id="packagedetailstypecomposerurl"></a>`composerUrl` | [`String`](#string) | Url of the Composer endpoint. |
@ -15893,6 +15896,16 @@ Represents the contents of a Helm Chart.yml file.
| <a id="packagehelmmetadatatypetype"></a>`type` | [`String`](#string) | Type of the chart. |
| <a id="packagehelmmetadatatypeversion"></a>`version` | [`String!`](#string) | Version of the chart. |
### `PackageLinks`
Represents links to perform actions on the package.
#### Fields
| Name | Type | Description |
| ---- | ---- | ----------- |
| <a id="packagelinkswebpath"></a>`webPath` | [`String`](#string) | Path to the package details page. |
### `PackageSettings`
Namespace-level Package Registry settings.

View File

@ -215,6 +215,42 @@ def down
end
```
## Indexes for partitioned tables
Indexes [cannot be created](https://www.postgresql.org/docs/15/ddl-partitioning.html#DDL-PARTITIONING-DECLARATIVE-MAINTENANCE)
**concurrently** on a partitioned table. You must use `CONCURRENTLY` to avoid service disruption in a hot system.
To create an index on a partitioned table, use `add_concurrent_partitioned_index`, provided by the database team.
Under the hood, `add_concurrent_partitioned_index`:
1. Creates indexes on each partition using `CONCURRENTLY`.
1. Creates an index on the parent table.
A Rails migration example:
```ruby
# in db/post_migrate/
class AddIndexToPartitionedTable < Gitlab::Database::Migration[2.0]
include Gitlab::Database::PartitioningMigrationHelpers
disable_ddl_transaction!
TABLE_NAME = :table_name
COLUMN_NAMES = [:partition_id, :id]
INDEX_NAME = :index_name
def up
add_concurrent_partitioned_index(TABLE_NAME, COLUMN_NAMES, name: INDEX_NAME)
end
def down
remove_concurrent_partitioned_index_by_name(TABLE_NAME, INDEX_NAME)
end
end
```
## Create indexes asynchronously
For very large tables, index creation can be a challenge to manage.

View File

@ -376,6 +376,8 @@ Upgrading across multiple GitLab versions in one go is *only possible by accepti
The following examples assume downtime is acceptable while upgrading.
If you don't want any downtime, read how to [upgrade with zero downtime](zero_downtime.md).
For a dynamic view of examples of supported upgrade paths, try the [Upgrade Path tool](https://gitlab-com.gitlab.io/support/toolbox/upgrade-path/) maintained by the [GitLab Support team](https://about.gitlab.com/handbook/support/#about-the-support-team). To share feedback and help improve the tool, create an issue or MR in the [upgrade-path project](https://gitlab.com/gitlab-com/support/toolbox/upgrade-path).
Find where your version sits in the upgrade path below, and upgrade GitLab
accordingly, while also consulting the
[version-specific upgrade instructions](#version-specific-upgrading-instructions):
@ -392,8 +394,6 @@ The following table, while not exhaustive, shows some examples of the supported
upgrade paths.
Additional steps between the mentioned versions are possible. We list the minimally necessary steps only.
For a dynamic view of examples of supported upgrade paths, try the [Upgrade Path tool](https://gitlab-com.gitlab.io/support/toolbox/upgrade-path/). The Upgrade Path tool is maintained by the [GitLab Support team](https://about.gitlab.com/handbook/support/#about-the-support-team). Share feedback and help improve the tool by raising an issue or MR in the [upgrade-path project](https://gitlab.com/gitlab-com/support/toolbox/upgrade-path).
| Target version | Your version | Supported upgrade path | Note |
| -------------- | ------------ | ---------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `15.1.0` | `14.6.2` | `14.6.2` -> `14.9.5` -> `14.10.5` -> `15.0.2` -> `15.1.0` | Three intermediate versions are required: `14.9` and `14.10`, `15.0`, then `15.1.0`. |

View File

@ -4,6 +4,7 @@ module API
module Entities
class Package < Grape::Entity
include ::API::Helpers::RelatedResourcesHelpers
include ::Routing::PackagesHelper
extend ::API::Entities::EntityHelpers
expose :id
@ -25,12 +26,8 @@ module API
expose :status
expose :_links do
expose :web_path do |package, opts|
if package.infrastructure_package?
::Gitlab::Routing.url_helpers.namespace_project_infrastructure_registry_path(opts[:namespace], package.project, package)
else
::Gitlab::Routing.url_helpers.project_package_path(package.project, package)
end
expose :web_path do |package|
package_path(package)
end
expose :delete_api_path, if: can_destroy(:package, &:project) do |package|

View File

@ -48,9 +48,8 @@ module Gitlab
end
##
# If `file: true` has been provided we expose it, otherwise we
# don't expose `file` attribute at all (stems from what the runner
# expects).
# If `file: true` or `raw: true` has been provided we expose it, otherwise we
# don't expose `file` and `raw` attributes at all (stems from what the runner expects).
#
def to_runner_variable
@variable.reject do |hash_key, hash_value|

View File

@ -52,6 +52,8 @@ module Gitlab
wiki_page_url(object.wiki, object, **options)
when ::DesignManagement::Design
design_url(object, **options)
when ::Packages::Package
package_url(object, **options)
else
raise NotImplementedError, "No URL builder defined for #{object.inspect}"
end
@ -133,6 +135,17 @@ module Gitlab
instance.project_design_management_designs_raw_image_url(design.project, design, ref, **options)
end
end
def package_url(package, **options)
project = package.project
if package.infrastructure_package?
return instance.project_infrastructure_registry_url(project, package,
**options)
end
instance.project_package_url(project, package, **options)
end
end
end
end

View File

@ -3301,7 +3301,7 @@ msgstr ""
msgid "AdminUsers|Restore user access to the account, including web, Git and API."
msgstr ""
msgid "AdminUsers|Search by name, email or username"
msgid "AdminUsers|Search by name, email, or username"
msgstr ""
msgid "AdminUsers|Search users"

View File

@ -14,7 +14,8 @@
"versions",
"status",
"canDestroy",
"lastDownloadedAt"
"lastDownloadedAt",
"_links"
],
"properties": {
"id": {
@ -177,6 +178,15 @@
},
"lastDownloadedAt": {
"type": ["string", "null"]
},
"_links": {
"type": "object",
"additionalProperties": false,
"properties": {
"webPath": {
"type": ["string", "null"]
}
}
}
}
}

View File

@ -0,0 +1,13 @@
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe ::Routing::PackagesHelper do
describe '#package_path' do
let(:package) { build_stubbed(:package) }
it "creates package's path" do
expect(helper.package_path(package)).to eq("/#{package.project.full_path}/-/packages/#{package.id}")
end
end
end

View File

@ -56,6 +56,7 @@ RSpec.describe Gitlab::UrlBuilder do
:discussion_note_on_project_snippet | ->(note) { "/#{note.project.full_path}/-/snippets/#{note.noteable_id}#note_#{note.id}" }
:discussion_note_on_personal_snippet | ->(note) { "/-/snippets/#{note.noteable_id}#note_#{note.id}" }
:note_on_personal_snippet | ->(note) { "/-/snippets/#{note.noteable_id}#note_#{note.id}" }
:package | ->(package) { "/#{package.project.full_path}/-/packages/#{package.id}" }
end
with_them do
@ -196,6 +197,18 @@ RSpec.describe Gitlab::UrlBuilder do
end
end
context 'when passing Packages::Package' do
let(:package) { build_stubbed(:terraform_module_package) }
context 'with infrastructure package' do
it 'returns the url for infrastucture registry' do
url = subject.build(package)
expect(url).to eq "#{Gitlab.config.gitlab.url}/#{package.project.full_path}/-/infrastructure_registry/#{package.id}"
end
end
end
context 'when passing a DesignManagement::Design' do
let(:design) { build_stubbed(:design) }

View File

@ -84,6 +84,7 @@ RSpec.describe Ci::HasVariable do
key: subject.key,
value: subject.value,
public: false,
raw: false,
masked: false
}
end

View File

@ -206,5 +206,25 @@ RSpec.describe 'package details' do
expect(graphql_data_at(:package, :composer_config_repository_url)).to eq("localhost/#{group.id}")
end
end
context 'web_path' do
before do
subject
end
it 'returns web_path correctly' do
expect(graphql_data_at(:package, :_links, :web_path)).to eq("/#{project.full_path}/-/packages/#{composer_package.id}")
end
context 'with terraform module' do
let_it_be(:terraform_package) { create(:terraform_module_package, project: project) }
let(:package_global_id) { global_id_of(terraform_package) }
it 'returns web_path correctly' do
expect(graphql_data_at(:package, :_links, :web_path)).to eq("/#{project.full_path}/-/infrastructure_registry/#{terraform_package.id}")
end
end
end
end
end