Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2022-04-27 21:11:05 +00:00
parent 6093748e9e
commit 04354e22bf
6 changed files with 128 additions and 197 deletions

View File

@ -103,7 +103,7 @@ yarn-audit-dependency_scanning:
extends: .default-retry extends: .default-retry
stage: test stage: test
image: image:
name: registry.gitlab.com/gitlab-org/security-products/package-hunter-cli:v1.3.1@sha256:582b70bdb002075e33d63758e4c55af376b9f50278f826b4366acce922a9e357 name: registry.gitlab.com/gitlab-org/security-products/package-hunter-cli:v1.3.2@sha256:7529deaef9ea21aab56bfb74ae1abbc121311affdb6ece49ce7b1c360f997ca2
entrypoint: [""] entrypoint: [""]
variables: variables:
HTR_user: '$PACKAGE_HUNTER_USER' HTR_user: '$PACKAGE_HUNTER_USER'

View File

@ -8,13 +8,13 @@ module Projects
def execute(container_repository) def execute(container_repository)
@container_repository = container_repository @container_repository = container_repository
unless params[:container_expiration_policy] unless container_expiration_policy?
return error('access denied') unless can?(current_user, :destroy_container_image, project) return error('access denied') unless can?(current_user, :destroy_container_image, project)
end end
@tag_names = params[:tags] @tag_names = params[:tags]
return error('not tags specified') if @tag_names.blank? return error('not tags specified') if @tag_names.blank?
return error('repository importing') if @container_repository.migration_importing? return error('repository importing') if cancel_while_importing?
delete_tags delete_tags
end end
@ -49,6 +49,20 @@ module Projects
log_error(log_data) log_error(log_data)
end end
end end
def cancel_while_importing?
return true if @container_repository.importing?
if container_expiration_policy?
return @container_repository.pre_importing? || @container_repository.pre_import_done?
end
false
end
def container_expiration_policy?
params[:container_expiration_policy].present?
end
end end
end end
end end

View File

