diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-10-04 22:13:10 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-10-04 22:13:10 +0200 |
commit | 07247601f3208fce65b3ac64ad3854dcc3dfd8c2 (patch) | |
tree | 42e0bf83e13517dd5789cf8a14851fceb6918ee8 /app | |
parent | bee5c08094b4f2c125509f61e9e03a7a700bba5e (diff) | |
download | gitlab-ce-07247601f3208fce65b3ac64ad3854dcc3dfd8c2.tar.gz |
Remove status enum from Gcp::Cluster, use state_machine#state
Diffstat (limited to 'app')
-rw-r--r-- | app/models/gcp/cluster.rb | 14 | ||||
-rw-r--r-- | app/serializers/cluster_entity.rb | 2 | ||||
-rw-r--r-- | app/services/ci/create_cluster_service.rb | 1 | ||||
-rw-r--r-- | app/views/projects/clusters/show.html.haml | 2 |
4 files changed, 8 insertions, 11 deletions
diff --git a/app/models/gcp/cluster.rb b/app/models/gcp/cluster.rb index f570c8b3c4c..fceda191880 100644 --- a/app/models/gcp/cluster.rb +++ b/app/models/gcp/cluster.rb @@ -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 diff --git a/app/serializers/cluster_entity.rb b/app/serializers/cluster_entity.rb index ca0ee8952e2..08a113c4d8a 100644 --- a/app/serializers/cluster_entity.rb +++ b/app/serializers/cluster_entity.rb @@ -1,6 +1,6 @@ class ClusterEntity < Grape::Entity include RequestAwareEntity - expose :status + expose :status_name, as: :status expose :status_reason end diff --git a/app/services/ci/create_cluster_service.rb b/app/services/ci/create_cluster_service.rb index 179dfa0c6bb..d01e167ecc3 100644 --- a/app/services/ci/create_cluster_service.rb +++ b/app/services/ci/create_cluster_service.rb @@ -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 diff --git a/app/views/projects/clusters/show.html.haml b/app/views/projects/clusters/show.html.haml index f160ce98b55..ecf43981c49 100644 --- a/app/views/projects/clusters/show.html.haml +++ b/app/views/projects/clusters/show.html.haml @@ -1,7 +1,7 @@ - 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 |