Skip to content
Snippets Groups Projects
Commit ab7cf450 authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 4204cf30
No related branches found
No related tags found
No related merge requests found
Showing
with 144 additions and 25 deletions
Loading
Loading
@@ -31,7 +31,6 @@ rules:
- error
- allowElseIf: true
import/no-cycle: warn
import/no-unresolved: warn
import/no-useless-path-segments: off
import/order: warn
lines-between-class-members: off
Loading
Loading
Loading
Loading
@@ -20,11 +20,11 @@ class ApplicationController < ActionController::Base
before_action :authenticate_user!, except: [:route_not_found]
before_action :enforce_terms!, if: :should_enforce_terms?
before_action :validate_user_service_ticket!
before_action :check_password_expiration
before_action :check_password_expiration, if: :html_request?
before_action :ldap_security_check
before_action :sentry_context
before_action :default_headers
before_action :add_gon_variables, unless: [:peek_request?, :json_request?]
before_action :add_gon_variables, if: :html_request?
before_action :configure_permitted_parameters, if: :devise_controller?
before_action :require_email, unless: :devise_controller?
before_action :active_user_check, unless: :devise_controller?
Loading
Loading
@@ -455,8 +455,8 @@ class ApplicationController < ActionController::Base
response.headers['Page-Title'] = URI.escape(page_title('GitLab'))
end
 
def peek_request?
request.path.start_with?('/-/peek')
def html_request?
request.format.html?
end
 
def json_request?
Loading
Loading
@@ -466,7 +466,7 @@ class ApplicationController < ActionController::Base
def should_enforce_terms?
return false unless Gitlab::CurrentSettings.current_application_settings.enforce_terms
 
!(peek_request? || devise_controller?)
html_request? && !devise_controller?
end
 
def set_usage_stats_consent_flag
Loading
Loading
Loading
Loading
@@ -4,15 +4,18 @@ module ConfirmEmailWarning
extend ActiveSupport::Concern
 
included do
before_action :set_confirm_warning, if: -> { Feature.enabled?(:soft_email_confirmation) }
before_action :set_confirm_warning, if: :show_confirm_warning?
end
 
protected
 
def show_confirm_warning?
html_request? && request.get? && Feature.enabled?(:soft_email_confirmation)
end
def set_confirm_warning
return unless current_user
return if current_user.confirmed?
return if peek_request? || json_request? || !request.get?
 
email = current_user.unconfirmed_email || current_user.email
 
Loading
Loading
Loading
Loading
@@ -4,7 +4,7 @@ module SourcegraphGon
extend ActiveSupport::Concern
 
included do
before_action :push_sourcegraph_gon, unless: :json_request?
before_action :push_sourcegraph_gon, if: :html_request?
end
 
private
Loading
Loading
# frozen_string_literal: true
 
module UploadsActions
extend ActiveSupport::Concern
include Gitlab::Utils::StrongMemoize
include SendFileUpload
 
UPLOAD_MOUNTS = %w(avatar attachment file logo header_logo favicon).freeze
 
included do
prepend_before_action :set_request_format_from_path_extension
end
def create
uploader = UploadService.new(model, params[:file], uploader_class).execute
 
Loading
Loading
@@ -64,6 +69,20 @@ module UploadsActions
 
private
 
# Based on ActionDispatch::Http::MimeNegotiation. We have an
# initializer that monkey-patches this method out (so that repository
# paths don't guess a format based on extension), but we do want this
# behavior when serving uploads.
def set_request_format_from_path_extension
path = request.headers['action_dispatch.original_path'] || request.headers['PATH_INFO']
if match = path&.match(/\.(\w+)\z/)
format = Mime[match.captures.first]
request.format = format.symbol if format
end
end
def uploader_class
raise NotImplementedError
end
Loading
Loading
# frozen_string_literal: true
 
