summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-04-13 15:08:16 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-04-13 15:08:16 +0000
commit907fd5d94ecec19ff7de4986e83e75e6fa082558 (patch)
tree5729bfd4ce7d552a0cb5e1a8f4b2437c68faf4b5 /lib
parent0cb47d7129c3d5d7bc91d32222ca70d46cb976ca (diff)
downloadgitlab-ce-907fd5d94ecec19ff7de4986e83e75e6fa082558.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r--lib/api/admin/instance_clusters.rb2
-rw-r--r--lib/api/api.rb1
-rw-r--r--lib/api/ci/jobs.rb2
-rw-r--r--lib/api/clusters/agents.rb81
-rw-r--r--lib/api/entities/clusters/agent.rb3
-rw-r--r--lib/api/internal/kubernetes.rb6
-rw-r--r--lib/api/metrics/dashboard/annotations.rb2
-rw-r--r--lib/backup/manager.rb2
-rw-r--r--lib/gitlab/ci/templates/Python.gitlab-ci.yml2
-rw-r--r--lib/gitlab/integrations/sti_type.rb4
-rw-r--r--lib/gitlab/usage_data_counters/known_events/epic_events.yml6
11 files changed, 101 insertions, 10 deletions
diff --git a/lib/api/admin/instance_clusters.rb b/lib/api/admin/instance_clusters.rb
index 4aebd9c0d40..d6c212a9886 100644
--- a/lib/api/admin/instance_clusters.rb
+++ b/lib/api/admin/instance_clusters.rb
@@ -112,7 +112,7 @@ module API
helpers do
def clusterable_instance
- Clusters::Instance.new
+ ::Clusters::Instance.new
end
def clusters_for_current_user
diff --git a/lib/api/api.rb b/lib/api/api.rb
index 724d21d824d..afc7a66b4ff 100644
--- a/lib/api/api.rb
+++ b/lib/api/api.rb
@@ -182,6 +182,7 @@ module API
mount ::API::Ci::SecureFiles
mount ::API::Ci::Triggers
mount ::API::Ci::Variables
+ mount ::API::Clusters::Agents
mount ::API::Commits
mount ::API::CommitStatuses
mount ::API::ContainerRegistryEvent
diff --git a/lib/api/ci/jobs.rb b/lib/api/ci/jobs.rb
index 794d2bbe3b2..86897eb61ae 100644
--- a/lib/api/ci/jobs.rb
+++ b/lib/api/ci/jobs.rb
@@ -197,7 +197,7 @@ module API
pipeline = current_authenticated_job.pipeline
project = current_authenticated_job.project
- agent_authorizations = Clusters::AgentAuthorizationsFinder.new(project).execute
+ agent_authorizations = ::Clusters::AgentAuthorizationsFinder.new(project).execute
project_groups = project.group&.self_and_ancestor_ids&.map { |id| { id: id } } || []
user_access_level = project.team.max_member_access(current_user.id)
roles_in_project = Gitlab::Access.sym_options_with_owner
diff --git a/lib/api/clusters/agents.rb b/lib/api/clusters/agents.rb
new file mode 100644
index 00000000000..6c1bf21b952
--- /dev/null
+++ b/lib/api/clusters/agents.rb
@@ -0,0 +1,81 @@
+# frozen_string_literal: true
+
+module API
+ module Clusters
+ class Agents < ::API::Base
+ include PaginationParams
+
+ before { authenticate! }
+
+ feature_category :kubernetes_management
+
+ params do
+ requires :id, type: String, desc: 'The ID of a project'
+ end
+ resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
+ desc 'List agents' do
+ detail 'This feature was introduced in GitLab 14.10.'
+ success Entities::Clusters::Agent
+ end
+ params do
+ use :pagination
+ end
+ get ':id/cluster_agents' do
+ authorize! :read_cluster, user_project
+
+ agents = ::Clusters::AgentsFinder.new(user_project, current_user).execute
+
+ present paginate(agents), with: Entities::Clusters::Agent
+ end
+
+ desc 'Get single agent' do
+ detail 'This feature was introduced in GitLab 14.10.'
+ success Entities::Clusters::Agent
+ end
+ params do
+ requires :agent_id, type: Integer, desc: 'The ID of an agent'
+ end
+ get ':id/cluster_agents/:agent_id' do
+ authorize! :read_cluster, user_project
+
+ agent = user_project.cluster_agents.find(params[:agent_id])
+
+ present agent, with: Entities::Clusters::Agent
+ end
+
+ desc 'Add an agent to a project' do
+ detail 'This feature was introduced in GitLab 14.10.'
+ success Entities::Clusters::Agent
+ end
+ params do
+ requires :name, type: String, desc: 'The name of the agent'
+ end
+ post ':id/cluster_agents' do
+ authorize! :create_cluster, user_project
+
+ params = declared_params(include_missing: false)
+
+ result = ::Clusters::Agents::CreateService.new(user_project, current_user).execute(name: params[:name])
+
+ bad_request!(result[:message]) if result[:status] == :error
+
+ present result[:cluster_agent], with: Entities::Clusters::Agent
+ end
+
+ desc 'Delete an agent' do
+ detail 'This feature was introduced in GitLab 14.10.'
+ end
+ params do
+ requires :agent_id, type: Integer, desc: 'The ID of an agent'
+ end
+ delete ':id/cluster_agents/:agent_id' do
+ authorize! :admin_cluster, user_project
+
+ agent = user_project.cluster_agents.find(params.delete(:agent_id))
+
+ destroy_conditionally!(agent)
+ end
+ end
+ end
+ end
+end
diff --git a/lib/api/entities/clusters/agent.rb b/lib/api/entities/clusters/agent.rb
index 3b4538b81c2..140b680f5e8 100644
--- a/lib/api/entities/clusters/agent.rb
+++ b/lib/api/entities/clusters/agent.rb
@@ -5,7 +5,10 @@ module API
module Clusters
class Agent < Grape::Entity
expose :id
+ expose :name
expose :project, with: Entities::ProjectIdentity, as: :config_project
+ expose :created_at
+ expose :created_by_user_id
end
end
end
diff --git a/lib/api/internal/kubernetes.rb b/lib/api/internal/kubernetes.rb
index df887a83c4f..59bc917a602 100644
--- a/lib/api/internal/kubernetes.rb
+++ b/lib/api/internal/kubernetes.rb
@@ -54,7 +54,7 @@ module API
def check_agent_token
unauthorized! unless agent_token
- Clusters::AgentTokens::TrackUsageService.new(agent_token).execute
+ ::Clusters::AgentTokens::TrackUsageService.new(agent_token).execute
end
end
@@ -91,9 +91,9 @@ module API
requires :agent_config, type: JSON, desc: 'Configuration for the Agent'
end
post '/' do
- agent = Clusters::Agent.find(params[:agent_id])
+ agent = ::Clusters::Agent.find(params[:agent_id])
- Clusters::Agents::RefreshAuthorizationService.new(agent, config: params[:agent_config]).execute
+ ::Clusters::Agents::RefreshAuthorizationService.new(agent, config: params[:agent_config]).execute
no_content!
end
diff --git a/lib/api/metrics/dashboard/annotations.rb b/lib/api/metrics/dashboard/annotations.rb
index 0989340b3ea..c6406bf61df 100644
--- a/lib/api/metrics/dashboard/annotations.rb
+++ b/lib/api/metrics/dashboard/annotations.rb
@@ -12,7 +12,7 @@ module API
ANNOTATIONS_SOURCES = [
{ class: ::Environment, resource: :environments, create_service_param_key: :environment },
- { class: Clusters::Cluster, resource: :clusters, create_service_param_key: :cluster }
+ { class: ::Clusters::Cluster, resource: :clusters, create_service_param_key: :cluster }
].freeze
ANNOTATIONS_SOURCES.each do |annotations_source|
diff --git a/lib/backup/manager.rb b/lib/backup/manager.rb
index fffaffda71c..403b2d9f16c 100644
--- a/lib/backup/manager.rb
+++ b/lib/backup/manager.rb
@@ -201,7 +201,7 @@ module Backup
end
def build_db_task
- force = ENV['force'] == 'yes'
+ force = Gitlab::Utils.to_boolean(ENV['force'], default: false)
Database.new(progress, force: force)
end
diff --git a/lib/gitlab/ci/templates/Python.gitlab-ci.yml b/lib/gitlab/ci/templates/Python.gitlab-ci.yml
index 6ed5e05ed4c..191d5b6b11c 100644
--- a/lib/gitlab/ci/templates/Python.gitlab-ci.yml
+++ b/lib/gitlab/ci/templates/Python.gitlab-ci.yml
@@ -13,7 +13,7 @@ variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
# Pip's cache doesn't store the python packages
-# https://pip.pypa.io/en/stable/reference/pip_install/#caching
+# https://pip.pypa.io/en/stable/topics/caching/
#
# If you want to also cache the installed packages, you have to install
# them in a virtualenv and cache it as well.
diff --git a/lib/gitlab/integrations/sti_type.rb b/lib/gitlab/integrations/sti_type.rb
index 82c2b3297c1..f347db7bc8c 100644
--- a/lib/gitlab/integrations/sti_type.rb
+++ b/lib/gitlab/integrations/sti_type.rb
@@ -3,12 +3,12 @@
module Gitlab
module Integrations
class StiType < ActiveRecord::Type::String
- NAMESPACED_INTEGRATIONS = Set.new(%w(
+ NAMESPACED_INTEGRATIONS = %w[
Asana Assembla Bamboo Bugzilla Buildkite Campfire Confluence CustomIssueTracker Datadog
Discord DroneCi EmailsOnPush Ewm ExternalWiki Flowdock HangoutsChat Harbor Irker Jenkins Jira Mattermost
MattermostSlashCommands MicrosoftTeams MockCi MockMonitoring Packagist PipelinesEmail Pivotaltracker
Prometheus Pushover Redmine Shimo Slack SlackSlashCommands Teamcity UnifyCircuit WebexTeams Youtrack Zentao
- )).freeze
+ ].to_set.freeze
def self.namespaced_integrations
NAMESPACED_INTEGRATIONS
diff --git a/lib/gitlab/usage_data_counters/known_events/epic_events.yml b/lib/gitlab/usage_data_counters/known_events/epic_events.yml
index 93158b72461..b2096cbfc70 100644
--- a/lib/gitlab/usage_data_counters/known_events/epic_events.yml
+++ b/lib/gitlab/usage_data_counters/known_events/epic_events.yml
@@ -206,3 +206,9 @@
redis_slot: project_management
aggregation: daily
feature_flag: track_epics_activity
+
+- name: g_project_management_epic_blocking_removed
+ category: epics_usage
+ redis_slot: project_management
+ aggregation: daily
+ feature_flag: track_epics_activity