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
Boxiang Sun
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
Hide 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
key:
Gitlab
::
Application
.
secrets
.
db_key_base
,
algorithm:
'aes-256-cbc'
enum
status:
{
scheduled:
1
,
creating:
2
,
created:
3
,
errored:
4
}
validates
:gcp_project_id
,
length:
1
..
63
,
format:
{
...
...
@@ -67,6 +60,11 @@ module Gcp
validate
:restrict_modification
,
on: :update
,
unless: :status_changed?
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
transition
any
-
[
:creating
]
=>
:creating
end
...
...
@@ -86,7 +84,7 @@ module Gcp
before_transition
any
=>
[
:errored
]
do
|
cluster
,
transition
|
status_reason
=
transition
.
args
.
first
cluster
.
status_reason
=
status_reason
cluster
.
status_reason
=
status_reason
if
status_reason
end
end
...
...
app/serializers/cluster_entity.rb
View file @
07247601
class
ClusterEntity
<
Grape
::
Entity
include
RequestAwareEntity
expose
:status
expose
:status
_name
,
as: :status
expose
:status_reason
end
app/services/ci/create_cluster_service.rb
View file @
07247601
...
...
@@ -5,7 +5,6 @@ module Ci
project
.
create_cluster
(
params
.
merge
(
user:
current_user
,
status:
Gcp
::
Cluster
.
statuses
[
:scheduled
],
gcp_token:
access_token
)).
tap
do
|
cluster
|
ClusterProvisionWorker
.
perform_async
(
cluster
.
id
)
if
cluster
.
persisted?
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?
.row.prepend-top-default.edit-cluster-form.js-edit-cluster-form
{
data:
{
status_path:
status_path
,
toggle_status:
@cluster
.
enabled?
?
'true'
:
'false'
,
cluster_status:
@cluster
.
status
,
cluster_status:
@cluster
.
status
_name
,
cluster_status_reason:
@cluster
.
status_reason
}}
=
render
'sidebar'
.col-lg-8
...
...
spec/factories/gcp/cluster.rb
View file @
07247601
...
...
@@ -13,11 +13,17 @@ FactoryGirl.define do
end
trait
:created_on_gke
do
status_event
:make_created
endpoint
'111.111.111.111'
ca_cert
'xxxxxx'
kubernetes_token
'xxxxxx'
username
'xxxxxx'
password
'xxxxxx'
end
trait
:errored
do
status_event
:make_errored
status_reason
'general error'
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