class InstanceStatistics::ConversationalDevelopmentIndexController < InstanceStatistics::ApplicationController
class InstanceStatistics::DevOpsScoreController < InstanceStatistics::ApplicationController
# rubocop: disable CodeReuse/ActiveRecord
def index
@metric = DevOpsScore::Metric.order(:created_at).last&.present
Loading
Loading
Loading
Loading
@@ -46,7 +46,7 @@ class Projects::BranchesController < Projects::ApplicationController
def diverging_commit_counts
respond_to do |format|
format.json do
service = Branches::DivergingCommitCountsService.new(repository)
service = ::Branches::DivergingCommitCountsService.new(repository)
branches = BranchesFinder.new(repository, params.permit(names: [])).execute
 
Gitlab::GitalyClient.allow_n_plus_1_calls do
Loading
Loading
@@ -63,7 +63,7 @@ class Projects::BranchesController < Projects::ApplicationController
 
redirect_to_autodeploy = project.empty_repo? && project.deployment_platform.present?
 
result = CreateBranchService.new(project, current_user)
result = ::Branches::CreateService.new(project, current_user)
.execute(branch_name, ref)
 
success = (result[:status] == :success)
Loading
Loading
@@ -102,7 +102,7 @@ class Projects::BranchesController < Projects::ApplicationController
 
def destroy
@branch_name = Addressable::URI.unescape(params[:id])
result = DeleteBranchService.new(project, current_user).execute(@branch_name)
result = ::Branches::DeleteService.new(project, current_user).execute(@branch_name)
 
respond_to do |format|
format.html do
Loading
Loading
@@ -118,7 +118,7 @@ class Projects::BranchesController < Projects::ApplicationController
end
 
def destroy_all_merged
DeleteMergedBranchesService.new(@project, current_user).async_execute
::Branches::DeleteMergedService.new(@project, current_user).async_execute
 
redirect_to project_branches_path(@project),
notice: _('Merged branches are being deleted. This can take some time depending on the number of branches. Please refresh the page to see changes.')
Loading
Loading
# frozen_string_literal: true
module Clusters
class KnativeVersionRoleBindingFinder
attr_reader :cluster
def initialize(cluster)
@cluster = cluster
end
def execute
cluster&.kubeclient&.get_cluster_role_bindings&.find do |resource|
resource.metadata.name == Clusters::Kubernetes::GITLAB_KNATIVE_VERSION_ROLE_BINDING_NAME
end
end
end
end
# frozen_string_literal: true
module Mutations
module Issues
class SetConfidential < Base
graphql_name 'IssueSetConfidential'
argument :confidential,
GraphQL::BOOLEAN_TYPE,
required: true,
description: 'Whether or not to set the issue as a confidential.'
def resolve(project_path:, iid:, confidential:)
issue = authorized_find!(project_path: project_path, iid: iid)
project = issue.project
::Issues::UpdateService.new(project, current_user, confidential: confidential)
.execute(issue)
{
issue: issue,
errors: issue.errors.full_messages
}
end
end
end
end
Loading
Loading
@@ -16,22 +16,21 @@ module Mutations
null: false,
description: 'The requested todo'
 
# rubocop: disable CodeReuse/ActiveRecord
def resolve(id:)
todo = authorized_find!(id: id)
mark_done(Todo.where(id: todo.id)) unless todo.done?
mark_done(todo)
 
{
todo: todo.reset,
errors: errors_on_object(todo)
}
end
# rubocop: enable CodeReuse/ActiveRecord
 
private
 
def mark_done(todo)
TodoService.new.mark_todos_as_done(todo, current_user)
TodoService.new.mark_todo_as_done(todo, current_user)
end
end
end
Loading
Loading
Loading
Loading
@@ -9,6 +9,7 @@ module Types
mount_mutation Mutations::AwardEmojis::Add
mount_mutation Mutations::AwardEmojis::Remove
mount_mutation Mutations::AwardEmojis::Toggle
mount_mutation Mutations::Issues::SetConfidential
mount_mutation Mutations::Issues::SetDueDate
mount_mutation Mutations::MergeRequests::SetLabels
mount_mutation Mutations::MergeRequests::SetLocked
Loading
Loading
Loading
Loading
@@ -425,6 +425,18 @@ module Ci
end
end
 
def expanded_kubernetes_namespace
return unless has_environment?
namespace = options.dig(:environment, :kubernetes, :namespace)
if namespace.present?
strong_memoize(:expanded_kubernetes_namespace) do
ExpandVariables.expand(namespace, -> { simple_variables })
end
end
end
def has_environment?
environment.present?
end
Loading
Loading
Loading
Loading
@@ -63,7 +63,7 @@ module Clusters
 
