Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-10-13 12:12:02 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-10-13 12:12:02 +0300
commitce79b3dd66d0e9616d547f90a93cce0b709407a3 (patch)
treed862546e33d6551e47d25ce70aa9e5167e98dfeb /app
parent95ce32c508b9d6c9bda443f0762b92ec71074777 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/models/container_registry/protection.rb9
-rw-r--r--app/models/container_registry/protection/rule.rb20
-rw-r--r--app/models/group.rb6
-rw-r--r--app/models/member.rb2
-rw-r--r--app/models/members/member_task.rb44
-rw-r--r--app/models/project.rb1
-rw-r--r--app/models/project_team.rb6
-rw-r--r--app/services/deployments/create_for_job_service.rb2
-rw-r--r--app/services/deployments/create_service.rb1
-rw-r--r--app/services/tasks_to_be_done/base_service.rb55
-rw-r--r--app/services/tasks_to_be_done/create_ci_task_service.rb44
-rw-r--r--app/services/tasks_to_be_done/create_code_task_service.rb52
-rw-r--r--app/services/tasks_to_be_done/create_issues_task_service.rb43
13 files changed, 34 insertions, 251 deletions
diff --git a/app/models/container_registry/protection.rb b/app/models/container_registry/protection.rb
new file mode 100644
index 00000000000..33c94c0c893
--- /dev/null
+++ b/app/models/container_registry/protection.rb
@@ -0,0 +1,9 @@
+# frozen_string_literal: true
+
+module ContainerRegistry
+ module Protection
+ def self.table_name_prefix
+ 'container_registry_protection_'
+ end
+ end
+end
diff --git a/app/models/container_registry/protection/rule.rb b/app/models/container_registry/protection/rule.rb
new file mode 100644
index 00000000000..a91f3633d75
--- /dev/null
+++ b/app/models/container_registry/protection/rule.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+module ContainerRegistry
+ module Protection
+ class Rule < ApplicationRecord
+ enum delete_protected_up_to_access_level:
+ Gitlab::Access.sym_options_with_owner.slice(:maintainer, :owner, :developer),
+ _prefix: :delete_protected_up_to
+ enum push_protected_up_to_access_level:
+ Gitlab::Access.sym_options_with_owner.slice(:maintainer, :owner, :developer),
+ _prefix: :push_protected_up_to
+
+ belongs_to :project, inverse_of: :container_registry_protection_rules
+
+ validates :container_path_pattern, presence: true, uniqueness: { scope: :project_id }, length: { maximum: 255 }
+ validates :delete_protected_up_to_access_level, presence: true
+ validates :push_protected_up_to_access_level, presence: true
+ end
+ end
+end
diff --git a/app/models/group.rb b/app/models/group.rb
index bc6125887d4..c83dd24e98e 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -423,15 +423,13 @@ class Group < Namespace
owners.include?(user)
end
- def add_members(users, access_level, current_user: nil, expires_at: nil, tasks_to_be_done: [], tasks_project_id: nil)
+ def add_members(users, access_level, current_user: nil, expires_at: nil)
Members::Groups::CreatorService.add_members( # rubocop:disable CodeReuse/ServiceClass
self,
users,
access_level,
current_user: current_user,
- expires_at: expires_at,
- tasks_to_be_done: tasks_to_be_done,
- tasks_project_id: tasks_project_id
+ expires_at: expires_at
)
end
diff --git a/app/models/member.rb b/app/models/member.rb
index 248cad00c26..80a875fc04d 100644
--- a/app/models/member.rb
+++ b/app/models/member.rb
@@ -29,10 +29,8 @@ class Member < ApplicationRecord
belongs_to :source, polymorphic: true # rubocop:disable Cop/PolymorphicAssociations
belongs_to :member_namespace, inverse_of: :namespace_members, foreign_key: 'member_namespace_id', class_name: 'Namespace'
belongs_to :member_role
- has_one :member_task
delegate :name, :username, :email, :last_activity_on, to: :user, prefix: true
- delegate :tasks_to_be_done, to: :member_task, allow_nil: true
validates :expires_at, allow_blank: true, future_date: true
validates :user, presence: true, unless: :invite?
diff --git a/app/models/members/member_task.rb b/app/models/members/member_task.rb
deleted file mode 100644
index 6cf6b1adb45..00000000000
--- a/app/models/members/member_task.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-# frozen_string_literal: true
-
-class MemberTask < ApplicationRecord
- TASKS = {
- code: 0,
- ci: 1,
- issues: 2
- }.freeze
-
- belongs_to :member
- belongs_to :project
-
- validates :member, :project, presence: true
- validates :tasks, inclusion: { in: TASKS.values }
- validate :tasks_uniqueness
- validate :project_in_member_source
-
- scope :for_members, -> (members) { joins(:member).where(member: members) }
-
- def tasks_to_be_done
- Array(self[:tasks]).map { |task| TASKS.key(task) }
- end
-
- def tasks_to_be_done=(tasks)
- self[:tasks] = Array(tasks).map do |task|
- TASKS[task.to_sym]
- end.uniq
- end
-
- private
-
- def tasks_uniqueness
- errors.add(:tasks, 'are not unique') unless Array(tasks).length == Array(tasks).uniq.length
- end
-
- def project_in_member_source
- case member
- when GroupMember
- errors.add(:project, _('is not in the member group')) unless project.namespace == member.source
- when ProjectMember
- errors.add(:project, _('is not the member project')) unless project == member.source
- end
- end
-end
diff --git a/app/models/project.rb b/app/models/project.rb
index 22d4402d732..6c12c85d45d 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -390,6 +390,7 @@ class Project < ApplicationRecord
has_many :alert_management_alerts, class_name: 'AlertManagement::Alert', inverse_of: :project
has_many :alert_management_http_integrations, class_name: 'AlertManagement::HttpIntegration', inverse_of: :project
+ has_many :container_registry_protection_rules, class_name: 'ContainerRegistry::Protection::Rule', inverse_of: :project
# Container repositories need to remove data from the container registry,
# which is not managed by the DB. Hence we're still using dependent: :destroy
# here.
diff --git a/app/models/project_team.rb b/app/models/project_team.rb
index 38521ae6090..586294f0dd0 100644
--- a/app/models/project_team.rb
+++ b/app/models/project_team.rb
@@ -43,15 +43,13 @@ class ProjectTeam
member
end
- def add_members(users, access_level, current_user: nil, expires_at: nil, tasks_to_be_done: [], tasks_project_id: nil)
+ def add_members(users, access_level, current_user: nil, expires_at: nil)
Members::Projects::CreatorService.add_members( # rubocop:disable CodeReuse/ServiceClass
project,
users,
access_level,
current_user: current_user,
- expires_at: expires_at,
- tasks_to_be_done: tasks_to_be_done,
- tasks_project_id: tasks_project_id
+ expires_at: expires_at
)
end
diff --git a/app/services/deployments/create_for_job_service.rb b/app/services/deployments/create_for_job_service.rb
index e230515ce27..fb07efe8694 100644
--- a/app/services/deployments/create_for_job_service.rb
+++ b/app/services/deployments/create_for_job_service.rb
@@ -38,8 +38,6 @@ module Deployments
return unless deployment.valid? && deployment.environment.persisted?
if cluster = deployment.environment.deployment_platform&.cluster # rubocop: disable Lint/AssignmentInCondition
- # double write cluster_id until 12.9: https://gitlab.com/gitlab-org/gitlab/issues/202628
- deployment.cluster_id = cluster.id
deployment.deployment_cluster = ::DeploymentCluster.new(
cluster_id: cluster.id,
kubernetes_namespace: cluster.kubernetes_namespace_for(deployment.environment, deployable: job)
diff --git a/app/services/deployments/create_service.rb b/app/services/deployments/create_service.rb
index ebf2b077bca..8ef9982f41b 100644
--- a/app/services/deployments/create_service.rb
+++ b/app/services/deployments/create_service.rb
@@ -28,7 +28,6 @@ module Deployments
# We use explicit parameters here so we never by accident allow parameters
# to be set that one should not be able to set (e.g. the row ID).
{
- cluster_id: environment.deployment_platform&.cluster_id,
project_id: environment.project_id,
environment_id: environment.id,
ref: params[:ref],
diff --git a/app/services/tasks_to_be_done/base_service.rb b/app/services/tasks_to_be_done/base_service.rb
deleted file mode 100644
index 1d50e5081ff..00000000000
--- a/app/services/tasks_to_be_done/base_service.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-# frozen_string_literal: true
-
-module TasksToBeDone
- class BaseService < ::BaseContainerService
- LABEL_PREFIX = 'tasks to be done'
-
- def initialize(container:, current_user:, assignee_ids: [])
- params = {
- assignee_ids: assignee_ids,
- title: title,
- description: description,
- add_labels: label_name
- }
- super(container: container, current_user: current_user, params: params)
- end
-
- def execute
- if (issue = existing_task_issue)
- update_service = Issues::UpdateService.new(container: project, current_user: current_user, params: { add_assignee_ids: params[:assignee_ids] })
- update_service.execute(issue)
- else
- create_service = Issues::CreateService.new(container: project, current_user: current_user, params: params, perform_spam_check: false)
- create_service.execute
- end
- end
-
- private
-
- def existing_task_issue
- IssuesFinder.new(
- current_user,
- project_id: project.id,
- state: 'opened',
- non_archived: true,
- label_name: label_name
- ).execute.last
- end
-
- def title
- raise NotImplementedError
- end
-
- def description
- raise NotImplementedError
- end
-
- def label_suffix
- raise NotImplementedError
- end
-
- def label_name
- "#{LABEL_PREFIX}:#{label_suffix}"
- end
- end
-end
diff --git a/app/services/tasks_to_be_done/create_ci_task_service.rb b/app/services/tasks_to_be_done/create_ci_task_service.rb
deleted file mode 100644
index 025ca2feb8e..00000000000
--- a/app/services/tasks_to_be_done/create_ci_task_service.rb
+++ /dev/null
@@ -1,44 +0,0 @@
-# frozen_string_literal: true
-
-module TasksToBeDone
- class CreateCiTaskService < BaseService
- protected
-
- def title
- 'Set up CI/CD'
- end
-
- def description
- <<~DESCRIPTION
- GitLab CI/CD is a tool built into GitLab for software development through the [continuous methodologies](https://docs.gitlab.com/ee/ci/introduction/index.html#introduction-to-cicd-methodologies):
-
- * Continuous Integration (CI)
- * Continuous Delivery (CD)
- * Continuous Deployment (CD)
-
- Continuous Integration works by pushing small changes to your application’s codebase hosted in a Git repository, and, to every push, run a pipeline of scripts to build, test, and validate the code changes before merging them into the main branch.
-
- Continuous Delivery and Deployment consist of a step further CI, deploying your application to production at every push to the default branch of the repository.
-
- These methodologies allow you to catch bugs and errors early in the development cycle, ensuring that all the code deployed to production complies with the code standards you established for your app.
-
- * :book: [Read the documentation](https://docs.gitlab.com/ee/ci/introduction/index.html)
- * :clapper: [Watch a Demo](https://www.youtube.com/watch?v=1iXFbchozdY)
-
- ## Next steps
-
- * [ ] To start we recommend reviewing the following documentation:
- * [ ] [How GitLab CI/CD works.](https://docs.gitlab.com/ee/ci/introduction/index.html#how-gitlab-cicd-works)
- * [ ] [Fundamental pipeline architectures.](https://docs.gitlab.com/ee/ci/pipelines/pipeline_architectures.html)
- * [ ] [GitLab CI/CD basic workflow.](https://docs.gitlab.com/ee/ci/introduction/index.html#basic-cicd-workflow)
- * [ ] [Step-by-step guide for writing .gitlab-ci.yml for the first time.](https://docs.gitlab.com/ee/user/project/pages/getting_started_part_four.html)
- * [ ] When you're ready select **Projects** (in the top navigation bar) > **Your projects** > select the Project you've already created.
- * [ ] Select **CI / CD** in the left navigation to start setting up CI / CD in your project.
- DESCRIPTION
- end
-
- def label_suffix
- 'ci'
- end
- end
-end
diff --git a/app/services/tasks_to_be_done/create_code_task_service.rb b/app/services/tasks_to_be_done/create_code_task_service.rb
deleted file mode 100644
index dc3b9366a66..00000000000
--- a/app/services/tasks_to_be_done/create_code_task_service.rb
+++ /dev/null
@@ -1,52 +0,0 @@
-# frozen_string_literal: true
-
-module TasksToBeDone
- class CreateCodeTaskService < BaseService
- protected
-
- def title
- 'Create or import your code into your Project (Repository)'
- end
-
- def description
- <<~DESCRIPTION
- You've already created your Group and Project within GitLab; we'll quickly review this hierarchy below. Once you're within your project you can easily create or import repositories.
-
- **With GitLab Groups, you can:**
-
- * Create one or multiple Projects for hosting your codebase (repositories).
- * Assemble related projects together.
- * Grant members access to several projects at once.
-
- Groups can also be nested in subgroups.
-
- Read more about groups in our [documentation](https://docs.gitlab.com/ee/user/group/).
-
- **Within GitLab Projects, you can**
-
- * Use it as an issue tracker.
- * Collaborate on code.
- * Continuously build, test, and deploy your app with built-in GitLab CI/CD.
-
- You can also import an existing repository by providing the Git URL.
-
- * :book: [Read the documentation](https://docs.gitlab.com/ee/user/project/index.html).
-
- ## Next steps
-
- Create or import your first repository into the project you created:
-
- * [ ] Click **Projects** in the top navigation bar, then click **Your projects**.
- * [ ] Select the Project that you created, then select **Repository**.
- * [ ] Once on the Repository page you can select the **+** icon to add or import files.
- * [ ] You can review our full documentation on creating [repositories](https://docs.gitlab.com/ee/user/project/repository/) in GitLab.
-
- :tada: All done, you can close this issue!
- DESCRIPTION
- end
-
- def label_suffix
- 'code'
- end
- end
-end
diff --git a/app/services/tasks_to_be_done/create_issues_task_service.rb b/app/services/tasks_to_be_done/create_issues_task_service.rb
deleted file mode 100644
index a2de6852868..00000000000
--- a/app/services/tasks_to_be_done/create_issues_task_service.rb
+++ /dev/null
@@ -1,43 +0,0 @@
-# frozen_string_literal: true
-
-module TasksToBeDone
- class CreateIssuesTaskService < BaseService
- protected
-
- def title
- 'Create/import issues (tickets) to collaborate on ideas and plan work'
- end
-
- def description
- <<~DESCRIPTION
- Issues allow you and your team to discuss proposals before, and during, their implementation. They can be used for a variety of other purposes, customized to your needs and workflow.
-
- Issues are always associated with a specific project. If you have multiple projects in a group, you can view all the issues at the group level. [You can review our full Issue documentation here.](https://docs.gitlab.com/ee/user/project/issues/)
-
- If you have existing issues or equivalent tickets you can import them as long as they are formatted as a CSV file, [the import process is covered here](https://docs.gitlab.com/ee/user/project/issues/csv_import.html).
-
- **Common use cases include:**
-
- * Discussing the implementation of a new idea
- * Tracking tasks and work status
- * Accepting feature proposals, questions, support requests, or bug reports
- * Elaborating on new code implementations
-
- ## Next steps
-
- * [ ] Select **Projects** in the top navigation > **Your Projects** > select the Project you've already created.
- * [ ] Once you've selected that project, you can select **Issues** in the left navigation, then click **New issue**.
- * [ ] Fill in the title and description in the **New issue** page.
- * [ ] Click on **Create issue**.
-
- Pro tip: When you're in a group or project you can always utilize the **+** icon in the top navigation (located to the left of the search bar) to quickly create new issues.
-
- That's it! You can close this issue.
- DESCRIPTION
- end
-
- def label_suffix
- 'issues'
- end
- end
-end