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

mindersec / minder / 14376078638

10 Apr 2025 08:39AM UTC coverage: 56.857%. First build
14376078638

Pull #5515

github

web-flow
Merge ea220ae51 into 0f5ecd80e
Pull Request #5515: Don't return errors when getting properties

27 of 49 new or added lines in 22 files covered. (55.1%)

18305 of 32195 relevant lines covered (56.86%)

37.04 hits per line

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

0.0
/internal/providers/gitlab/manager/webhook_handlers_repos.go
1
// SPDX-FileCopyrightText: Copyright 2024 The Minder Authors
2
// SPDX-License-Identifier: Apache-2.0
3

4
package manager
5

6
import (
7
        "fmt"
8
        "net/http"
9

10
        "github.com/ThreeDotsLabs/watermill/message"
11
        "github.com/google/uuid"
12
        "github.com/rs/zerolog"
13
        gitlablib "gitlab.com/gitlab-org/api/client-go"
14

15
        entmsg "github.com/mindersec/minder/internal/entities/handlers/message"
16
        "github.com/mindersec/minder/internal/providers/gitlab"
17
        minderv1 "github.com/mindersec/minder/pkg/api/protobuf/go/minder/v1"
18
        "github.com/mindersec/minder/pkg/entities/properties"
19
        "github.com/mindersec/minder/pkg/eventer/constants"
20
)
21

22
func (m *providerClassManager) handleRepoPush(l zerolog.Logger, r *http.Request) error {
×
23
        l.Debug().Msg("handling push event")
×
24

×
25
        pushEvent := gitlablib.PushEvent{}
×
26
        if err := decodeJSONSafe(r.Body, &pushEvent); err != nil {
×
27
                l.Error().Err(err).Msg("error decoding push event")
×
28
                return fmt.Errorf("error decoding push event: %w", err)
×
29
        }
×
30

31
        rawID := pushEvent.ProjectID
×
32
        if rawID == 0 {
×
33
                l.Error().Msg("push event missing project ID")
×
34
                return fmt.Errorf("push event missing project ID")
×
35
        }
×
36

37
        return m.publishRefreshAndEvalForGitlabProject(l, rawID)
×
38
}
39

40
func (m *providerClassManager) handleTagPush(l zerolog.Logger, r *http.Request) error {
×
41
        l.Debug().Msg("handling tag push event")
×
42

×
43
        tagPushEvent := gitlablib.TagEvent{}
×
44
        if err := decodeJSONSafe(r.Body, &tagPushEvent); err != nil {
×
45
                l.Error().Err(err).Msg("error decoding tag push event")
×
46
                return fmt.Errorf("error decoding tag push event: %w", err)
×
47
        }
×
48

49
        rawID := tagPushEvent.ProjectID
×
50
        if rawID == 0 {
×
51
                l.Error().Msg("tag push event missing project ID")
×
52
                return fmt.Errorf("tag push event missing project ID")
×
53
        }
×
54

55
        return m.publishRefreshAndEvalForGitlabProject(l, rawID)
×
56
}
57

58
func (m *providerClassManager) publishRefreshAndEvalForGitlabProject(
59
        l zerolog.Logger, rawProjectID int) error {
×
60
        upstreamID := gitlab.FormatRepositoryUpstreamID(rawProjectID)
×
61

×
62
        // Form identifying properties
×
NEW
63
        identifyingProps := properties.NewProperties(map[string]any{
×
64
                properties.PropertyUpstreamID: upstreamID,
×
65
        })
×
66

×
67
        // Form message to publish
×
68
        outm := entmsg.NewEntityRefreshAndDoMessage()
×
69
        outm.WithEntity(minderv1.Entity_ENTITY_REPOSITORIES, identifyingProps)
×
70
        outm.WithProviderClassHint(gitlab.Class)
×
71

×
72
        // Convert message for publishing
×
73
        msgID := uuid.New().String()
×
74
        msg := message.NewMessage(msgID, nil)
×
75
        if err := outm.ToMessage(msg); err != nil {
×
76
                l.Error().Err(err).Msg("error converting message to protobuf")
×
77
                return fmt.Errorf("error converting message to protobuf: %w", err)
×
78
        }
×
79

80
        // Publish message
81
        l.Debug().Str("msg_id", msgID).Msg("publishing refresh and eval message")
×
82
        if err := m.pub.Publish(constants.TopicQueueRefreshEntityAndEvaluate, msg); err != nil {
×
83
                l.Error().Err(err).Msg("error publishing refresh and eval message")
×
84
                return fmt.Errorf("error publishing refresh and eval message: %w", err)
×
85
        }
×
86

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

© 2025 Coveralls, Inc