default_value_for :authorization_type, :rbac
 
def predefined_variables(project:, environment_name:)
def predefined_variables(project:, environment_name:, kubernetes_namespace: nil)
Gitlab::Ci::Variables::Collection.new.tap do |variables|
variables.append(key: 'KUBE_URL', value: api_url)
 
Loading
Loading
@@ -74,15 +74,15 @@ module Clusters
end
 
if !cluster.managed? || cluster.management_project == project
namespace = Gitlab::Kubernetes::DefaultNamespace.new(cluster, project: project).from_environment_name(environment_name)
namespace = kubernetes_namespace || default_namespace(project, environment_name: environment_name)
 
variables
.append(key: 'KUBE_TOKEN', value: token, public: false, masked: true)
.append(key: 'KUBE_NAMESPACE', value: namespace)
.append(key: 'KUBECONFIG', value: kubeconfig(namespace), public: false, file: true)
 
elsif kubernetes_namespace = find_persisted_namespace(project, environment_name: environment_name)
variables.concat(kubernetes_namespace.predefined_variables)
elsif persisted_namespace = find_persisted_namespace(project, environment_name: environment_name)
variables.concat(persisted_namespace.predefined_variables)
end
 
variables.concat(cluster.predefined_variables)
Loading
Loading
@@ -107,6 +107,13 @@ module Clusters
 
private
 
def default_namespace(project, environment_name:)
Gitlab::Kubernetes::DefaultNamespace.new(
cluster,
project: project
).from_environment_name(environment_name)
end
def find_persisted_namespace(project, environment_name:)
Clusters::KubernetesNamespaceFinder.new(
cluster,
Loading
Loading
Loading
Loading
@@ -15,7 +15,7 @@ module Ci
variables.concat(project.predefined_variables)
variables.concat(pipeline.predefined_variables)
variables.concat(runner.predefined_variables) if runnable? && runner
variables.concat(project.deployment_variables(environment: environment)) if environment
variables.concat(deployment_variables(environment: environment))
variables.concat(yaml_variables)
variables.concat(user_variables)
variables.concat(secret_group_variables)
Loading
Loading
@@ -72,6 +72,15 @@ module Ci
end
end
 
def deployment_variables(environment:)
return [] unless environment
project.deployment_variables(
environment: environment,
kubernetes_namespace: expanded_kubernetes_namespace
)
end
def secret_group_variables
return [] unless project.group
 
Loading
Loading
Loading
Loading
@@ -22,4 +22,8 @@ class DashboardGroupMilestone < GlobalMilestone
def dashboard_milestone?
true
end
def merge_requests_enabled?
true
end
end
Loading
Loading
@@ -12,4 +12,8 @@ class DashboardMilestone < GlobalMilestone
def project_milestone?
true
end
def merge_requests_enabled?
project.merge_requests_enabled?
end
end
Loading
Loading
@@ -41,4 +41,8 @@ class GroupMilestone < GlobalMilestone
def legacy_group_milestone?
true
end
def merge_requests_enabled?
true
end
end
Loading
Loading
@@ -274,6 +274,16 @@ class Milestone < ApplicationRecord
project_id.present?
end
 
def merge_requests_enabled?
if group_milestone?
# Assume that groups have at least one project with merge requests enabled.
# Otherwise, we would need to load all of the projects from the database.
true
elsif project_milestone?
project&.merge_requests_enabled?
end
end
private
 
# Milestone titles must be unique across project milestones and group milestones
Loading
Loading
Loading
Loading
@@ -1986,12 +1986,16 @@ class Project < ApplicationRecord
end
end
 
def deployment_variables(environment:)
def deployment_variables(environment:, kubernetes_namespace: nil)
platform = deployment_platform(environment: environment)
 
return [] unless platform.present?
 
platform.predefined_variables(project: self, environment_name: environment)
platform.predefined_variables(
project: self,
environment_name: environment,
kubernetes_namespace: kubernetes_namespace
)
end
 
def auto_devops_variables
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment