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

Expose applications as array via API

parent 94d5f568
...@@ -5,7 +5,7 @@ module Clusters ...@@ -5,7 +5,7 @@ module Clusters
NAME = 'helm'.freeze NAME = 'helm'.freeze
include ::Clusters::Concerns::AppStatus include ::Clusters::Concerns::ApplicationStatus
belongs_to :cluster, class_name: 'Clusters::Cluster', foreign_key: :cluster_id belongs_to :cluster, class_name: 'Clusters::Cluster', foreign_key: :cluster_id
......
...@@ -51,6 +51,12 @@ module Clusters ...@@ -51,6 +51,12 @@ module Clusters
end end
end end
def applications
[
application_helm || build_application_helm
]
end
def provider def provider
return provider_gcp if gcp? return provider_gcp if gcp?
end end
......
module Clusters module Clusters
module Concerns module Concerns
module AppStatus module ApplicationStatus
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do included do
state_machine :status, initial: :scheduled do state_machine :status, initial: :installable do
state :errored, value: -1 state :errored, value: -1
state :scheduled, value: 0 state :installable, value: 0
state :installing, value: 1 state :scheduled, value: 1
state :installed, value: 2 state :installing, value: 2
state :installed, value: 3
event :make_installing do event :make_installing do
transition any - [:installing] => :installing transition any - [:installing] => :installing
......
...@@ -5,11 +5,5 @@ module Clusters ...@@ -5,11 +5,5 @@ module Clusters
def gke_cluster_url def gke_cluster_url
"https://console.cloud.google.com/kubernetes/clusters/details/#{provider.zone}/#{name}" if gcp? "https://console.cloud.google.com/kubernetes/clusters/details/#{provider.zone}/#{name}" if gcp?
end end
def applications
Clusters::Cluster::APPLICATIONS.map do |key, value|
value.find_by(cluster_id: id)
end.compact
end
end 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