diff --git a/src/interfaces/listener.go b/src/interfaces/listener.go index 0a0e3fe..a6bc6c8 100644 --- a/src/interfaces/listener.go +++ b/src/interfaces/listener.go @@ -5,9 +5,9 @@ import ( "fmt" "html/template" "io" - "io/ioutil" "log" "net/http" + "os" "path" "sort" "time" @@ -94,7 +94,7 @@ func (d *DashboardController) renderDashboardStatus(rw http.ResponseWriter, view "unstable": func() uint { return kube.State_unstable }, }) - b, err := ioutil.ReadFile(path.Join(d.Templates, "dashboard.html")) + b, err := os.ReadFile(path.Join(d.Templates, "dashboard.html")) if err != nil { e(rw, err) diff --git a/src/model/kube/fakeData.go b/src/model/kube/fakeData.go index 50c162a..a62d7d3 100644 --- a/src/model/kube/fakeData.go +++ b/src/model/kube/fakeData.go @@ -23,6 +23,9 @@ func (d *DemoService) GetKubernetesDeployments() (map[string]appsV1.Deployment, ObjectMeta: metaV1.ObjectMeta{ Name: "flamingo", + Labels: map[string]string{ + "chart": "flamingo-1.0.1", + }, }, Spec: appsV1.DeploymentSpec{ Template: v1.PodTemplateSpec{ @@ -45,6 +48,10 @@ func (d *DemoService) GetKubernetesDeployments() (map[string]appsV1.Deployment, deployments["akeneo"] = appsV1.Deployment{ ObjectMeta: metaV1.ObjectMeta{ Name: "akeneo", + Labels: map[string]string{ + "chart": "akeneo-1.2.3", + "helm.sh/version": "1.2.3", + }, }, Spec: appsV1.DeploymentSpec{ Template: v1.PodTemplateSpec{ diff --git a/src/model/kube/statusFetcher.go b/src/model/kube/statusFetcher.go index 609d802..99afea6 100644 --- a/src/model/kube/statusFetcher.go +++ b/src/model/kube/statusFetcher.go @@ -3,7 +3,7 @@ package kube import ( "encoding/json" "fmt" - "io/ioutil" + "io" "log" "math/rand" "net/http" @@ -29,6 +29,7 @@ type ( // AppDeploymentInfo wraps Info on any Deployment's Data AppDeploymentInfo struct { Name string + Labels map[string]string Ingress []K8sIngressInfo Images []Image K8sDeployment apps.Deployment @@ -364,6 +365,14 @@ func checkDeploymentWithHealthCheck(name string, app *vistectureCore.Application d.Images = append(d.Images, buildImageStruct(c.Image)) } + d.Labels = make(map[string]string) + for k, e := range depl.Labels { + if k == "helm.sh/version" { + d.Labels["helm"] = e + } + d.Labels[k] = e + } + if !podExists(depl) { d.AppStateInfo.State = State_failed d.AppStateInfo.StateReason = "No pod available" @@ -477,7 +486,7 @@ func checkHealth(status AppDeploymentInfo, checkBaseUrl string, healtcheckPath s Services: []HealthCheckService{}, } - responseBody, bodyErr := ioutil.ReadAll(r.Body) + responseBody, bodyErr := io.ReadAll(r.Body) if bodyErr != nil { return false, "Could not read from HealthcheckPath", HealthCheckType_HealthCheck } diff --git a/templates/dashboard/dashboard.html b/templates/dashboard/dashboard.html index b07dcb9..293a802 100644 --- a/templates/dashboard/dashboard.html +++ b/templates/dashboard/dashboard.html @@ -47,6 +47,15 @@ {{ .Version }}
{{- end }} + + {{- if .Labels.helm}} + {{ .Labels.helm }}
+ {{- else if .Labels.chart}} + {{ .Labels.chart }}
+ {{- else }} +
+ {{- end }} + {{- end }} {{- end -}} @@ -59,6 +68,7 @@ Urls (Ingresses) Status Info Image Version(s) + Helm Chart {{- end -}}