• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

trento-project / agent / 30531395988

30 Jul 2026 09:36AM UTC coverage: 76.134% (-0.005%) from 76.139%
30531395988

push

github

web-flow
Fix linter issues in pkg files (#628)

Signed-off-by: Antonio Gamez Diaz <antonio.gamez@suse.com>

44 of 54 new or added lines in 7 files covered. (81.48%)

203 existing lines in 21 files now uncovered.

7401 of 9721 relevant lines covered (76.13%)

16.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.71
/pkg/factsengine/plugininterface/rpc.go
1
// SPDX-FileCopyrightText: SUSE LLC
2
// SPDX-License-Identifier: Apache-2.0
3

4
package plugininterface
5

6
import (
7
        "context"
8
        "log/slog"
9
        "net/rpc"
10
        "sync"
11

12
        "github.com/google/uuid"
13
        "github.com/trento-project/agent/v3/pkg/factsengine/entities"
14
)
15

16
type GathererRPC struct{ client *rpc.Client }
17

18
func (g *GathererRPC) RequestGathering(
19
        ctx context.Context,
20
        factsRequest []entities.FactRequest,
21
) ([]entities.Fact, error) {
1✔
22
        var (
1✔
23
                resp []entities.Fact
1✔
24
                err  error
1✔
25
        )
1✔
26

1✔
27
        requestID := uuid.New().String()
1✔
28
        args := GatheringArgs{
1✔
29
                FactRequests: factsRequest,
1✔
30
                RequestID:    requestID,
1✔
31
        }
1✔
32

1✔
33
        gathering := make(chan error, 1)
1✔
34

1✔
35
        go func() {
2✔
36
                gathering <- g.client.Call("Plugin.ServeGathering", args, &resp)
1✔
37
        }()
1✔
38

39
        select {
1✔
40
        case <-ctx.Done():
1✔
41
                err = g.client.Call("Plugin.Cancel", requestID, &resp)
1✔
42

1✔
43
                return []entities.Fact{}, err
1✔
44
        case err = <-gathering:
×
45
                if err != nil {
×
46
                        return nil, err
×
47
                }
×
48

UNCOV
49
                return resp, nil
×
50
        }
51
}
52

53
type GathererRPCServer struct {
54
        Impl      Gatherer
55
        cancelMap map[string]context.CancelFunc
56
        mu        sync.Mutex
57
}
58

59
type GatheringArgs struct {
60
        FactRequests []entities.FactRequest
61
        RequestID    string
62
}
63

64
func (s *GathererRPCServer) ServeGathering(args GatheringArgs, resp *[]entities.Fact) error {
51✔
65
        ctx, cancel := context.WithCancel(context.Background())
51✔
66
        defer cancel()
51✔
67

51✔
68
        s.mu.Lock()
51✔
69
        if s.cancelMap == nil {
53✔
70
                s.cancelMap = make(map[string]context.CancelFunc)
2✔
71
        }
2✔
72

73
        s.cancelMap[args.RequestID] = cancel
51✔
74
        s.mu.Unlock()
51✔
75

51✔
76
        defer func() {
102✔
77
                s.mu.Lock()
51✔
78
                delete(s.cancelMap, args.RequestID)
51✔
79
                s.mu.Unlock()
51✔
80
        }()
51✔
81

82
        var err error
51✔
83

51✔
84
        *resp, err = s.Impl.Gather(ctx, args.FactRequests)
51✔
85

51✔
86
        return err
51✔
87
}
88

89
func (s *GathererRPCServer) Cancel(requestID string, _ *[]entities.Fact) (_ error) {
51✔
90
        s.mu.Lock()
51✔
91
        cancel, ok := s.cancelMap[requestID]
51✔
92
        if ok {
102✔
93
                delete(s.cancelMap, requestID)
51✔
94
        }
51✔
95
        s.mu.Unlock()
51✔
96

51✔
97
        if ok {
102✔
98
                cancel()
51✔
99
        } else {
51✔
100
                slog.Warn("Cannot find cancel function for request", "requestID", requestID)
×
101
        }
×
102

103
        return nil
51✔
104
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc