Skip to content

Commit 53dbc15

Browse files
askyrieSongZhen0704
authored andcommitted
feat: vtap groups verify name
1 parent 73d11d3 commit 53dbc15

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

server/controller/http/service/vtap_group.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@ func (a *AgentGroup) Create(vtapGroupCreate model.VtapGroupCreate) (resp model.V
162162
}
163163
db := dbInfo.DB
164164

165+
var count int64
166+
db.Model(&metadbmodel.VTapGroup{}).Where("name = ?", vtapGroupCreate.Name).Count(&count)
167+
if count > 0 {
168+
return model.VtapGroup{}, response.ServiceError(
169+
httpcommon.RESOURCE_ALREADY_EXIST,
170+
fmt.Sprintf("vtap_group name (%s) already exist", vtapGroupCreate.Name))
171+
}
172+
165173
db.Model(&metadbmodel.VTapGroup{}).Count(&vtapGroupCount)
166174
if int(vtapGroupCount) > cfg.Spec.VTapGroupMax {
167175
return model.VtapGroup{}, response.ServiceError(

0 commit comments

Comments
 (0)