change env value max length

This commit is contained in:
barnettZQG 2021-03-30 11:15:56 +08:00
parent ae9b8106a7
commit 728f58e319
2 changed files with 4 additions and 1 deletions

View File

@ -364,7 +364,7 @@ type TenantServiceEnvVar struct {
ContainerPort int `gorm:"column:container_port" validate:"container_port|numeric_between:1,65535" json:"container_port"`
Name string `gorm:"column:name;size:1024" validate:"name" json:"name"`
AttrName string `gorm:"column:attr_name;size:1024" validate:"env_name|required" json:"attr_name"`
AttrValue string `gorm:"column:attr_value;size:2048" validate:"env_value|required" json:"attr_value"`
AttrValue string `gorm:"column:attr_value;type:text" validate:"env_value|required" json:"attr_value"`
IsChange bool `gorm:"column:is_change" validate:"is_change|bool" json:"is_change"`
Scope string `gorm:"column:scope;default:'outer'" validate:"scope|in:outer,inner,both" json:"scope"`
}

View File

@ -885,6 +885,9 @@ func (t *TenantServiceEnvVarDaoImpl) AddModel(mo model.Interface) error {
relation := mo.(*model.TenantServiceEnvVar)
var oldRelation model.TenantServiceEnvVar
if ok := t.DB.Where("service_id = ? and attr_name = ?", relation.ServiceID, relation.AttrName).Find(&oldRelation).RecordNotFound(); ok {
if len(relation.AttrValue) > 65532 {
relation.AttrValue = relation.AttrValue[:65532]
}
if err := t.DB.Create(relation).Error; err != nil {
return err
}