BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
7af2161c
Commit
7af2161c
authored
Dec 03, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix controllers and links
parent
1385d700
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
35 additions
and
20 deletions
+35
-20
gcp_controller.rb
app/controllers/projects/clusters/gcp_controller.rb
+8
-2
clusters_controller.rb
app/controllers/projects/clusters_controller.rb
+5
-1
cluster.rb
app/models/clusters/cluster.rb
+6
-3
_dropdown.html.haml
app/views/projects/clusters/_dropdown.html.haml
+2
-2
_form.html.haml
app/views/projects/clusters/gcp/_form.html.haml
+1
-1
show.html.haml
app/views/projects/clusters/show.html.haml
+1
-1
_form.html.haml
app/views/projects/clusters/user/_form.html.haml
+1
-1
_show.html.haml
app/views/projects/clusters/user/_show.html.haml
+5
-5
project.rb
config/routes/project.rb
+6
-4
No files found.
app/controllers/projects/clusters/gcp_controller.rb
View file @
7af2161c
...
...
@@ -2,8 +2,6 @@ class Projects::Clusters::GcpController < Projects::ApplicationController
before_action
:authorize_read_cluster!
before_action
:authorize_google_api
,
except:
[
:login
]
before_action
:authorize_create_cluster!
,
only:
[
:new
,
:create
]
before_action
:authorize_update_cluster!
,
only:
[
:update
]
before_action
:authorize_admin_cluster!
,
only:
[
:destroy
]
def
login
begin
...
...
@@ -52,6 +50,14 @@ class Projects::Clusters::GcpController < Projects::ApplicationController
)
end
def
update_params
params
.
require
(
:cluster
).
permit
(
:enabled
,
platform_kubernetes_attributes:
[
:namespace
])
end
def
authorize_google_api
unless
GoogleApi
::
CloudPlatform
::
Client
.
new
(
token_in_session
,
nil
)
.
validate_token
(
expires_at_in_session
)
...
...
app/controllers/projects/clusters_controller.rb
View file @
7af2161c
class
Projects
::
ClustersController
<
Projects
::
ApplicationController
before_action
:cluster
,
except:
[
:
login
,
:
index
,
:new
]
before_action
:cluster
,
except:
[
:index
,
:new
]
before_action
:authorize_read_cluster!
before_action
:authorize_create_cluster!
,
only:
[
:new
]
before_action
:authorize_update_cluster!
,
only:
[
:update
]
...
...
@@ -13,6 +13,9 @@ class Projects::ClustersController < Projects::ApplicationController
end
end
def
new
end
def
status
respond_to
do
|
format
|
format
.
json
do
...
...
@@ -60,6 +63,7 @@ class Projects::ClustersController < Projects::ApplicationController
def
update_params
params
.
require
(
:cluster
).
permit
(
:enabled
,
:name
,
platform_kubernetes_attributes:
[
:namespace
,
:api_url
,
...
...
app/models/clusters/cluster.rb
View file @
7af2161c
...
...
@@ -17,7 +17,7 @@ module Clusters
# we force autosave to happen when we save `Cluster` model
has_one
:provider_gcp
,
class_name:
'Clusters::Providers::Gcp'
,
autosave:
true
has_one
:platform_kubernetes
,
class_name:
'Clusters::Platforms::Kubernetes'
has_one
:platform_kubernetes
,
class_name:
'Clusters::Platforms::Kubernetes'
,
autosave:
true
has_one
:application_helm
,
class_name:
'Clusters::Applications::Helm'
has_one
:application_ingress
,
class_name:
'Clusters::Applications::Ingress'
...
...
@@ -28,8 +28,6 @@ module Clusters
validates
:name
,
cluster_name:
true
validate
:restrict_modification
,
on: :update
validates_associated
:provider_gcp
,
:platform_kubernetes
delegate
:status
,
to: :provider
,
allow_nil:
true
delegate
:status_reason
,
to: :provider
,
allow_nil:
true
delegate
:on_creation?
,
to: :provider
,
allow_nil:
true
...
...
@@ -95,6 +93,11 @@ module Clusters
return
false
end
if
managed?
&&
name_changed?
errors
.
add
(
:base
,
"cannot modify cluster name"
)
return
false
end
true
end
end
...
...
app/views/projects/clusters/_dropdown.html.haml
View file @
7af2161c
...
...
@@ -7,6 +7,6 @@
=
icon
(
'chevron-down'
)
%ul
.dropdown-menu.clusters-dropdown-menu.dropdown-menu-full-width
%li
=
link_to
(
s_
(
'ClusterIntegration|Create cluster on Google Container Engine'
),
new_namespace_project_gcp
_path
(
@project
.
namespace
,
@project
))
=
link_to
(
s_
(
'ClusterIntegration|Create cluster on Google Container Engine'
),
gcp_new_namespace_project_clusters
_path
(
@project
.
namespace
,
@project
))
%li
=
link_to
(
s_
(
'ClusterIntegration|Add an existing cluster'
),
new_namespace_project_user
_path
(
@project
.
namespace
,
@project
))
=
link_to
(
s_
(
'ClusterIntegration|Add an existing cluster'
),
user_new_namespace_project_clusters
_path
(
@project
.
namespace
,
@project
))
app/views/projects/clusters/gcp/_form.html.haml
View file @
7af2161c
...
...
@@ -3,7 +3,7 @@
-
link_to_help_page
=
link_to
(
s_
(
'ClusterIntegration|help page'
),
help_page_path
(
'user/project/clusters/index'
),
target:
'_blank'
,
rel:
'noopener noreferrer'
)
=
s_
(
'ClusterIntegration|Read our %{link_to_help_page} on cluster integration.'
).
html_safe
%
{
link_to_help_page:
link_to_help_page
}
=
form_for
@cluster
,
html:
{
class:
'prepend-top-20'
},
url:
namespace_project_gcp
_path
(
@project
.
namespace
,
@project
),
as: :cluster
do
|
field
|
=
form_for
@cluster
,
html:
{
class:
'prepend-top-20'
},
url:
gcp_namespace_project_clusters
_path
(
@project
.
namespace
,
@project
),
as: :cluster
do
|
field
|
=
form_errors
(
@cluster
)
.form-group
=
field
.
label
:name
,
s_
(
'ClusterIntegration|Cluster name'
)
...
...
app/views/projects/clusters/show.html.haml
View file @
7af2161c
...
...
@@ -69,7 +69,7 @@
-
if
@cluster
.
managed?
=
render
'projects/clusters/gcp/show'
-
else
=
render
'projects/clusters/
kubernetes
/show'
=
render
'projects/clusters/
user
/show'
%section
.settings.no-animate
#js-cluster-advanced-settings
{
class:
(
'expanded'
if
expanded
)
}
.settings-header
...
...
app/views/projects/clusters/user/_form.html.haml
View file @
7af2161c
=
form_for
@cluster
,
url:
namespace_project_user
_path
(
@project
.
namespace
,
@project
),
as: :cluster
do
|
field
|
=
form_for
@cluster
,
url:
user_namespace_project_clusters
_path
(
@project
.
namespace
,
@project
),
as: :cluster
do
|
field
|
=
form_errors
(
@cluster
)
.form-group
=
field
.
label
:name
,
s_
(
'ClusterIntegration|Cluster name'
)
...
...
app/views/projects/clusters/user/_show.html.haml
View file @
7af2161c
.form-group
%label
.append-bottom-10
{
for:
'cluster-name'
}
=
s_
(
'ClusterIntegration|Cluster name'
)
%input
.form-control.cluster-name
{
value:
@cluster
.
name
}
=
form_for
@cluster
,
url:
namespace_project_cluster_path
(
@project
.
namespace
,
@project
,
@cluster
),
as: :cluster
do
|
field
|
=
form_errors
(
@cluster
)
.form-group
=
field
.
label
:name
,
s_
(
'ClusterIntegration|Cluster name'
)
=
field
.
text_field
:name
,
class:
'form-control'
,
placeholder:
s_
(
'ClusterIntegration|Cluster name'
)
=
field
.
fields_for
:platform_kubernetes
,
@cluster
.
platform_kubernetes
do
|
platform_kubernetes_field
|
.form-group
=
platform_kubernetes_field
.
label
:api_url
,
s_
(
'ClusterIntegration|API URL'
)
...
...
config/routes/project.rb
View file @
7af2161c
...
...
@@ -186,10 +186,12 @@ constraints(ProjectUrlConstrainer.new) do
resources
:clusters
,
except:
[
:edit
,
:create
]
do
collection
do
scope
:providers
do
resource
:user
,
only:
[
:new
,
:create
],
controller:
'clusters/user'
resource
:gcp
,
only:
[
:new
,
:create
],
controller:
'clusters/gcp'
do
get
:login
end
get
'/user/new'
,
to:
'clusters/user#new'
post
'/user'
,
to:
'clusters/user#create'
get
'/gcp/new'
,
to:
'clusters/gcp#new'
get
'/gcp/login'
,
to:
'clusters/gcp#login'
post
'/gcp'
,
to:
'clusters/gcp#create'
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment