1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 15:59:41 +02:00

refactor(edge): init endpoint relation when endpoint is created [BE-11928] (#814)

This commit is contained in:
Oscar Zhou 2025-07-01 06:15:56 +12:00 committed by GitHub
parent b43f864511
commit b6f3682a62
10 changed files with 62 additions and 43 deletions

View file

@ -17,17 +17,7 @@ func (handler *Handler) updateEdgeRelations(tx dataservices.DataStoreTx, endpoin
relation, err := tx.EndpointRelation().EndpointRelation(endpoint.ID)
if err != nil {
if !tx.IsErrObjectNotFound(err) {
return errors.WithMessage(err, "Unable to retrieve environment relation inside the database")
}
relation = &portainer.EndpointRelation{
EndpointID: endpoint.ID,
EdgeStacks: map[portainer.EdgeStackID]bool{},
}
if err := tx.EndpointRelation().Create(relation); err != nil {
return errors.WithMessage(err, "Unable to create environment relation inside the database")
}
return errors.WithMessage(err, "Unable to retrieve environment relation inside the database")
}
endpointGroup, err := tx.EndpointGroup().Read(endpoint.GroupID)