Merge branch '35616-move-gke-form-1st-iteration' into move-kubernetes-from-service-to-clusters-page-10-2-ver

This commit is contained in:
Shinya Maeda 2017-11-04 03:34:13 +09:00
commit 3278b0a5ff
6 changed files with 40 additions and 11 deletions

View file

@ -1,8 +1,8 @@
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

View file

@ -1,9 +1,20 @@
- 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'

View file

@ -0,0 +1,10 @@
- breadcrumb_title "Cluster"
- page_title _("New Cluster")
.row.prepend-top-default
.col-sm-4
= render 'sidebar'
.col-sm-8
= render 'header'
= render 'form'

View file

@ -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

View file

@ -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

View file

@ -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_content('Choose how to set up cluster integration')
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