Merge branch 'main' of github.com:komodorio/helm-dashboard

This commit is contained in:
Andrei Pohilko
2023-01-13 12:41:05 +00:00
18 changed files with 173 additions and 12 deletions

View File

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

64
.github/labeler.yml vendored Normal file
View File

@@ -0,0 +1,64 @@
# This configures label matching for PR's.
#
# The keys are labels, and the values are lists of minimatch patterns
# to which those labels apply.
#
# NOTE: This can only add labels, not remove them.
# NOTE: Due to YAML syntax limitations, patterns or labels which start
# with a character that is part of the standard YAML syntax must be
# quoted.
#
# Please keep the labels sorted and deduplicated.
api:
- pkg/dashboard/api.go
app:
- main.go
- pkg/dashboard/server.go
- pkg/dashboard/subproc/*
- pkg/dashboard/utils/*
backend:
- pkg/dashboard/handlers/*
- pkg/dashboard/scanners/*
ci:
- .github/workflow/build.yml
- ci/*
- Makefile
- scripts/*
docs:
- CODE_OF_CONDUCT.md
- CONTRIBUTING.md
- LICENSE
- README.md
- screenshot*.png
- screenshot*.svg
docker:
- .dockerignore
- Dockerfile
helm-charts:
- charts/*
github-actions:
- .github/ISSUE_TEMPLATE/*
- .github/labeler.yml
- .github/pull_request_template
- .github/workflow/pull-request-labeler.yaml
release:
- .github/workflows/publish-chart.yaml
- .github/workflows/release.yaml
- .goreleaser.yml
- artifacthub-repo.yml
- plugin.yaml
scanners:
- pkg/dashboard/scanners/*
frontend:
- pkg/dashboard/static/*

View File

@@ -47,7 +47,7 @@ jobs:
timeout-minutes: 60
steps:
- name: Check out the repo
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Build and push
uses: docker/build-push-action@v2
@@ -60,7 +60,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Helm Template Check For Sanity

View File

@@ -0,0 +1,14 @@
name: "Pull Request Labeler"
on:
- pull_request_target
jobs:
triage:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"

1
.gitignore vendored
View File

@@ -15,6 +15,7 @@
# Output of the go coverage tool, specifically when used with LiteIDE
*.out
*.cov
# Dependency directories (remove the comment below to include it)
# vendor/

View File

@@ -52,4 +52,4 @@ By contributing, you agree that your contributions will be licensed under its Ap
## Questions?
Contact us on [Slack](https://join.slack.com/t/komodorkommunity/shared_invite/zt-1dm3cnkue-ov1Yh~_95teA35QNx5yuMg).
Contact us on [Slack](https://komodorkommunity.slack.com).

View File

@@ -88,6 +88,16 @@ The official helm chart is [available here](https://github.com/komodorio/helm-ch
Download the appropriate [release package](https://github.com/komodorio/helm-dashboard/releases) for your platform, unpack it and just run `dashboard` binary from it.
## Execute Helm tests
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
You can execute `helm test` for the specific release as below:
![](screenshot_run_test.png)
The result of executed `helm test` for the release will be disapled as below:
![](screenshot_run_test_result.png)
## Scanner Integrations
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:
## Support Channels
We have two main channels for supporting the Helm Dashboard
users: [Slack community](https://join.slack.com/t/komodorkommunity/shared_invite/zt-1dm3cnkue-ov1Yh~_95teA35QNx5yuMg) for general conversations
users: [Slack community](https://komodorkommunity.slack.com) for general conversations
and [GitHub issues](https://github.com/komodorio/helm-dashboard/issues) for real bugs.
## Contributing

View File

@@ -19,11 +19,10 @@ metadata:
rules:
- apiGroups: ["*"]
resources: ["*"]
verbs: ["get", "list", "watch"]
{{- if .Values.dashboard.allowWriteActions }}
- apiGroups: ["*"]
resources: ["*"]
verbs: ["get", "list", "watch", "create", "delete", "patch", "update"]
{{- else }}
verbs: ["get", "list", "watch"]
{{- end }}
---
apiVersion: rbac.authorization.k8s.io/v1

View File

@@ -112,6 +112,7 @@ func configureHelms(api *gin.RouterGroup, data *subproc.DataLayer) {
api.GET("/charts/:section", h.GetInfoSection)
api.GET("/charts/show", h.Show)
api.POST("/charts/install", h.Install)
api.POST("/charts/tests", h.Tests)
api.POST("/charts/rollback", h.Rollback)
api.GET("/repo", h.RepoList)

View File

@@ -176,6 +176,22 @@ func (h *HelmHandler) Install(c *gin.Context) {
c.String(http.StatusAccepted, out)
}
func (h *HelmHandler) Tests(c *gin.Context) {
qp, err := utils.GetQueryProps(c, false)
if err != nil {
_ = c.AbortWithError(http.StatusBadRequest, err)
return
}
out, err := h.Data.RunTests(qp.Namespace, qp.Name)
if err != nil {
_ = c.AbortWithError(http.StatusInternalServerError, err)
return
}
c.String(http.StatusOK, out)
}
func (h *HelmHandler) GetInfoSection(c *gin.Context) {
qp, err := utils.GetQueryProps(c, true)
if err != nil {

View File

@@ -343,3 +343,18 @@ $("#btnAddRepository").click(function () {
setHashParam("section", "repository")
window.location.reload()
})
$("#btnTest").click(function() {
$("#testModal .test-result").empty().prepend('<span class="spinner-border spinner-border-sm" role="status" aria-hidden="true"></span>')
$.ajax({
type: 'POST',
url: "/api/helm/charts/tests" + "?namespace=" + getHashParam("namespace") + "&name=" + getHashParam("chart")
}).fail(function (xhr) {
reportError("Failed to execute test for chart", xhr)
}).done(function (data) {
$("#testModal .test-result").empty().html(data.replaceAll("\n", "<br>"))
})
const myModal = new bootstrap.Modal(document.getElementById('testModal'), {});
myModal.show()
})

View File

@@ -42,7 +42,7 @@
</a>
<ul class="dropdown-menu fs-80">
<li><a class="dropdown-item"
href="https://join.slack.com/t/komodorkommunity/shared_invite/zt-1dm3cnkue-ov1Yh~_95teA35QNx5yuMg"
href="https://komodorkommunity.slack.com"
target="_blank"><i class="bi-slack"></i> Support Chat</a></li>
<li><a class="dropdown-item" href="https://github.com/komodorio/helm-dashboard" target="_blank"><i
class="bi-github"></i> Project Page</a></li>
@@ -194,6 +194,9 @@
<button id="btnRollback" class="btn btn-sm btn-light bg-white border border-secondary me-2"
title="Rollback to this revision"><i class="bi-arrow-repeat"></i> <span>Rollback</span>
</button>
<button id="btnTest" class="btn btn-sm btn-light bg-white border border-secondary"
title="Run tests for this chart"><i class="bi-check-circle"></i> <span>Run tests</span>
</button>
<button id="btnUninstall" class="btn btn-sm btn-light bg-white border border-secondary"
title="Uninstall the chart"><i class="bi-trash3"></i> Uninstall
</button>
@@ -417,6 +420,26 @@
</div>
</div>
<div class="modal" id="testModal" tabindex="-1">
<div class="modal-dialog modal-dialog modal-dialog-scrollable modal-xl">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="testModalLabel">
<span class="type">Test results</span>
</h4>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body border-bottom fs-5">
<div class="row">
<div class="col">
<span class="test-result"></span>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Modal -->
<div class="modal fade" id="PowerOffModal" tabindex="-1" aria-labelledby="ModalLabel" aria-hidden="true">
<div class="modal-dialog">

View File

@@ -296,3 +296,7 @@ nav .nav-tabs .nav-link.active {
#sectionRepo .repo-details ul .row:hover .btn {
visibility: visible;
}
.test-result {
font-size: 1rem;
}

View File

@@ -278,6 +278,17 @@ func (d *DataLayer) ChartInstall(namespace string, name string, repoChart string
return out, nil
}
func (d *DataLayer) RunTests(namespace string, name string) (string, error) {
cmd := []string{"test", name, "--namespace", namespace, "--logs"}
out, err := d.runCommandHelm(cmd...)
if err != nil {
return "", err
}
return out, nil
}
func RevisionDiff(functor SectionFn, ext string, namespace string, name string, revision1 int, revision2 int, flag bool) (string, error) {
if revision1 == 0 || revision2 == 0 {
log.Debugf("One of revisions is zero: %d %d", revision1, revision2)

View File

@@ -1,5 +1,5 @@
name: "dashboard"
version: "0.3.0"
version: "0.3.1"
usage: "A simplified way of working with Helm"
description: "View HELM situation in nice web UI"
command: "$HELM_PLUGIN_DIR/bin/helm-dashboard"

BIN
screenshot_run_test.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

BIN
screenshot_run_test_result.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

View File

@@ -4,14 +4,17 @@
name="helm-dashboard"
repo="https://github.com/komodorio/${name}"
api_repo="https://api.github.com/repos/komodorio/${name}/releases/latest"
if [ -n "${HELM_PUSH_PLUGIN_NO_INSTALL_HOOK}" ]; then
echo "Development mode: not downloading versioned release."
exit 0
fi
version="$(curl -X GET --header \"Accept: application/json\" ${api_repo} | grep '\"name\": "v.*\"' | cut -d 'v' -f 2 | cut -d '"' -f 1)"
[ -z "$version" ] && {
version="$(cat plugin.yaml | grep "version" | cut -d '"' -f 2)"
# TODO: if no version provided, get it from https://api.github.com/repos/komodorio/helm-dashboard/releases/latest
}
echo "Downloading and installing ${name} v${version} ..."
url=""