Skip to content

Commit b76fbb1

Browse files
committed
Merge branch 'main' of github.com:komodorio/helm-dashboard
2 parents d0c9de9 + f3c66ec commit b76fbb1

File tree

18 files changed

+173
-12
lines changed

18 files changed

+173
-12
lines changed

.github/ISSUE_TEMPLATE/bug.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ body:
5454

5555
value: |
5656
57-
You can also join our slack community [here](https://join.slack.com/t/komodorkommunity/shared_invite/zt-1dm3cnkue-ov1Yh~_95teA35QNx5yuMg)
57+
You can also join our slack community [here](https://komodorkommunity.slack.com)
5858
5959
Feel free to check out other cool repositories of the [komodorio](https://github.com/komodorio)

.github/labeler.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# This configures label matching for PR's.
2+
#
3+
# The keys are labels, and the values are lists of minimatch patterns
4+
# to which those labels apply.
5+
#
6+
# NOTE: This can only add labels, not remove them.
7+
# NOTE: Due to YAML syntax limitations, patterns or labels which start
8+
# with a character that is part of the standard YAML syntax must be
9+
# quoted.
10+
#
11+
# Please keep the labels sorted and deduplicated.
12+
13+
api:
14+
- pkg/dashboard/api.go
15+
16+
app:
17+
- main.go
18+
- pkg/dashboard/server.go
19+
- pkg/dashboard/subproc/*
20+
- pkg/dashboard/utils/*
21+
22+
backend:
23+
- pkg/dashboard/handlers/*
24+
- pkg/dashboard/scanners/*
25+
26+
ci:
27+
- .github/workflow/build.yml
28+
- ci/*
29+
- Makefile
30+
- scripts/*
31+
32+
docs:
33+
- CODE_OF_CONDUCT.md
34+
- CONTRIBUTING.md
35+
- LICENSE
36+
- README.md
37+
- screenshot*.png
38+
- screenshot*.svg
39+
40+
docker:
41+
- .dockerignore
42+
- Dockerfile
43+
44+
helm-charts:
45+
- charts/*
46+
47+
github-actions:
48+
- .github/ISSUE_TEMPLATE/*
49+
- .github/labeler.yml
50+
- .github/pull_request_template
51+
- .github/workflow/pull-request-labeler.yaml
52+
53+
release:
54+
- .github/workflows/publish-chart.yaml
55+
- .github/workflows/release.yaml
56+
- .goreleaser.yml
57+
- artifacthub-repo.yml
58+
- plugin.yaml
59+
60+
scanners:
61+
- pkg/dashboard/scanners/*
62+
63+
frontend:
64+
- pkg/dashboard/static/*

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
timeout-minutes: 60
4848
steps:
4949
- name: Check out the repo
50-
uses: actions/checkout@v2
50+
uses: actions/checkout@v3
5151

5252
- name: Build and push
5353
uses: docker/build-push-action@v2
@@ -60,7 +60,7 @@ jobs:
6060
runs-on: ubuntu-latest
6161
steps:
6262
- name: Checkout
63-
uses: actions/checkout@v2
63+
uses: actions/checkout@v3
6464
with:
6565
fetch-depth: 0
6666
- name: Helm Template Check For Sanity
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: "Pull Request Labeler"
2+
on:
3+
- pull_request_target
4+
5+
jobs:
6+
triage:
7+
permissions:
8+
contents: read
9+
pull-requests: write
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/labeler@v4
13+
with:
14+
repo-token: "${{ secrets.GITHUB_TOKEN }}"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
# Output of the go coverage tool, specifically when used with LiteIDE
1717
*.out
18+
*.cov
1819

1920
# Dependency directories (remove the comment below to include it)
2021
# vendor/

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ By contributing, you agree that your contributions will be licensed under its Ap
5252

5353
## Questions?
5454

55-
Contact us on [Slack](https://join.slack.com/t/komodorkommunity/shared_invite/zt-1dm3cnkue-ov1Yh~_95teA35QNx5yuMg).
55+
Contact us on [Slack](https://komodorkommunity.slack.com).

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ The official helm chart is [available here](https://github.com/komodorio/helm-ch
8888

8989
Download the appropriate [release package](https://github.com/komodorio/helm-dashboard/releases) for your platform, unpack it and just run `dashboard` binary from it.
9090

91+
## Execute Helm tests
92+
93+
For all the release(s) (istalled helm charts), you can execute helm tests for that release. For the tests to execute successfully, you need to have existing tests for that helm chart
94+
95+
You can execute `helm test` for the specific release as below:
96+
![](screenshot_run_test.png)
97+
98+
The result of executed `helm test` for the release will be disapled as below:
99+
![](screenshot_run_test_result.png)
100+
91101
## Scanner Integrations
92102

93103
Upon startup, Helm Dashboard detects the presence of [Trivy](https://github.com/aquasecurity/trivy)
@@ -104,7 +114,7 @@ button at the bottom of the dialog:
104114
## Support Channels
105115

106116
We have two main channels for supporting the Helm Dashboard
107-
users: [Slack community](https://join.slack.com/t/komodorkommunity/shared_invite/zt-1dm3cnkue-ov1Yh~_95teA35QNx5yuMg) for general conversations
117+
users: [Slack community](https://komodorkommunity.slack.com) for general conversations
108118
and [GitHub issues](https://github.com/komodorio/helm-dashboard/issues) for real bugs.
109119

110120
## Contributing

charts/helm-dashboard/templates/serviceaccount.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,10 @@ metadata:
1919
rules:
2020
- apiGroups: ["*"]
2121
resources: ["*"]
22-
verbs: ["get", "list", "watch"]
2322
{{- if .Values.dashboard.allowWriteActions }}
24-
- apiGroups: ["*"]
25-
resources: ["*"]
2623
verbs: ["get", "list", "watch", "create", "delete", "patch", "update"]
24+
{{- else }}
25+
verbs: ["get", "list", "watch"]
2726
{{- end }}
2827
---
2928
apiVersion: rbac.authorization.k8s.io/v1

pkg/dashboard/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ func configureHelms(api *gin.RouterGroup, data *subproc.DataLayer) {
112112
api.GET("/charts/:section", h.GetInfoSection)
113113
api.GET("/charts/show", h.Show)
114114
api.POST("/charts/install", h.Install)
115+
api.POST("/charts/tests", h.Tests)
115116
api.POST("/charts/rollback", h.Rollback)
116117

117118
api.GET("/repo", h.RepoList)

pkg/dashboard/handlers/helmHandlers.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,22 @@ func (h *HelmHandler) Install(c *gin.Context) {
176176
c.String(http.StatusAccepted, out)
177177
}
178178

179+
func (h *HelmHandler) Tests(c *gin.Context) {
180+
qp, err := utils.GetQueryProps(c, false)
181+
if err != nil {
182+
_ = c.AbortWithError(http.StatusBadRequest, err)
183+
return
184+
}
185+
186+
out, err := h.Data.RunTests(qp.Namespace, qp.Name)
187+
if err != nil {
188+
_ = c.AbortWithError(http.StatusInternalServerError, err)
189+
return
190+
}
191+
192+
c.String(http.StatusOK, out)
193+
}
194+
179195
func (h *HelmHandler) GetInfoSection(c *gin.Context) {
180196
qp, err := utils.GetQueryProps(c, true)
181197
if err != nil {

pkg/dashboard/static/actions.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,3 +343,18 @@ $("#btnAddRepository").click(function () {
343343
setHashParam("section", "repository")
344344
window.location.reload()
345345
})
346+
347+
$("#btnTest").click(function() {
348+
$("#testModal .test-result").empty().prepend('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>')
349+
$.ajax({
350+
type: 'POST',
351+
url: "/api/helm/charts/tests" + "?namespace=" + getHashParam("namespace") + "&name=" + getHashParam("chart")
352+
}).fail(function (xhr) {
353+
reportError("Failed to execute test for chart", xhr)
354+
}).done(function (data) {
355+
$("#testModal .test-result").empty().html(data.replaceAll("\n", "<br>"))
356+
})
357+
358+
const myModal = new bootstrap.Modal(document.getElementById('testModal'), {});
359+
myModal.show()
360+
})

pkg/dashboard/static/index.html

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
</a>
4343
<ul class="dropdown-menu fs-80">
4444
<li><a class="dropdown-item"
45-
href="https://join.slack.com/t/komodorkommunity/shared_invite/zt-1dm3cnkue-ov1Yh~_95teA35QNx5yuMg"
45+
href="https://komodorkommunity.slack.com"
4646
target="_blank"><i class="bi-slack"></i> Support Chat</a></li>
4747
<li><a class="dropdown-item" href="https://github.com/komodorio/helm-dashboard" target="_blank"><i
4848
class="bi-github"></i> Project Page</a></li>
@@ -194,6 +194,9 @@ <h1 class="name float-start">Name</h1>
194194
<button id="btnRollback" class="btn btn-sm btn-light bg-white border border-secondary me-2"
195195
title="Rollback to this revision"><i class="bi-arrow-repeat"></i> <span>Rollback</span>
196196
</button>
197+
<button id="btnTest" class="btn btn-sm btn-light bg-white border border-secondary"
198+
title="Run tests for this chart"><i class="bi-check-circle"></i> <span>Run tests</span>
199+
</button>
197200
<button id="btnUninstall" class="btn btn-sm btn-light bg-white border border-secondary"
198201
title="Uninstall the chart"><i class="bi-trash3"></i> Uninstall
199202
</button>
@@ -417,6 +420,26 @@ <h4 class="modal-title" id="upgradeModalLabel">
417420
</div>
418421
</div>
419422

423+
<div class="modal" id="testModal" tabindex="-1">
424+
<div class="modal-dialog modal-dialog modal-dialog-scrollable modal-xl">
425+
<div class="modal-content">
426+
<div class="modal-header">
427+
<h4 class="modal-title" id="testModalLabel">
428+
<span class="type">Test results</span>
429+
</h4>
430+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
431+
</div>
432+
<div class="modal-body border-bottom fs-5">
433+
<div class="row">
434+
<div class="col">
435+
<span class="test-result"></span>
436+
</div>
437+
</div>
438+
</div>
439+
</div>
440+
</div>
441+
</div>
442+
420443
<!-- Modal -->
421444
<div class="modal fade" id="PowerOffModal" tabindex="-1" aria-labelledby="ModalLabel" aria-hidden="true">
422445
<div class="modal-dialog">

pkg/dashboard/static/styles.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,4 +295,8 @@ nav .nav-tabs .nav-link.active {
295295

296296
#sectionRepo .repo-details ul .row:hover .btn {
297297
visibility: visible;
298+
}
299+
300+
.test-result {
301+
font-size: 1rem;
298302
}

pkg/dashboard/subproc/data.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,17 @@ func (d *DataLayer) ChartInstall(namespace string, name string, repoChart string
278278
return out, nil
279279
}
280280

281+
func (d *DataLayer) RunTests(namespace string, name string) (string, error) {
282+
cmd := []string{"test", name, "--namespace", namespace, "--logs"}
283+
284+
out, err := d.runCommandHelm(cmd...)
285+
if err != nil {
286+
return "", err
287+
}
288+
289+
return out, nil
290+
}
291+
281292
func RevisionDiff(functor SectionFn, ext string, namespace string, name string, revision1 int, revision2 int, flag bool) (string, error) {
282293
if revision1 == 0 || revision2 == 0 {
283294
log.Debugf("One of revisions is zero: %d %d", revision1, revision2)

plugin.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: "dashboard"
2-
version: "0.3.0"
2+
version: "0.3.1"
33
usage: "A simplified way of working with Helm"
44
description: "View HELM situation in nice web UI"
55
command: "$HELM_PLUGIN_DIR/bin/helm-dashboard"

screenshot_run_test.png

47.9 KB
Loading

screenshot_run_test_result.png

60 KB
Loading

scripts/install_plugin.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44

55
name="helm-dashboard"
66
repo="https://github.com/komodorio/${name}"
7+
api_repo="https://api.github.com/repos/komodorio/${name}/releases/latest"
78

89
if [ -n "${HELM_PUSH_PLUGIN_NO_INSTALL_HOOK}" ]; then
910
echo "Development mode: not downloading versioned release."
1011
exit 0
1112
fi
1213

13-
version="$(cat plugin.yaml | grep "version" | cut -d '"' -f 2)"
14-
# TODO: if no version provided, get it from https://api.github.com/repos/komodorio/helm-dashboard/releases/latest
14+
version="$(curl -X GET --header \"Accept: application/json\" ${api_repo} | grep '\"name\": "v.*\"' | cut -d 'v' -f 2 | cut -d '"' -f 1)"
15+
[ -z "$version" ] && {
16+
version="$(cat plugin.yaml | grep "version" | cut -d '"' -f 2)"
17+
}
1518
echo "Downloading and installing ${name} v${version} ..."
1619

1720
url=""

0 commit comments

Comments
 (0)