* feat(helm): add helm chart backport to ce EE-1409 (#5425) * EE-1311 Helm Chart Backport from EE * backport to ce Co-authored-by: Matt Hook <hookenz@gmail.com> * feat(helm) helm chart backport from ee EE-1311 (#5436) * Add missing defaultHelmRepoUrl and mock testing * Backport EE-1477 * Backport updates to helm tests from EE * add https by default changes and ssl to tls renaming from EE * Port install integration test. Disabled by default to pass CI checks * merged changes from EE for the integration test * kube proxy whitelist updated to support internal helm install command Co-authored-by: zees-dev <dev.786zshan@gmail.com> * Pull in all changes from tech review in EE-943 * feat(helm): add helm chart backport to ce EE-1409 (#5425) * EE-1311 Helm Chart Backport from EE * backport to ce Co-authored-by: Matt Hook <hookenz@gmail.com> * Pull in all changes from tech review in EE-943 * added helm to sidebar after rebase, sync CE with EE * backport EE-1278, squashed, diffed, updated * helm install openapi spec update * resolved conflicts, updated code * - matching ee codebase at 0afe57034449ee0e9f333d92c252a13995a93019 - helm install using endpoint middleware - remove trailing slash from added/persisted helm repo urls * feat(helm) use libhelm url validator and improved path assembly EE-1554 (#5561) * feat(helm/userrepos) fix getting global repo for ordinary users EE-1562 (#5567) * feat(helm/userrepos) fix getting global repo for ordinary users EE-1562 * post review changes and further backported changes from EE * resolved conflicts, updated code * fixed helm_install handler unit test * user cannot add existing repo if suffix is '/' (#5571) * feat(helm/docs) fix broken swagger docs EE-1278 (#5572) * Fix swagger docs * minor correction * fix(helm): migrating code from user handler to helm handler (#5573) * - migrated user_helm_repos to helm endpoint handler - migrated api operations from user factory/service to helm factory/service - passing endpointId into helm service/factory as endpoint provider is deprecated * upgrade libhelm to hide secrets Co-authored-by: Matt Hook <hookenz@gmail.com> * removed duplicate file - due to merge conflict * dependency injection in helm factory Co-authored-by: Richard Wei <54336863+WaysonWei@users.noreply.github.com> Co-authored-by: Matt Hook <hookenz@gmail.com>
56 lines
1.6 KiB
Go
56 lines
1.6 KiB
Go
package helm
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/portainer/libhelm/options"
|
|
httperror "github.com/portainer/libhttp/error"
|
|
"github.com/portainer/libhttp/request"
|
|
"github.com/portainer/libhttp/response"
|
|
)
|
|
|
|
// @id HelmDelete
|
|
// @summary Delete Helm Chart(s)
|
|
// @description
|
|
// @description **Access policy**: authorized
|
|
// @tags helm_chart
|
|
// @security jwt
|
|
// @accept json
|
|
// @produce json
|
|
// @param release query string true "The name of the release/application to uninstall"
|
|
// @param namespace query string true "An optional namespace"
|
|
// @success 204 "Success"
|
|
// @failure 400 "Invalid endpoint id or bad request"
|
|
// @failure 401 "Unauthorized"
|
|
// @failure 404 "Endpoint or ServiceAccount not found"
|
|
// @failure 500 "Server error or helm error"
|
|
// @router /endpoints/:id/kubernetes/helm/{release} [delete]
|
|
func (handler *Handler) helmDelete(w http.ResponseWriter, r *http.Request) *httperror.HandlerError {
|
|
release, err := request.RetrieveRouteVariableValue(r, "release")
|
|
if err != nil {
|
|
return &httperror.HandlerError{http.StatusBadRequest, "No release specified", err}
|
|
}
|
|
|
|
clusterAccess, httperr := handler.getHelmClusterAccess(r)
|
|
if httperr != nil {
|
|
return httperr
|
|
}
|
|
|
|
uninstallOpts := options.UninstallOptions{
|
|
Name: release,
|
|
KubernetesClusterAccess: clusterAccess,
|
|
}
|
|
|
|
q := r.URL.Query()
|
|
if namespace := q.Get("namespace"); namespace != "" {
|
|
uninstallOpts.Namespace = namespace
|
|
}
|
|
|
|
err = handler.helmPackageManager.Uninstall(uninstallOpts)
|
|
if err != nil {
|
|
return &httperror.HandlerError{http.StatusInternalServerError, "Helm returned an error", err}
|
|
}
|
|
|
|
return response.Empty(w)
|
|
}
|