diff options
author | Mike Greiling <mike@pixelcog.com> | 2019-01-11 01:47:30 +0000 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2019-01-11 01:47:30 +0000 |
commit | 89c4d2ae623dbd666e2eaa58812323b81e02b4ea (patch) | |
tree | 736843b40db79adbf39553e1e6d521b117f40718 /app/models/clusters/applications/knative.rb | |
parent | a0f77090854b3510543dc42529d7353adab03da0 (diff) | |
parent | 1102deb0bd04a1bdf550ed74cf381a6bd400a7e0 (diff) | |
download | gitlab-ce-89c4d2ae623dbd666e2eaa58812323b81e02b4ea.tar.gz |
Merge branch 'knative-show-page' into 'master'
Initial Serverless Functions detailed view
See merge request gitlab-org/gitlab-ce!23863
Diffstat (limited to 'app/models/clusters/applications/knative.rb')
-rw-r--r-- | app/models/clusters/applications/knative.rb | 20 |
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 |