Expose applications as array via API

This commit is contained in:
Kamil Trzcinski 2017-11-02 17:57:50 +01:00
parent 94d5f5680e
commit 4d0a700da0
4 changed files with 13 additions and 12 deletions

View file

@ -5,7 +5,7 @@ module Clusters
NAME = 'helm'.freeze
include ::Clusters::Concerns::AppStatus
include ::Clusters::Concerns::ApplicationStatus
belongs_to :cluster, class_name: 'Clusters::Cluster', foreign_key: :cluster_id

View file

@ -51,6 +51,12 @@ module Clusters
end
end
def applications
[
application_helm || build_application_helm
]
end
def provider
return provider_gcp if gcp?
end

View file

@ -1,14 +1,15 @@
module Clusters
module Concerns
module AppStatus
module ApplicationStatus
extend ActiveSupport::Concern
included do
state_machine :status, initial: :scheduled do
state_machine :status, initial: :installable do
state :errored, value: -1
state :scheduled, value: 0
state :installing, value: 1
state :installed, value: 2
state :installable, value: 0
state :scheduled, value: 1
state :installing, value: 2
state :installed, value: 3
event :make_installing do
transition any - [:installing] => :installing

View file

@ -5,11 +5,5 @@ module Clusters
def gke_cluster_url
"https://console.cloud.google.com/kubernetes/clusters/details/#{provider.zone}/#{name}" if gcp?
end
def applications
Clusters::Cluster::APPLICATIONS.map do |key, value|
value.find_by(cluster_id: id)
end.compact
end
end
end