@ -7,66 +7,56 @@ info: To determine the technical writer assigned to the Stage/Group associated w
# Import your project from GitHub to GitLab **(FREE)** # Import your project from GitHub to GitLab **(FREE)**
Using the importer, you can import your GitHub repositories to GitLab.com or to You can import your GitHub repositories:
your self-managed GitLab instance.
The following aspects of a project are imported: - From either GitHub.com or GitHub Enterprise.
- To either GitLab.com or a self-managed GitLab instance.
- Repository description (GitLab.com & 7.7+) This process does not migrate or import any types of groups or organizations from GitHub to GitLab.
- Git repository data (GitLab.com & 7.7+)
- Issues (GitLab.com & 7.7+)
- Pull requests (GitLab.com & 8.4+)
- Wiki pages (GitLab.com & 8.4+)
- Milestones (GitLab.com & 8.7+)
- Labels (GitLab.com & 8.7+)
- Release note descriptions (GitLab.com & 8.12+)
- Pull request review comments (GitLab.com & 10.2+)
- Pull request reviews (GitLab.com & 13.7+)
- Pull request "merged by" information (GitLab.com & 13.7+)
- Regular issue and pull request comments
- [Git Large File Storage (LFS) Objects](../../../topics/git/lfs/index.md)
- Pull request comments replies in discussions ([GitLab.com & 14.5+](https://gitlab.com/gitlab-org/gitlab/-/issues/336596))
- Diff Notes suggestions ([GitLab.com & 14.7+](https://gitlab.com/gitlab-org/gitlab/-/issues/340624))
References to pull requests and issues are preserved (GitLab.com & 8.7+), and The namespace is a user or group in GitLab, such as `gitlab.com/sidney-jones` or
each imported repository maintains visibility level unless that [visibility `gitlab.com/customer-success`. You can use bulk actions in the rails console to move projects to
level is restricted](../../public_access.md#restrict-use-of-public-or-internal-projects), different namespaces.
in which case it defaults to the default project visibility.
The namespace is a user or group in GitLab, such as `gitlab.com/janedoe` or If you are importing to a self-managed GitLab instance, you can use the
`gitlab.com/customer-success`. You can do some bulk actions to move projects to [GitHub Rake task](../../../administration/raketasks/github_import.md) instead. This allows you to import projects
different namespaces in the rails console. without the constraints of a [Sidekiq](../../../development/sidekiq/index.md) worker.
This process does not migrate or import any types of groups or organizations If you are importing from GitHub Enterprise to a self-managed GitLab instance:
from GitHub to GitLab.
## Use cases - You must first enable [GitHub integration](../../../integration/github.md).
- To import projects from GitHub Enterprise to GitLab.com, use the [Import API](../../../api/import.md).
- If GitLab is behind a HTTP/HTTPS proxy, you must populate the [allowlist for local requests](../../../security/webhooks.md#allowlist-for-local-requests)
with `github.com` and `api.github.com` to solve the hostname. For more information, read the issue
[Importing a GitHub project requires DNS resolution even when behind a proxy](https://gitlab.com/gitlab-org/gitlab/-/issues/37941).
The steps you take depend on whether you are importing from GitHub.com or If you are importing from GitHub.com to a self-managed GitLab instance:
GitHub Enterprise. The steps also depend on whether you are importing to GitLab.com or
self-managed GitLab instance.
- If you're importing to GitLab.com, you can alternatively import GitHub repositories - Setting up GitHub integration is not required.
using a [personal access token](#use-a-github-token). We do not recommend - You can use the [Import API](../../../api/import.md).
this method, as it does not associate all user activity (such as issues and
pull requests) with matching GitLab users.
- If you're importing to a self-managed GitLab instance, you can alternatively use the
[GitHub Rake task](../../../administration/raketasks/github_import.md) to import
projects without the constraints of a [Sidekiq](../../../development/sidekiq/index.md) worker.
- If you're importing from GitHub Enterprise to your self-managed GitLab instance:
- You must first enable [GitHub integration](../../../integration/github.md).
- To import projects from GitHub Enterprise to GitLab.com, use the [Import API](../../../api/import.md).
- If GitLab is behind a HTTP/HTTPS proxy you must populate the [allowlist for local requests](../../../security/webhooks.md#allowlist-for-local-requests)
with `github.com` and `api.github.com` to solve the hostname. For more information, read the issue
[Importing a GitHub project requires DNS resolution even when behind a proxy](https://gitlab.com/gitlab-org/gitlab/-/issues/37941)
- If you're importing from GitHub.com to your self-managed GitLab instance,
setting up GitHub integration is not required. You can use the [Import API](../../../api/import.md).
## How it works When importing projects:
- If a user referenced in the project is not found in the GitLab database, the project creator is set as the author and
assignee. The project creator is usually the user that initiated the import process. A note on the issue mentioning the
original GitHub author is added.
- The importer creates any new namespaces (or groups) if they do not exist, or, if the namespace is taken, the
repository is imported under the namespace of the user who initiated the import process. The namespace or repository
name can also be edited, with the proper permissions.
- The importer also imports branches on forks of projects related to open pull requests. These branches are
imported with a naming scheme similar to `GH-SHA-username/pull-request-number/fork-name/branch`. This may lead to
a discrepancy in branches compared to those of the GitHub repository.
For additional technical details, refer to the [GitHub Importer](../../../development/github_importer.md)
developer documentation.
For an overview of the import process, see the video [Migrating from GitHub to GitLab](https://youtu.be/VYOXuOg9tQI).
## Prerequisites
When issues and pull requests are being imported, the importer attempts to find When issues and pull requests are being imported, the importer attempts to find
their GitHub authors and assignees in the database of the GitLab instance (note their GitHub authors and assignees in the database of the GitLab instance. Pull requests are called _merge requests_ in
that pull requests are called "merge requests" in GitLab). GitLab.
For this association to succeed, each GitHub author and assignee in the repository For this association to succeed, each GitHub author and assignee in the repository
must meet one of the following conditions prior to the import: must meet one of the following conditions prior to the import:
@ -75,32 +65,9 @@ must meet one of the following conditions prior to the import:
- Have a GitHub account with a [public-facing email address](https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-github-user-account/managing-email-preferences/setting-your-commit-email-address) - Have a GitHub account with a [public-facing email address](https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-github-user-account/managing-email-preferences/setting-your-commit-email-address)
that matches their GitLab account's email address. that matches their GitLab account's email address.
NOTE: GitLab content imports that use GitHub accounts require that the GitHub public-facing email address is populated. This means
GitLab content imports that use GitHub accounts require that the GitHub all comments and contributions are properly mapped to the same user in GitLab. GitHub Enterprise does not require this
public-facing email address is populated so that all comments and field to be populated so you may have to add it on existing accounts.
contributions are properly mapped to the same user in GitLab. GitHub
Enterprise (on premise) does not require this field to be populated to use the
product, so you may have to add it on existing accounts for the imported
content to be properly mapped to the user in the new system. Refer to GitHub
documentation for instructions on how to add this email address.
If a user referenced in the project is not found in the GitLab database, the project creator (typically the user
that initiated the import process) is set as the author/assignee, but a note on the issue mentioning the original
GitHub author is added.
The importer creates any new namespaces (groups) if they do not exist, or, if the namespace is taken, the
repository is imported under the namespace of the user who initiated the import process. The namespace/repository
name can also be edited, with the proper permissions.
The importer will also import branches on forks of projects related to open pull requests. These branches will be
imported with a naming scheme similar to `GH-SHA-username/pull-request-number/fork-name/branch`. This may lead to
a discrepancy in branches compared to those of the GitHub repository.
For additional technical details, you can refer to the
[GitHub Importer](../../../development/github_importer.md "Working with the GitHub importer")
developer documentation.
For an overview of the import process, see the video [Migrating from GitHub to GitLab](https://youtu.be/VYOXuOg9tQI).
## Import your GitHub repository into GitLab ## Import your GitHub repository into GitLab
@ -108,10 +75,12 @@ For an overview of the import process, see the video [Migrating from GitHub to G
Before you begin, ensure that any GitHub users who you want to map to GitLab users have either: Before you begin, ensure that any GitHub users who you want to map to GitLab users have either:
- A GitLab account that has logged in using the GitHub icon - A GitLab account that has logged in using the GitHub icon.
\- or -
- A GitLab account with an email address that matches the [publicly visible email address](https://docs.github.com/en/rest/reference/users#get-a-user) in the profile of the GitHub user - A GitLab account with an email address that matches the [publicly visible email address](https://docs.github.com/en/rest/reference/users#get-a-user) in the profile of the GitHub user
If you are importing to GitLab.com, you can alternatively import GitHub repositories using a [personal access token](#use-a-github-token).
We do not recommend this method, as it does not associate all user activity (such as issues and pull requests) with matching GitLab users.
User-matching attempts occur in that order, and if a user is not identified either way, the activity is associated with User-matching attempts occur in that order, and if a user is not identified either way, the activity is associated with
the user account that is performing the import. the user account that is performing the import.
@ -119,10 +88,10 @@ NOTE:
If you are using a self-managed GitLab instance or if you are importing from GitHub Enterprise, this process requires that you have configured If you are using a self-managed GitLab instance or if you are importing from GitHub Enterprise, this process requires that you have configured
[GitHub integration](../../../integration/github.md). [GitHub integration](../../../integration/github.md).
1. From the top navigation bar, click **+** and select **New project**. 1. From the top navigation bar, select **+** and select **New project**.
1. Select the **Import project** tab and then select **GitHub**. 1. Select the **Import project** tab and then select **GitHub**.
1. Select the first button to **List your GitHub repositories**. You are redirected to a page on [GitHub](https://github.com) to authorize the GitLab application. 1. Select the first button to **List your GitHub repositories**. You are redirected to a page on [GitHub](https://github.com) to authorize the GitLab application.
1. Click **Authorize GitlabHQ**. You are redirected back to the GitLab Import page and all of your GitHub repositories are listed. 1. Select **Authorize GitlabHQ**. You are redirected back to the GitLab Import page and all of your GitHub repositories are listed.
1. Continue on to [selecting which repositories to import](#select-which-repositories-to-import). 1. Continue on to [selecting which repositories to import](#select-which-repositories-to-import).
### Use a GitHub token ### Use a GitHub token
@ -134,14 +103,13 @@ associate all user activity (such as issues and pull requests) with matching Git
If you are an administrator of a self-managed GitLab instance or if you are importing from If you are an administrator of a self-managed GitLab instance or if you are importing from
GitHub Enterprise, you cannot use a personal access token. GitHub Enterprise, you cannot use a personal access token.
The [GitHub integration method (above)](#use-the-github-integration) is recommended for all users. The [GitHub integration method (above)](#use-the-github-integration) is recommended for all users.
Read more in the [How it works](#how-it-works) section.
If you are not using the GitHub integration, you can still perform an authorization with GitHub to grant GitLab access your repositories: If you are not using the GitHub integration, you can still perform an authorization with GitHub to grant GitLab access your repositories:
1. Go to <https://github.com/settings/tokens/new> 1. Go to <https://github.com/settings/tokens/new>
1. Enter a token description. 1. Enter a token description.
1. Select the repository scope. 1. Select the repository scope.
1. Click **Generate token**. 1. Select **Generate token**.
1. Copy the token hash. 1. Copy the token hash.
1. Go back to GitLab and provide the token to the GitHub importer. 1. Go back to GitLab and provide the token to the GitHub importer.
1. Hit the **List Your GitHub Repositories** button and wait while GitLab reads your repositories' information. 1. Hit the **List Your GitHub Repositories** button and wait while GitLab reads your repositories' information.
@ -161,7 +129,7 @@ your GitHub repositories are listed.
you can filter projects by name. If filter is applied, **Import all repositories** only imports matched repositories. you can filter projects by name. If filter is applied, **Import all repositories** only imports matched repositories.
1. The **Status** column shows the import status of each repository. You can choose to leave the page open and it will 1. The **Status** column shows the import status of each repository. You can choose to leave the page open and it will
update in real-time or you can return to it later. update in real-time or you can return to it later.
1. Once a repository has been imported, click its GitLab path to open its GitLab URL. 1. Once a repository has been imported, select its GitLab path to open its GitLab URL.
![GitHub importer page](img/import_projects_from_github_importer_v12_3.png) ![GitHub importer page](img/import_projects_from_github_importer_v12_3.png)
@ -197,6 +165,30 @@ Reducing the time spent in cloning a repository can be done by increasing networ
performance (by using high performance SSDs, for example) of the disks that store the Git repositories (for your GitLab instance). performance (by using high performance SSDs, for example) of the disks that store the Git repositories (for your GitLab instance).
Increasing the number of Sidekiq workers does *not* reduce the time spent cloning repositories. Increasing the number of Sidekiq workers does *not* reduce the time spent cloning repositories.
## Imported data
The following items of a project are imported:
- Repository description.
- Git repository data.
- Issues.
- Pull requests.
- Wiki pages.
- Milestones.
- Labels.
- Release note descriptions.
- Pull request review comments.
- Regular issue and pull request comments.
- [Git Large File Storage (LFS) Objects](../../../topics/git/lfs/index.md).
- Pull request reviews (GitLab.com and GitLab 13.7 and later).
- Pull request "merged by" information (GitLab.com and GitLab 13.7 and later).
- Pull request comments replies in discussions ([GitLab.com and GitLab 14.5 and later](https://gitlab.com/gitlab-org/gitlab/-/issues/336596)).
- Diff Notes suggestions ([GitLab.com and GitLab 14.7 and later](https://gitlab.com/gitlab-org/gitlab/-/issues/340624)).
References to pull requests and issues are preserved. Each imported repository maintains visibility level unless that
[visibility level is restricted](../../public_access.md#restrict-use-of-public-or-internal-projects), in which case it
defaults to the default project visibility.
## Alternative way to import notes and diff notes ## Alternative way to import notes and diff notes
When GitHub Importer runs on extremely large projects not all notes & diff notes can be imported due to GitHub API `issues_comments` & `pull_requests_comments` endpoints limitation. When GitHub Importer runs on extremely large projects not all notes & diff notes can be imported due to GitHub API `issues_comments` & `pull_requests_comments` endpoints limitation.

View File

@ -5661,9 +5661,6 @@ msgstr ""
msgid "Based on" msgid "Based on"
msgstr "" msgstr ""
msgid "Basic information"
msgstr ""
msgid "Batch size" msgid "Batch size"
msgstr "" msgstr ""
@ -25072,48 +25069,9 @@ msgstr ""
msgid "Network:" msgid "Network:"
msgstr "" msgstr ""
msgid "NetworkPolicies|%{ifLabelStart}if%{ifLabelEnd} %{ruleType} %{isLabelStart}is%{isLabelEnd} %{ruleDirection} %{ruleSelector} %{directionLabelStart}and is inbound from a%{directionLabelEnd} %{rule} %{portsLabelStart}on%{portsLabelEnd} %{ports}"
msgstr ""
msgid "NetworkPolicies|%{ifLabelStart}if%{ifLabelEnd} %{ruleType} %{isLabelStart}is%{isLabelEnd} %{ruleDirection} %{ruleSelector} %{directionLabelStart}and is outbound to a%{directionLabelEnd} %{rule} %{portsLabelStart}on%{portsLabelEnd} %{ports}"
msgstr ""
msgid "NetworkPolicies|%{labelStart}And%{labelEnd} %{spanStart}send an Alert to GitLab.%{spanEnd}"
msgstr ""
msgid "NetworkPolicies|%{labelStart}Then%{labelEnd} %{action} %{spanStart}the network traffic.%{spanEnd}"
msgstr ""
msgid "NetworkPolicies|%{number} selected"
msgstr ""
msgid "NetworkPolicies|%{strongOpen}all%{strongClose} pods"
msgstr ""
msgid "NetworkPolicies|%{strongOpen}any%{strongClose} port"
msgstr ""
msgid "NetworkPolicies|.yaml mode" msgid "NetworkPolicies|.yaml mode"
msgstr "" msgstr ""
msgid "NetworkPolicies|Add alert"
msgstr ""
msgid "NetworkPolicies|Alerts are intended to be selectively used for a limited number of events that are potentially concerning and warrant a manual review. Alerts should not be used as a substitute for a SIEM or a logging tool. High volume alerts are likely to be dropped so as to preserve the stability of GitLab's integration with Kubernetes."
msgstr ""
msgid "NetworkPolicies|All selected"
msgstr ""
msgid "NetworkPolicies|Allow"
msgstr ""
msgid "NetworkPolicies|Allow all inbound traffic to %{selector} from %{ruleSelector} on %{ports}"
msgstr ""
msgid "NetworkPolicies|Allow all outbound traffic from %{selector} to %{ruleSelector} on %{ports}"
msgstr ""
msgid "NetworkPolicies|Are you sure you want to delete this policy? This action cannot be undone." msgid "NetworkPolicies|Are you sure you want to delete this policy? This action cannot be undone."
msgstr "" msgstr ""
@ -25126,15 +25084,9 @@ msgstr ""
msgid "NetworkPolicies|Delete policy: %{policy}" msgid "NetworkPolicies|Delete policy: %{policy}"
msgstr "" msgstr ""
msgid "NetworkPolicies|Deny all traffic"
msgstr ""
msgid "NetworkPolicies|Environment does not have deployment platform" msgid "NetworkPolicies|Environment does not have deployment platform"
msgstr "" msgstr ""
msgid "NetworkPolicies|IP/subnet"
msgstr ""
msgid "NetworkPolicies|Invalid or empty policy" msgid "NetworkPolicies|Invalid or empty policy"
msgstr "" msgstr ""
@ -25144,18 +25096,6 @@ msgstr ""
msgid "NetworkPolicies|Kubernetes error: %{error}" msgid "NetworkPolicies|Kubernetes error: %{error}"
msgstr "" msgstr ""
msgid "NetworkPolicies|Network Policies can be used to limit which network traffic is allowed between containers inside the cluster."
msgstr ""
msgid "NetworkPolicies|Network policy can be created after the environment is loaded successfully."
msgstr ""
msgid "NetworkPolicies|Network traffic"
msgstr ""
msgid "NetworkPolicies|None selected"
msgstr ""
msgid "NetworkPolicies|Policy %{policyName} was successfully changed" msgid "NetworkPolicies|Policy %{policyName} was successfully changed"
msgstr "" msgstr ""
@ -25174,51 +25114,6 @@ msgstr ""
msgid "NetworkPolicies|Something went wrong, unable to fetch policies" msgid "NetworkPolicies|Something went wrong, unable to fetch policies"
msgstr "" msgstr ""
msgid "NetworkPolicies|To enable alerts, %{installLinkStart}install an agent%{installLinkEnd} first."
msgstr ""
msgid "NetworkPolicies|all DNS names"
msgstr ""
msgid "NetworkPolicies|all IP addresses"
msgstr ""
msgid "NetworkPolicies|any pod"
msgstr ""
msgid "NetworkPolicies|any port"
msgstr ""
msgid "NetworkPolicies|domain name"
msgstr ""
msgid "NetworkPolicies|entity"
msgstr ""
msgid "NetworkPolicies|inbound to"
msgstr ""
msgid "NetworkPolicies|nowhere"
msgstr ""
msgid "NetworkPolicies|outbound from"
msgstr ""
msgid "NetworkPolicies|pod with labels"
msgstr ""
msgid "NetworkPolicies|pods %{pods}"
msgstr ""
msgid "NetworkPolicies|pods with labels"
msgstr ""
msgid "NetworkPolicies|ports %{ports}"
msgstr ""
msgid "NetworkPolicies|ports/protocols"
msgstr ""
msgid "NetworkPolicy|Policy" msgid "NetworkPolicy|Policy"
msgstr "" msgstr ""
@ -33762,9 +33657,6 @@ msgstr ""
msgid "SecurityOrchestration|Policy status" msgid "SecurityOrchestration|Policy status"
msgstr "" msgstr ""
msgid "SecurityOrchestration|Policy summary"
msgstr ""
msgid "SecurityOrchestration|Policy type" msgid "SecurityOrchestration|Policy type"
msgstr "" msgstr ""

View File

@ -33,7 +33,11 @@ module QA
super super
rescue ResourceNotFoundError rescue ResourceNotFoundError
super result = super
project.wait_for_push(commit_message)
result
end end
def api_get_path def api_get_path

View File

@ -3,6 +3,7 @@
require 'spec_helper' require 'spec_helper'
RSpec.describe Projects::ContainerRepository::DeleteTagsService do RSpec.describe Projects::ContainerRepository::DeleteTagsService do
using RSpec::Parameterized::TableSyntax
include_context 'container repository delete tags service shared context' include_context 'container repository delete tags service shared context'
let(:service) { described_class.new(project, user, params) } let(:service) { described_class.new(project, user, params) }
@ -157,11 +158,39 @@ RSpec.describe Projects::ContainerRepository::DeleteTagsService do
end end
context 'when the repository is importing' do context 'when the repository is importing' do
before do where(:migration_state, :called_by_policy, :error_expected) do
repository.update_columns(migration_state: 'importing', migration_import_started_at: Time.zone.now) 'default' | false | false
'default' | true | false
'pre_importing' | false | false
'pre_importing' | true | true
'pre_import_done' | false | false
'pre_import_done' | true | true
'importing' | false | true
'importing' | true | true
'import_done' | false | false
'import_done' | true | false
'import_aborted' | false | false
'import_aborted' | true | false
'import_skipped' | false | false
'import_skipped' | true | false
end end
it { is_expected.to include(status: :error, message: 'repository importing') } with_them do
let(:params) { { tags: tags, container_expiration_policy: called_by_policy ? true : nil } }
before do
repository.update_columns(migration_state: migration_state, migration_import_started_at: Time.zone.now, migration_pre_import_started_at: Time.zone.now, migration_pre_import_done_at: Time.zone.now)
end
it 'returns an error response if expected' do
if error_expected
expect(subject).to include(status: :error, message: 'repository importing')
else
expect(service).to receive(:delete_tags).and_return(status: :success)
expect(subject).not_to include(status: :error)
end
end
end
end end
end end