Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
07247601
Commit
07247601
authored
Oct 04, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove status enum from Gcp::Cluster, use state_machine#state
parent
bee5c080
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
11 deletions
+14
-11
app/models/gcp/cluster.rb
app/models/gcp/cluster.rb
+6
-8
app/serializers/cluster_entity.rb
app/serializers/cluster_entity.rb
+1
-1
app/services/ci/create_cluster_service.rb
app/services/ci/create_cluster_service.rb
+0
-1
app/views/projects/clusters/show.html.haml
app/views/projects/clusters/show.html.haml
+1
-1
spec/factories/gcp/cluster.rb
spec/factories/gcp/cluster.rb
+6
-0
No files found.
app/models/gcp/cluster.rb
View file @
07247601
...
@@ -25,13 +25,6 @@ module Gcp
...
@@ -25,13 +25,6 @@ module Gcp
key:
Gitlab
::
Application
.
secrets
.
db_key_base
,
key:
Gitlab
::
Application
.
secrets
.
db_key_base
,
algorithm:
'aes-256-cbc'
algorithm:
'aes-256-cbc'
enum
status:
{
scheduled:
1
,
creating:
2
,
created:
3
,
errored:
4
}
validates
:gcp_project_id
,
validates
:gcp_project_id
,
length:
1
..
63
,
length:
1
..
63
,
format:
{
format:
{
...
@@ -67,6 +60,11 @@ module Gcp
...
@@ -67,6 +60,11 @@ module Gcp
validate
:restrict_modification
,
on: :update
,
unless: :status_changed?
validate
:restrict_modification
,
on: :update
,
unless: :status_changed?
state_machine
:status
,
initial: :scheduled
do
state_machine
:status
,
initial: :scheduled
do
state
:scheduled
,
value:
1
state
:creating
,
value:
2
state
:created
,
value:
3
state
:errored
,
value:
4
event
:make_creating
do
event
:make_creating
do
transition
any
-
[
:creating
]
=>
:creating
transition
any
-
[
:creating
]
=>
:creating
end
end
...
@@ -86,7 +84,7 @@ module Gcp
...
@@ -86,7 +84,7 @@ module Gcp
before_transition
any
=>
[
:errored
]
do
|
cluster
,
transition
|
before_transition
any
=>
[
:errored
]
do
|
cluster
,
transition
|
status_reason
=
transition
.
args
.
first
status_reason
=
transition
.
args
.
first
cluster
.
status_reason
=
status_reason
cluster
.
status_reason
=
status_reason
if
status_reason
end
end
end
end
...
...
app/serializers/cluster_entity.rb
View file @
07247601
class
ClusterEntity
<
Grape
::
Entity
class
ClusterEntity
<
Grape
::
Entity
include
RequestAwareEntity
include
RequestAwareEntity
expose
:status
expose
:status
_name
,
as: :status
expose
:status_reason
expose
:status_reason
end
end
app/services/ci/create_cluster_service.rb
View file @
07247601
...
@@ -5,7 +5,6 @@ module Ci
...
@@ -5,7 +5,6 @@ module Ci
project
.
create_cluster
(
project
.
create_cluster
(
params
.
merge
(
user:
current_user
,
params
.
merge
(
user:
current_user
,
status:
Gcp
::
Cluster
.
statuses
[
:scheduled
],
gcp_token:
access_token
)).
tap
do
|
cluster
|
gcp_token:
access_token
)).
tap
do
|
cluster
|
ClusterProvisionWorker
.
perform_async
(
cluster
.
id
)
if
cluster
.
persisted?
ClusterProvisionWorker
.
perform_async
(
cluster
.
id
)
if
cluster
.
persisted?
end
end
...
...
app/views/projects/clusters/show.html.haml
View file @
07247601
-
status_path
=
status_namespace_project_cluster_path
(
@cluster
.
project
.
namespace
,
@cluster
.
project
,
@cluster
.
id
,
format: :json
)
if
can?
(
current_user
,
:admin_cluster
,
@cluster
)
&&
@cluster
.
on_creation?
-
status_path
=
status_namespace_project_cluster_path
(
@cluster
.
project
.
namespace
,
@cluster
.
project
,
@cluster
.
id
,
format: :json
)
if
can?
(
current_user
,
:admin_cluster
,
@cluster
)
&&
@cluster
.
on_creation?
.row.prepend-top-default.edit-cluster-form.js-edit-cluster-form
{
data:
{
status_path:
status_path
,
.row.prepend-top-default.edit-cluster-form.js-edit-cluster-form
{
data:
{
status_path:
status_path
,
toggle_status:
@cluster
.
enabled?
?
'true'
:
'false'
,
toggle_status:
@cluster
.
enabled?
?
'true'
:
'false'
,
cluster_status:
@cluster
.
status
,
cluster_status:
@cluster
.
status
_name
,
cluster_status_reason:
@cluster
.
status_reason
}}
cluster_status_reason:
@cluster
.
status_reason
}}
=
render
'sidebar'
=
render
'sidebar'
.col-lg-8
.col-lg-8
...
...
spec/factories/gcp/cluster.rb
View file @
07247601
...
@@ -13,11 +13,17 @@ FactoryGirl.define do
...
@@ -13,11 +13,17 @@ FactoryGirl.define do
end
end
trait
:created_on_gke
do
trait
:created_on_gke
do
status_event
:make_created
endpoint
'111.111.111.111'
endpoint
'111.111.111.111'
ca_cert
'xxxxxx'
ca_cert
'xxxxxx'
kubernetes_token
'xxxxxx'
kubernetes_token
'xxxxxx'
username
'xxxxxx'
username
'xxxxxx'
password
'xxxxxx'
password
'xxxxxx'
end
end
trait
:errored
do
status_event
:make_errored
status_reason
'general error'
end
end
end
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