Skip to content

Commit

Permalink
improve list of components to get logs (#1575)
Browse files Browse the repository at this point in the history
* only k8s workload object kinds for the list of components to get logs; none for helm or unknown app type
  • Loading branch information
konstan authored May 23, 2024
1 parent 07db18e commit dc262c0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
1 change: 1 addition & 0 deletions code/src/cljs/sixsq/nuvla/ui/pages/apps/utils.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
(def subtype-component "component")
(def subtype-application "application")
(def subtype-application-k8s "application_kubernetes")
(def subtype-application-helm "application_helm")
(def subtype-applications-sets "applications_sets")

(def apps-description-template "# App Description Placeholder
Expand Down
32 changes: 27 additions & 5 deletions code/src/cljs/sixsq/nuvla/ui/pages/deployments_detail/subs.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
(fn [{:keys [subtype]}]
(= subtype apps-utils/subtype-application-k8s)))

(reg-sub
::is-deployment-application-helm?
:<- [::deployment-module]
(fn [{:keys [subtype]}]
(= subtype apps-utils/subtype-application-helm)))


(defn parse-application-yaml
[docker-compose]
Expand All @@ -65,13 +71,29 @@
(catch :default _))]
(js->clj yaml)))

(def ^:const k8s-workload-object-kinds
#{"CronJob"
"DaemonSet"
"Deployment"
"Job"
"Pod"
"ReplicaSet"
"StatefulSet"})

(defn only-k8s-workload-object-kinds
[object]
(when (contains? k8s-workload-object-kinds (get object "kind"))
(let [kind (get object "kind")
name (get-in object ["metadata" "name"])]
(str kind "/" name))))

(reg-sub
::deployment-services-list
:<- [::is-deployment-application?]
:<- [::is-deployment-application-kubernetes?]
:<- [::is-deployment-application-helm?]
:<- [::deployment-module-content]
(fn [[is-application? is-application-kubernetes? {:keys [docker-compose]}]]
(fn [[is-application? is-application-kubernetes? is-application-helm? {:keys [docker-compose]}]]
(cond
is-application? (some-> docker-compose
parse-application-yaml
Expand All @@ -81,11 +103,11 @@
sort)
is-application-kubernetes? (some->> docker-compose
parse-application-yaml
(map #(let [kind (get % "kind")
meta-name (get-in % ["metadata" "name"])]
(str kind "/" meta-name)))
(map only-k8s-workload-object-kinds)
(remove nil?)
sort)
:else ["machine"])))
is-application-helm? []
:else [])))


(reg-sub
Expand Down

0 comments on commit dc262c0

Please sign in to comment.