forked from opskumu/helm-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
router.go
79 lines (69 loc) · 1.71 KB
/
router.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package main
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/golang/glog"
)
type respBody struct {
Code int `json:"code"` // 0 or 1, 0 is ok, 1 is error
Data interface{} `json:"data,omitempty"`
Error string `json:"error,omitempty"`
}
func respErr(c *gin.Context, err error) {
glog.Warningln(err)
c.JSON(http.StatusOK, &respBody{
Code: 1,
Error: err.Error(),
})
}
func respOK(c *gin.Context, data interface{}) {
c.JSON(http.StatusOK, &respBody{
Code: 0,
Data: data,
})
}
func RegisterRouter(router *gin.Engine) {
// helm env
envs := router.Group("/api/envs")
{
envs.GET("", getHelmEnvs)
}
// helm repo
repositories := router.Group("/api/repositories")
{
// helm search repo
repositories.GET("/charts", listRepoCharts)
// helm repo update
repositories.PUT("", updateRepositories)
}
// helm chart
charts := router.Group("/api/charts")
{
// helm show
charts.GET("", showChartInfo)
// upload chart
charts.POST("/upload", uploadChart)
// list uploaded charts
charts.GET("/upload", listUploadedCharts)
}
// helm release
releases := router.Group("/api/namespaces/:namespace/releases")
{
// helm list releases -> helm list
releases.GET("", listReleases)
// helm get
releases.GET("/:release", showReleaseInfo)
// helm install
releases.POST("/:release", installRelease)
// helm upgrade
releases.PUT("/:release", upgradeRelease)
// helm uninstall
releases.DELETE("/:release", uninstallRelease)
// helm rollback
releases.PUT("/:release/versions/:reversion", rollbackRelease)
// helm status <RELEASE_NAME>
releases.GET("/:release/status", getReleaseStatus)
// helm release history
releases.GET("/:release/histories", listReleaseHistories)
}
}