Fix initial status again

This commit is contained in:
Kamil Trzcinski 2017-11-07 14:26:14 +01:00
parent f96b5eae20
commit 3cb4614273
3 changed files with 9 additions and 13 deletions

View file

@ -11,16 +11,14 @@ module Clusters
validates :cluster, presence: true
after_initialize :set_initial_status
def self.application_name
self.to_s.demodulize.underscore
end
def initial_status
if cluster&.platform_kubernetes_active?
:installable
else
:not_installable
end
def set_initial_status
self.status = 'installable' if cluster&.platform_kubernetes_active?
end
def name

View file

@ -12,6 +12,8 @@ module Clusters
default_value_for :ingress_type, :nginx
default_value_for :version, :nginx
after_initialize :set_initial_status
enum ingress_type: {
nginx: 1
}
@ -20,12 +22,8 @@ module Clusters
self.to_s.demodulize.underscore
end
def initial_status
if cluster&.application_helm_installed?
:installable
else
:not_installable
end
def set_initial_status
self.status = 'installable' if cluster&.application_helm_installed?
end
def name

View file

@ -4,7 +4,7 @@ module Clusters
extend ActiveSupport::Concern
included do
state_machine :status, initial: ->(application) { application.initial_status } do
state_machine :status, initial: :not_installable do
state :not_installable, value: -2
state :errored, value: -1
state :installable, value: 0