2023-02-14 18:18:07 +00:00
|
|
|
package edgegroup
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
2023-06-20 20:51:34 +00:00
|
|
|
portainer "github.com/portainer/portainer/api"
|
2023-06-22 21:28:07 +00:00
|
|
|
"github.com/portainer/portainer/api/dataservices"
|
2023-02-14 18:18:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type ServiceTx struct {
|
2023-06-22 21:28:07 +00:00
|
|
|
dataservices.BaseDataServiceTx[portainer.EdgeGroup, portainer.EdgeGroupID]
|
2023-02-14 18:18:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// UpdateEdgeGroupFunc is a no-op inside a transaction.
|
|
|
|
func (service ServiceTx) UpdateEdgeGroupFunc(ID portainer.EdgeGroupID, updateFunc func(edgeGroup *portainer.EdgeGroup)) error {
|
|
|
|
return errors.New("cannot be called inside a transaction")
|
|
|
|
}
|
|
|
|
|
|
|
|
func (service ServiceTx) Create(group *portainer.EdgeGroup) error {
|
2023-06-22 21:28:07 +00:00
|
|
|
return service.Tx.CreateObject(
|
2023-02-14 18:18:07 +00:00
|
|
|
BucketName,
|
|
|
|
func(id uint64) (int, interface{}) {
|
|
|
|
group.ID = portainer.EdgeGroupID(id)
|
|
|
|
return int(group.ID), group
|
|
|
|
},
|
|
|
|
)
|
|
|
|
}
|