Commit 4d0a700d authored by Kamil Trzcinski's avatar Kamil Trzcinski

Expose applications as array via API

parent 94d5f568
......@@ -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
......
......@@ -51,6 +51,12 @@ module Clusters
end
end
def applications
[
application_helm || build_application_helm
]
end
def provider
return provider_gcp if gcp?
end
......
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
......
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment