Skip to content

Commit

Permalink
Merge branch 'main' of github.com:komodorio/helm-dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
undera committed Jan 13, 2023
2 parents d0c9de9 + f3c66ec commit b76fbb1
Show file tree
Hide file tree
Showing 18 changed files with 173 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 64 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
@@ -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/*
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/pull-request-labeler.yaml
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
5 changes: 2 additions & 3 deletions charts/helm-dashboard/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions pkg/dashboard/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions pkg/dashboard/handlers/helmHandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 15 additions & 0 deletions pkg/dashboard/static/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
25 changes: 24 additions & 1 deletion pkg/dashboard/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -194,6 +194,9 @@ <h1 class="name float-start">Name</h1>
<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>
Expand Down Expand Up @@ -417,6 +420,26 @@ <h4 class="modal-title" id="upgradeModalLabel">
</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">
Expand Down
4 changes: 4 additions & 0 deletions pkg/dashboard/static/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,8 @@ nav .nav-tabs .nav-link.active {

#sectionRepo .repo-details ul .row:hover .btn {
visibility: visible;
}

.test-result {
font-size: 1rem;
}
11 changes: 11 additions & 0 deletions pkg/dashboard/subproc/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion plugin.yaml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Binary file added screenshot_run_test.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshot_run_test_result.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions scripts/install_plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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="$(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
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)"
}
echo "Downloading and installing ${name} v${version} ..."

url=""
Expand Down

0 comments on commit b76fbb1

Please sign in to comment.