Commit ce7e60f6 authored by Grzegorz Bizon's avatar Grzegorz Bizon 🔴

Merge branch '35616-move-gke-form-1st-iteration' into 'master'

First iteration of Move Kubernetes from service to Cluster page

See merge request gitlab-org/gitlab-ce!15061
parents 39afe3bc 8d51a2f4
Pipeline #13650378 failed with stages
in 73 minutes and 24 seconds
class Projects::ClustersController < Projects::ApplicationController
before_action :cluster, except: [:login, :index, :new, :create]
before_action :cluster, except: [:login, :index, :new, :new_gcp, :create]
before_action :authorize_read_cluster!
before_action :authorize_create_cluster!, only: [:new, :create]
before_action :authorize_google_api, only: [:new, :create]
before_action :authorize_create_cluster!, only: [:new, :new_gcp, :create]
before_action :authorize_google_api, only: [:new_gcp, :create]
before_action :authorize_update_cluster!, only: [:update]
before_action :authorize_admin_cluster!, only: [:destroy]
......@@ -16,7 +16,7 @@ class Projects::ClustersController < Projects::ApplicationController
def login
begin
state = generate_session_key_redirect(namespace_project_clusters_url.to_s)
state = generate_session_key_redirect(providers_gcp_new_namespace_project_clusters_url.to_s)
@authorize_url = GoogleApi::CloudPlatform::Client.new(
nil, callback_google_api_auth_url,
......@@ -27,6 +27,9 @@ class Projects::ClustersController < Projects::ApplicationController
end
def new
end
def new_gcp
@cluster = Clusters::Cluster.new.tap do |cluster|
cluster.build_provider_gcp
end
......@@ -40,7 +43,7 @@ class Projects::ClustersController < Projects::ApplicationController
if @cluster.persisted?
redirect_to project_cluster_path(project, @cluster)
else
render :new
render :new_gcp
end
end
......
- breadcrumb_title "Cluster"
- page_title _("New Cluster")
- page_title _("Cluster")
.row.prepend-top-default
.col-sm-4
= render 'sidebar'
.col-sm-8
= render 'header'
= render 'form'
- if @project.kubernetes_service&.active?
%h4.prepend-top-0= s_('ClusterIntegration|Cluster management')
%p= s_('ClusterIntegration|A cluster has been set up on this project through the Kubernetes integration page')
= link_to s_('ClusterIntegration|Manage Kubernetes integration'), edit_project_service_path(@project, :kubernetes), class: 'btn append-bottom-20'
- else
%h4.prepend-top-0= s_('ClusterIntegration|Choose how to set up cluster integration')
%p= s_('ClusterIntegration|Create a new cluster on Google Container Engine right from GitLab')
= link_to s_('ClusterIntegration|Create on GKE'), providers_gcp_new_namespace_project_clusters_path(@project.namespace, @project), class: 'btn append-bottom-20'
%p= s_('ClusterIntegration|Enter the details for an existing Kubernetes cluster')
= link_to s_('ClusterIntegration|Add an existing cluster'), edit_project_service_path(@project, :kubernetes), class: 'btn append-bottom-20'
- breadcrumb_title "Cluster"
- page_title _("New Cluster")
.row.prepend-top-default
.col-sm-4
= render 'sidebar'
.col-sm-8
= render 'header'
= render 'form'
......@@ -186,6 +186,7 @@ constraints(ProjectUrlConstrainer.new) do
resources :clusters, except: [:edit] do
collection do
get :login
get '/providers/gcp/new', action: :new_gcp
end
member do
......
......@@ -72,7 +72,7 @@ describe Projects::ClustersController do
go
expect(assigns(:authorize_url)).to include(key)
expect(session[session_key_for_redirect_uri]).to eq(project_clusters_url(project))
expect(session[session_key_for_redirect_uri]).to eq(providers_gcp_new_project_clusters_url(project))
end
end
......@@ -113,7 +113,7 @@ describe Projects::ClustersController do
end
end
describe 'GET new' do
describe 'GET new_gcp' do
let(:project) { create(:project) }
describe 'functionality' do
......@@ -161,7 +161,7 @@ describe Projects::ClustersController do
end
def go
get :new, namespace_id: project.namespace, project_id: project
get :new_gcp, namespace_id: project.namespace, project_id: project
end
end
......
......@@ -22,6 +22,8 @@ feature 'Clusters', :js do
context 'when user does not have a cluster and visits cluster index page' do
before do
visit project_clusters_path(project)
click_link 'Create on GKE'
end
it 'user sees a new page' do
......@@ -98,7 +100,7 @@ feature 'Clusters', :js do
it 'user sees creation form with the succeccful message' do
expect(page).to have_content('Cluster integration was successfully removed.')
expect(page).to have_button('Create cluster')
expect(page).to have_link('Create on GKE')
end
end
end
......@@ -107,6 +109,8 @@ feature 'Clusters', :js do
context 'when user has not signed in Google' do
before do
visit project_clusters_path(project)
click_link 'Create on GKE'
end
it 'user sees a login page' do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment