mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-27 16:17:34 +00:00
API request parameter check for trait attach
check parameter `staging` before converting it to bool and add logs
This commit is contained in:
+7
-5
@@ -240,18 +240,20 @@ func AttachTrait(c *gin.Context, body apis.TraitBody) (string, error) {
|
||||
for _, f := range body.Flags {
|
||||
fs.String(f.Name, f.Value, "")
|
||||
}
|
||||
staging, err := strconv.ParseBool(body.Staging)
|
||||
if err != nil {
|
||||
return "", err
|
||||
var staging = false
|
||||
var err error
|
||||
if body.Staging != "" {
|
||||
staging, err = strconv.ParseBool(body.Staging)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
traitAlias := body.Name
|
||||
template, err := plugins.GetInstalledCapabilityWithCapAlias(types.TypeTrait, traitAlias)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
appObj, err = AddOrUpdateTrait(body.EnvName, body.AppGroup, body.WorkloadName, fs, template)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/cloud-native-application/rudrx/pkg/server/apis"
|
||||
"github.com/cloud-native-application/rudrx/pkg/server/util"
|
||||
"github.com/gin-gonic/gin"
|
||||
ctrl "sigs.k8s.io/controller-runtime"
|
||||
)
|
||||
|
||||
// Trait related handlers
|
||||
@@ -19,6 +20,7 @@ func AttachTrait(c *gin.Context) {
|
||||
util.HandleError(c, util.InvalidArgument, "the trait attach request body is invalid")
|
||||
return
|
||||
}
|
||||
ctrl.Log.Info("request parameters body:", "body", body)
|
||||
msg, err := oam.AttachTrait(c, body)
|
||||
if err != nil {
|
||||
util.HandleError(c, util.StatusInternalServerError, err.Error())
|
||||
|
||||
Reference in New Issue
Block a user