diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-08 06:08:13 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-01-08 06:08:13 +0000 |
commit | f6e985dba4d0f5b1ede95e9174d30dd6a8bedf0d (patch) | |
tree | c1fed91ae38ad6150ba323a2fc9a68f50f648bb4 /lib | |
parent | 30010b161d42bdac3ab5cd16e63cc61c2f4939f3 (diff) | |
download | gitlab-ce-f6e985dba4d0f5b1ede95e9174d30dd6a8bedf0d.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/remote_mirrors.rb | 30 | ||||
-rw-r--r-- | lib/gitlab/auth.rb | 6 | ||||
-rw-r--r-- | lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb | 22 | ||||
-rw-r--r-- | lib/gitlab/kubernetes/cluster_role.rb | 29 | ||||
-rw-r--r-- | lib/gitlab/kubernetes/kube_client.rb | 8 |
5 files changed, 34 insertions, 61 deletions
diff --git a/lib/api/remote_mirrors.rb b/lib/api/remote_mirrors.rb index 8a085517ce9..95313966133 100644 --- a/lib/api/remote_mirrors.rb +++ b/lib/api/remote_mirrors.rb @@ -7,6 +7,8 @@ module API before do # TODO: Remove flag: https://gitlab.com/gitlab-org/gitlab/issues/38121 not_found! unless Feature.enabled?(:remote_mirrors_api, user_project) + + unauthorized! unless can?(current_user, :admin_remote_mirror, user_project) end params do @@ -20,11 +22,35 @@ module API use :pagination end get ':id/remote_mirrors' do - unauthorized! unless can?(current_user, :admin_remote_mirror, user_project) - present paginate(user_project.remote_mirrors), with: Entities::RemoteMirror end + + desc 'Update the attributes of a single remote mirror' do + success Entities::RemoteMirror + end + params do + requires :mirror_id, type: String, desc: 'The ID of a remote mirror' + optional :enabled, type: Boolean, desc: 'Determines if the mirror is enabled' + optional :only_protected_branches, type: Boolean, desc: 'Determines if only protected branches are mirrored' + end + put ':id/remote_mirrors/:mirror_id' do + mirror = user_project.remote_mirrors.find(params[:mirror_id]) + + mirror_params = declared_params(include_missing: false) + mirror_params[:id] = mirror_params.delete(:mirror_id) + update_params = { remote_mirrors_attributes: mirror_params } + + result = ::Projects::UpdateService + .new(user_project, current_user, update_params) + .execute + + if result[:status] == :success + present mirror.reset, with: Entities::RemoteMirror + else + render_api_error!(result[:message], result[:http_status]) + end + end end end end diff --git a/lib/gitlab/auth.rb b/lib/gitlab/auth.rb index dfdba617cb6..821c68dbedc 100644 --- a/lib/gitlab/auth.rb +++ b/lib/gitlab/auth.rb @@ -54,7 +54,7 @@ module Gitlab Gitlab::Auth::Result.new rate_limit!(rate_limiter, success: result.success?, login: login) - Gitlab::Auth::UniqueIpsLimiter.limit_user!(result.actor) + look_to_limit_user(result.actor) return result if result.success? || authenticate_using_internal_or_ldap_password? @@ -129,6 +129,10 @@ module Gitlab ::Ci::Build::CI_REGISTRY_USER == login end + def look_to_limit_user(actor) + Gitlab::Auth::UniqueIpsLimiter.limit_user!(actor) if actor.is_a?(User) + end + def authenticate_using_internal_or_ldap_password? Gitlab::CurrentSettings.password_authentication_enabled_for_git? || Gitlab::Auth::LDAP::Config.enabled? end diff --git a/lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb b/lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb index 465877871ea..b64990d6a7a 100644 --- a/lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb +++ b/lib/gitlab/ci/build/prerequisite/kubernetes_namespace.rb @@ -8,7 +8,7 @@ module Gitlab def unmet? deployment_cluster.present? && deployment_cluster.managed? && - (missing_namespace? || need_knative_version_role_binding?) + missing_namespace? end def complete! @@ -23,10 +23,6 @@ module Gitlab kubernetes_namespace.nil? || kubernetes_namespace.service_account_token.blank? end - def need_knative_version_role_binding? - !knative_serving_namespace.nil? && knative_version_role_binding.nil? - end - def deployment_cluster build.deployment&.cluster end @@ -35,22 +31,6 @@ module Gitlab build.deployment.environment end - def knative_serving_namespace - strong_memoize(:knative_serving_namespace) do - Clusters::KnativeServingNamespaceFinder.new( - deployment_cluster - ).execute - end - end - - def knative_version_role_binding - strong_memoize(:knative_version_role_binding) do - Clusters::KnativeVersionRoleBindingFinder.new( - deployment_cluster - ).execute - end - end - def kubernetes_namespace strong_memoize(:kubernetes_namespace) do Clusters::KubernetesNamespaceFinder.new( diff --git a/lib/gitlab/kubernetes/cluster_role.rb b/lib/gitlab/kubernetes/cluster_role.rb deleted file mode 100644 index 4d40736a0b5..00000000000 --- a/lib/gitlab/kubernetes/cluster_role.rb +++ /dev/null @@ -1,29 +0,0 @@ -# frozen_string_literal: true - -module Gitlab - module Kubernetes - class ClusterRole - attr_reader :name, :rules - - def initialize(name:, rules:) - @name = name - @rules = rules - end - - def generate - ::Kubeclient::Resource.new( - metadata: metadata, - rules: rules - ) - end - - private - - def metadata - { - name: name - } - end - end - end -end diff --git a/lib/gitlab/kubernetes/kube_client.rb b/lib/gitlab/kubernetes/kube_client.rb index 21d5c9b0eee..7cb7f46a623 100644 --- a/lib/gitlab/kubernetes/kube_client.rb +++ b/lib/gitlab/kubernetes/kube_client.rb @@ -57,7 +57,6 @@ module Gitlab # group client delegate :create_cluster_role_binding, :get_cluster_role_binding, - :get_cluster_role_bindings, :update_cluster_role_binding, to: :rbac_client @@ -70,13 +69,6 @@ module Gitlab # RBAC methods delegates to the apis/rbac.authorization.k8s.io api # group client - delegate :create_cluster_role, - :get_cluster_role, - :update_cluster_role, - to: :rbac_client - - # RBAC methods delegates to the apis/rbac.authorization.k8s.io api - # group client delegate :create_role_binding, :get_role_binding, :update_role_binding, |