summaryrefslogtreecommitdiff
path: root/app/models/clusters/applications/knative.rb
diff options
context:
space:
mode:
authorChris Baumbauer <cab@cabnetworks.net>2018-12-16 23:31:38 -0800
committerChris Baumbauer <cab@cabnetworks.net>2019-01-10 14:13:41 -0800
commit1102deb0bd04a1bdf550ed74cf381a6bd400a7e0 (patch)
treed734488f04098bdabbae3ce0621debf0eb6bf918 /app/models/clusters/applications/knative.rb
parent71026ffd7e71da726a9b740d42093926f8477c3e (diff)
downloadgitlab-ce-1102deb0bd04a1bdf550ed74cf381a6bd400a7e0.tar.gz
Initial Serverless Functions detailed view
Diffstat (limited to 'app/models/clusters/applications/knative.rb')
-rw-r--r--app/models/clusters/applications/knative.rb20
1 files changed, 18 insertions, 2 deletions
diff --git a/app/models/clusters/applications/knative.rb b/app/models/clusters/applications/knative.rb
index c572c8bff44..8d79b041b64 100644
--- a/app/models/clusters/applications/knative.rb
+++ b/app/models/clusters/applications/knative.rb
@@ -41,6 +41,8 @@ module Clusters
scope :for_cluster, -> (cluster) { where(cluster: cluster) }
+ after_save :clear_reactive_cache!
+
def chart
'knative/knative'
end
@@ -79,7 +81,7 @@ module Clusters
end
def calculate_reactive_cache
- { services: read_services }
+ { services: read_services, pods: read_pods }
end
def ingress_service
@@ -87,7 +89,7 @@ module Clusters
end
def services_for(ns: namespace)
- return unless services
+ return [] unless services
return [] unless ns
services.select do |service|
@@ -95,8 +97,22 @@ module Clusters
end
end
+ def service_pod_details(ns, service)
+ with_reactive_cache do |data|
+ data[:pods].select { |pod| filter_pods(pod, ns, service) }
+ end
+ end
+
private
+ def read_pods
+ cluster.kubeclient.core_client.get_pods.as_json
+ end
+
+ def filter_pods(pod, namespace, service)
+ pod["metadata"]["namespace"] == namespace && pod["metadata"]["labels"]["serving.knative.dev/service"] == service
+ end
+
def read_services
client.get_services.as_json
rescue Kubeclient::ResourceNotFoundError