Commit 3278b0a5 authored by Shinya Maeda's avatar Shinya Maeda

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

Merge branch '35616-move-gke-form-1st-iteration' into move-kubernetes-from-service-to-clusters-page-10-2-ver
parents 8fb7e878 db98ce38
class Projects::ClustersController < Projects::ApplicationController 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_read_cluster!
before_action :authorize_create_cluster!, only: [:new, :create] before_action :authorize_create_cluster!, only: [:new, :new_gcp, :create]
before_action :authorize_google_api, only: [:new, :create] before_action :authorize_google_api, only: [:new_gcp, :create]
before_action :authorize_update_cluster!, only: [:update] before_action :authorize_update_cluster!, only: [:update]
before_action :authorize_admin_cluster!, only: [:destroy] before_action :authorize_admin_cluster!, only: [:destroy]
...@@ -16,7 +16,7 @@ class Projects::ClustersController < Projects::ApplicationController ...@@ -16,7 +16,7 @@ class Projects::ClustersController < Projects::ApplicationController
def login def login
begin 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( @authorize_url = GoogleApi::CloudPlatform::Client.new(
nil, callback_google_api_auth_url, nil, callback_google_api_auth_url,
...@@ -27,6 +27,9 @@ class Projects::ClustersController < Projects::ApplicationController ...@@ -27,6 +27,9 @@ class Projects::ClustersController < Projects::ApplicationController
end end
def new def new
end
def new_gcp
@cluster = Clusters::Cluster.new.tap do |cluster| @cluster = Clusters::Cluster.new.tap do |cluster|
cluster.build_provider_gcp cluster.build_provider_gcp
end end
...@@ -40,7 +43,7 @@ class Projects::ClustersController < Projects::ApplicationController ...@@ -40,7 +43,7 @@ class Projects::ClustersController < Projects::ApplicationController
if @cluster.persisted? if @cluster.persisted?
redirect_to project_cluster_path(project, @cluster) redirect_to project_cluster_path(project, @cluster)
else else
render :new render :new_gcp
end end
end end
......
- breadcrumb_title "Cluster" - breadcrumb_title "Cluster"
- page_title _("New Cluster") - page_title _("Cluster")
.row.prepend-top-default .row.prepend-top-default
.col-sm-4 .col-sm-4
= render 'sidebar' = render 'sidebar'
.col-sm-8 .col-sm-8
= render 'header' - if @project.kubernetes_service&.active?
= render 'form' %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 ...@@ -186,6 +186,7 @@ constraints(ProjectUrlConstrainer.new) do
resources :clusters, except: [:edit] do resources :clusters, except: [:edit] do
collection do collection do
get :login get :login
get '/providers/gcp/new', action: :new_gcp
end end
member do member do
......
...@@ -113,7 +113,7 @@ describe Projects::ClustersController do ...@@ -113,7 +113,7 @@ describe Projects::ClustersController do
end end
end end
describe 'GET new' do describe 'GET new_gcp' do
let(:project) { create(:project) } let(:project) { create(:project) }
describe 'functionality' do describe 'functionality' do
...@@ -161,7 +161,7 @@ describe Projects::ClustersController do ...@@ -161,7 +161,7 @@ describe Projects::ClustersController do
end end
def go def go
get :new, namespace_id: project.namespace, project_id: project get :new_gcp, namespace_id: project.namespace, project_id: project
end end
end end
......
...@@ -22,6 +22,8 @@ feature 'Clusters', :js do ...@@ -22,6 +22,8 @@ feature 'Clusters', :js do
context 'when user does not have a cluster and visits cluster index page' do context 'when user does not have a cluster and visits cluster index page' do
before do before do
visit project_clusters_path(project) visit project_clusters_path(project)
click_link 'Create on GKE'
end end
it 'user sees a new page' do it 'user sees a new page' do
...@@ -98,7 +100,7 @@ feature 'Clusters', :js do ...@@ -98,7 +100,7 @@ feature 'Clusters', :js do
it 'user sees creation form with the succeccful message' 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_content('Cluster integration was successfully removed.')
expect(page).to have_button('Create cluster') expect(page).to have_content('Choose how to set up cluster integration')
end end
end end
end end
...@@ -107,6 +109,8 @@ feature 'Clusters', :js do ...@@ -107,6 +109,8 @@ feature 'Clusters', :js do
context 'when user has not signed in Google' do context 'when user has not signed in Google' do
before do before do
visit project_clusters_path(project) visit project_clusters_path(project)
click_link 'Create on GKE'
end end
it 'user sees a login page' do 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