Skip to content

Commit

Permalink
feat: 本地应用同步增加校验 (1Panel-dev#4071)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengkunwang223 authored Mar 5, 2024
1 parent 71ca801 commit ca3be03
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions backend/app/service/app_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,34 @@ func handleLocalAppDetail(versionDir string, appDetail *model.AppDetail) error {
return buserr.WithName(constant.ErrAppParamKey, formField.EnvKey)
}
}

var dataMap map[string]interface{}
err = yaml.Unmarshal(paramByte, &dataMap)
if err != nil {
return buserr.WithMap(constant.ErrFileParseApp, map[string]interface{}{"name": "data.yml", "err": err.Error()}, err)
}

additionalProperties, ok := dataMap["additionalProperties"].(map[string]interface{})
if !ok {
return buserr.WithName(constant.ErrAppParamKey, "additionalProperties")
}

formFieldsInterface, ok := additionalProperties["formFields"]
if ok {
formFields, ok := formFieldsInterface.([]interface{})
if !ok {
return buserr.WithName(constant.ErrAppParamKey, "formFields")
}
for _, item := range formFields {
field := item.(map[string]interface{})
for key, value := range field {
if value == nil {
return buserr.WithName(constant.ErrAppParamKey, key)
}
}
}
}

appDetail.Params = string(dataJson)
return nil
}
Expand Down

0 comments on commit ca3be03

Please sign in to comment.