diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 23:50:22 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-04-20 23:50:22 +0000 |
commit | 9dc93a4519d9d5d7be48ff274127136236a3adb3 (patch) | |
tree | 70467ae3692a0e35e5ea56bcb803eb512a10bedb /app/controllers/clusters | |
parent | 4b0f34b6d759d6299322b3a54453e930c6121ff0 (diff) | |
download | gitlab-ce-9dc93a4519d9d5d7be48ff274127136236a3adb3.tar.gz |
Add latest changes from gitlab-org/gitlab@13-11-stable-eev13.11.0-rc43
Diffstat (limited to 'app/controllers/clusters')
-rw-r--r-- | app/controllers/clusters/clusters_controller.rb | 6 | ||||
-rw-r--r-- | app/controllers/clusters/integrations_controller.rb | 34 |
2 files changed, 39 insertions, 1 deletions
diff --git a/app/controllers/clusters/clusters_controller.rb b/app/controllers/clusters/clusters_controller.rb index 9800d94964d..c64301f72ba 100644 --- a/app/controllers/clusters/clusters_controller.rb +++ b/app/controllers/clusters/clusters_controller.rb @@ -60,6 +60,9 @@ class Clusters::ClustersController < Clusters::BaseController end def show + if params[:tab] == 'integrations' + @prometheus_integration = Clusters::IntegrationPresenter.new(@cluster.find_or_build_integration_prometheus) + end end def update @@ -305,7 +308,8 @@ class Clusters::ClustersController < Clusters::BaseController def proxy_variable_substitution_service @empty_service ||= Class.new(BaseService) do def initialize(proxyable, params) - @proxyable, @params = proxyable, params + @proxyable = proxyable + @params = params end def execute diff --git a/app/controllers/clusters/integrations_controller.rb b/app/controllers/clusters/integrations_controller.rb new file mode 100644 index 00000000000..a8c7eb10136 --- /dev/null +++ b/app/controllers/clusters/integrations_controller.rb @@ -0,0 +1,34 @@ +# frozen_string_literal: true + +module Clusters + class IntegrationsController < ::Clusters::BaseController + before_action :cluster + before_action :authorize_admin_cluster!, only: [:create_or_update] + + def create_or_update + service_response = Clusters::Integrations::CreateService + .new(container: clusterable, cluster: cluster, current_user: current_user, params: cluster_integration_params) + .execute + + if service_response.success? + redirect_to cluster.show_path(params: { tab: 'integrations' }), notice: service_response.message + else + redirect_to cluster.show_path(params: { tab: 'integrations' }), alert: service_response.message + end + end + + private + + def clusterable + raise NotImplementedError + end + + def cluster_integration_params + params.require(:integration).permit(:application_type, :enabled) + end + + def cluster + @cluster ||= clusterable.clusters.find(params[:cluster_id]).present(current_user: current_user) + end + end +end |