Skip to content

Commit 6fc50a4

Browse files
[management] remove withContext from store methods (#4422)
1 parent 149559a commit 6fc50a4

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

management/server/store/sql_store.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ func (s *SqlStore) GetAccountByPeerPubKey(ctx context.Context, peerKey string) (
914914

915915
func (s *SqlStore) GetAnyAccountID(ctx context.Context) (string, error) {
916916
var account types.Account
917-
result := s.db.WithContext(ctx).Select("id").Order("created_at desc").Limit(1).Find(&account)
917+
result := s.db.Select("id").Order("created_at desc").Limit(1).Find(&account)
918918
if result.Error != nil {
919919
return "", status.NewGetAccountFromStoreError(result.Error)
920920
}
@@ -1399,7 +1399,7 @@ func (s *SqlStore) AddPeerToGroup(ctx context.Context, accountID, peerID, groupI
13991399
PeerID: peerID,
14001400
}
14011401

1402-
err := s.db.WithContext(ctx).Clauses(clause.OnConflict{
1402+
err := s.db.Clauses(clause.OnConflict{
14031403
Columns: []clause.Column{{Name: "group_id"}, {Name: "peer_id"}},
14041404
DoNothing: true,
14051405
}).Create(peer).Error
@@ -1414,7 +1414,7 @@ func (s *SqlStore) AddPeerToGroup(ctx context.Context, accountID, peerID, groupI
14141414

14151415
// RemovePeerFromGroup removes a peer from a group
14161416
func (s *SqlStore) RemovePeerFromGroup(ctx context.Context, peerID string, groupID string) error {
1417-
err := s.db.WithContext(ctx).
1417+
err := s.db.
14181418
Delete(&types.GroupPeer{}, "group_id = ? AND peer_id = ?", groupID, peerID).Error
14191419

14201420
if err != nil {
@@ -1427,7 +1427,7 @@ func (s *SqlStore) RemovePeerFromGroup(ctx context.Context, peerID string, group
14271427

14281428
// RemovePeerFromAllGroups removes a peer from all groups
14291429
func (s *SqlStore) RemovePeerFromAllGroups(ctx context.Context, peerID string) error {
1430-
err := s.db.WithContext(ctx).
1430+
err := s.db.
14311431
Delete(&types.GroupPeer{}, "peer_id = ?", peerID).Error
14321432

14331433
if err != nil {
@@ -2015,7 +2015,7 @@ func (s *SqlStore) SavePolicy(ctx context.Context, policy *types.Policy) error {
20152015
}
20162016

20172017
func (s *SqlStore) DeletePolicy(ctx context.Context, accountID, policyID string) error {
2018-
return s.db.WithContext(ctx).Transaction(func(tx *gorm.DB) error {
2018+
return s.db.Transaction(func(tx *gorm.DB) error {
20192019
if err := tx.Where("policy_id = ?", policyID).Delete(&types.PolicyRule{}).Error; err != nil {
20202020
return fmt.Errorf("delete policy rules: %w", err)
20212021
}
@@ -2706,7 +2706,7 @@ func (s *SqlStore) GetPeerByIP(ctx context.Context, lockStrength LockingStrength
27062706
}
27072707

27082708
func (s *SqlStore) GetPeerIdByLabel(ctx context.Context, lockStrength LockingStrength, accountID string, hostname string) (string, error) {
2709-
tx := s.db.WithContext(ctx)
2709+
tx := s.db
27102710
if lockStrength != LockingStrengthNone {
27112711
tx = tx.Clauses(clause.Locking{Strength: string(lockStrength)})
27122712
}

0 commit comments

Comments
 (0)