Files
kubevela/pkg/server/handler/appHandlers.go
Zheng Xi Zhou 4fea3e9cf9 Implement API trait attach/detach, application get, capability center add/sync/list and fix detach issue (#187)
* implemented trait attach, get application

* implemented API for trait detach and fix trait detach issue

* implemeted API add/sync/list capability center

* implemented API capability add/remove/list

* update test-cases according to new cli style

* merge two ginkgo describe to one as in github environment ginkgo does NOT follow the order of describes

* merge two ginkgo describe to one as in github environment ginkgo does NOT follow the order of describes
2020-08-25 10:14:18 +08:00

62 lines
1.5 KiB
Go

package handler
import (
"github.com/cloud-native-application/rudrx/pkg/server/util"
"sigs.k8s.io/controller-runtime/pkg/client"
"github.com/cloud-native-application/rudrx/pkg/oam"
"github.com/gin-gonic/gin"
)
const querymodeKey = "appQuerymode"
// Apps related handlers
func CreateApps(c *gin.Context) {
}
func UpdateApps(c *gin.Context) {
}
func GetApp(c *gin.Context) {
kubeClient := c.MustGet("KubeClient")
envName := c.Param("envName")
envMeta, err := oam.GetEnvByName(envName)
if err != nil {
util.HandleError(c, util.StatusInternalServerError, err)
return
}
namespace := envMeta.Namespace
appName := c.Param("appName")
ctx := util.GetContext(c)
applicationStatus, err := oam.RetrieveApplicationStatusByName(ctx, kubeClient.(client.Client), appName, namespace)
if err != nil {
util.HandleError(c, util.StatusInternalServerError, err)
return
}
util.AssembleResponse(c, applicationStatus, nil)
}
func ListApps(c *gin.Context) {
kubeClient := c.MustGet("KubeClient")
envName := c.Param("envName")
envMeta, err := oam.GetEnvByName(envName)
if err != nil {
util.HandleError(c, util.StatusInternalServerError, err)
return
}
namespace := envMeta.Namespace
ctx := util.GetContext(c)
applicationMetaList, err := oam.RetrieveApplicationsByName(ctx, kubeClient.(client.Client), "", namespace)
if err != nil {
util.HandleError(c, util.StatusInternalServerError, err.Error())
return
}
util.AssembleResponse(c, applicationMetaList, nil)
}
func DeleteApps(c *gin.Context) {
}