Skip to content

Commit

Permalink
chore: add Helm Chart column (#17)
Browse files Browse the repository at this point in the history
* chore: add Helm Chart coloum

* chore: remove ioutil and use io, os package

---------

Co-authored-by: dennie.walo <[email protected]>
  • Loading branch information
denniewalo and dennie.walo authored Apr 17, 2024
1 parent f21d1bf commit 14848bf
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/interfaces/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (
"fmt"
"html/template"
"io"
"io/ioutil"
"log"
"net/http"
"os"
"path"
"sort"
"time"
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions src/model/kube/fakeData.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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{
Expand Down
13 changes: 11 additions & 2 deletions src/model/kube/statusFetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package kube
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"log"
"math/rand"
"net/http"
Expand All @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down
10 changes: 10 additions & 0 deletions templates/dashboard/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,15 @@
<span title="{{ .FullPath }}">{{ .Version }}</span><br/>
{{- end }}
</td>
<td class="mdl-data-table__cell--non-numeric">
{{- if .Labels.helm}}
<span title="Helm">{{ .Labels.helm }}</span><br/>
{{- else if .Labels.chart}}
<span title="Helm">{{ .Labels.chart }}</span><br/>
{{- else }}
<span title="Helm"></span><br/>
{{- end }}
</td>
</tr>
{{- end }}
{{- end -}}
Expand All @@ -59,6 +68,7 @@
<th class="mdl-data-table__cell--non-numeric urls">Urls (Ingresses)</th>
<th class="mdl-data-table__cell--non-numeric cell-status">Status Info</th>
<th class="mdl-data-table__cell--non-numeric">Image Version(s)</th>
<th class="mdl-data-table__cell--non-numeric">Helm Chart</th>
</tr>
{{- end -}}

Expand Down

0 comments on commit 14848bf

Please sign in to comment.