From 861971a85e9bd4be50e901f93dc3d4429be1d823 Mon Sep 17 00:00:00 2001 From: yanmingfan Date: Sat, 2 Jun 2018 14:29:11 +0800 Subject: [PATCH] add label and namespace to components --- pkg/models/components.go | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/pkg/models/components.go b/pkg/models/components.go index 89f3b7d7d..c76091b5d 100644 --- a/pkg/models/components.go +++ b/pkg/models/components.go @@ -28,13 +28,15 @@ const KUBESYSTEM = "kube-system" const OPENPITRIX = "openpitrix-system" type Components struct { - Name string `json:"name"` - Version string `json:"version"` - Kind string `json:"kind"` - Replicas int `json:"replicas"` - HealthStatus string `json:"healthStatus"` - SelfLink string `json:"selfLink"` - UpdateTime time.Time `json:"updateTime"` + Name string `json:"name"` + Version string `json:"version"` + Kind string `json:"kind"` + Namespace string `json:"namespace"` + Label interface{} `json:"label"` + Replicas int `json:"replicas"` + HealthStatus string `json:"healthStatus"` + SelfLink string `json:"selfLink"` + UpdateTime time.Time `json:"updateTime"` } /*** @@ -77,6 +79,8 @@ func GetComponents() (result []Components, err error) { components.Name = template components.Kind = "Pod" components.SelfLink = pod.SelfLink + components.Label = pod.Labels + components.Namespace = pod.Namespace version := strings.Split(pod.Spec.Containers[0].Image, ":") if len(version) < 2 { @@ -131,6 +135,8 @@ func GetComponents() (result []Components, err error) { components.Name = "kube-addon-manager" components.Kind = "Pod" components.SelfLink = pod.SelfLink + components.Label = pod.Labels + components.Namespace = pod.Namespace version := strings.Split(pod.Spec.Containers[0].Image, ":") if len(version) < 2 { @@ -180,6 +186,8 @@ func GetComponents() (result []Components, err error) { components.Name = ds.Name components.Kind = "Daemonset" components.SelfLink = ds.SelfLink + components.Label = ds.Labels + components.Namespace = ds.Namespace version := strings.Split(ds.Spec.Template.Spec.Containers[0].Image, ":") if len(version) < 2 { @@ -236,6 +244,8 @@ func GetComponents() (result []Components, err error) { components.Name = dm.Name components.Kind = "Deployment" components.SelfLink = dm.SelfLink + components.Label = dm.Labels + components.Namespace = dm.Namespace components.Replicas = int(dm.Status.Replicas) version := strings.Split(dm.Spec.Template.Spec.Containers[0].Image, ":") if len(version) < 2 {