Allow uninstalling the chart (#8)

This commit is contained in:
Andrey Pokhilko
2022-09-09 14:50:50 +01:00
committed by GitHub
parent 91fd3793c7
commit fa48cf5435
4 changed files with 132 additions and 41 deletions

View File

@@ -59,6 +59,11 @@ func configureRoutes(abortWeb ControlChan, data *DataLayer, api *gin.Engine) {
abortWeb <- struct{}{}
})
configureHelms(api, data)
configureKubectls(api, data)
}
func configureHelms(api *gin.Engine, data *DataLayer) {
api.GET("/api/helm/charts", func(c *gin.Context) {
res, err := data.ListInstalled()
if err != nil {
@@ -68,6 +73,21 @@ func configureRoutes(abortWeb ControlChan, data *DataLayer, api *gin.Engine) {
c.IndentedJSON(http.StatusOK, res)
})
api.DELETE("/api/helm/charts", func(c *gin.Context) {
cName := c.Query("chart")
cNamespace := c.Query("namespace")
if cName == "" {
_ = c.AbortWithError(http.StatusBadRequest, errors.New("missing required query string parameter: chart"))
return
}
err := data.UninstallChart(cNamespace, cName)
if err != nil {
_ = c.AbortWithError(http.StatusInternalServerError, err)
return
}
c.Redirect(http.StatusFound, "/")
})
api.GET("/api/helm/charts/history", func(c *gin.Context) {
cName := c.Query("chart")
cNamespace := c.Query("namespace")
@@ -105,8 +125,6 @@ func configureRoutes(abortWeb ControlChan, data *DataLayer, api *gin.Engine) {
c.IndentedJSON(http.StatusOK, res)
})
configureKubectls(api, data)
sections := map[string]SectionFn{
"manifests": data.RevisionManifests,
"values": data.RevisionValues,