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

mindersec / minder / 12370272701

17 Dec 2024 09:38AM UTC coverage: 54.996% (-0.4%) from 55.364%
12370272701

push

github

web-flow
Revert "build(deps): bump gitlab.com/gitlab-org/api/client-go from 0.116.0 to 0.117.0" (#5212)

Revert "build(deps): bump gitlab.com/gitlab-org/api/client-go from 0.116.0 to…"

This reverts commit 24270ffb1.

16830 of 30602 relevant lines covered (55.0%)

38.01 hits per line

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

9.68
/internal/providers/github/properties/fetcher.go
1
// SPDX-FileCopyrightText: Copyright 2024 The Minder Authors
2
// SPDX-License-Identifier: Apache-2.0
3

4
// Package properties provides utility functions for fetching and managing properties
5
package properties
6

7
import (
8
        "context"
9

10
        go_github "github.com/google/go-github/v63/github"
11

12
        "github.com/mindersec/minder/internal/entities/properties"
13
        minderv1 "github.com/mindersec/minder/pkg/api/protobuf/go/minder/v1"
14
)
15

16
// GhPropertyWrapper is a function that fetches a property from the GitHub API
17
type GhPropertyWrapper func(
18
        ctx context.Context, ghCli *go_github.Client, isOrg bool, lookupProperties *properties.Properties,
19
) (map[string]any, error)
20

21
// GhPropertyFetcher is an interface for fetching properties from the GitHub API
22
type GhPropertyFetcher interface {
23
        ghPropertyFetcherBase
24
        GetName(props *properties.Properties) (string, error)
25
}
26

27
type ghPropertyFetcherBase interface {
28
        WrapperForProperty(propertyKey string) GhPropertyWrapper
29
        AllPropertyWrappers() []GhPropertyWrapper
30
        OperationalProperties() []string
31
}
32

33
// GhPropertyFetcherFactory is an interface for creating GhPropertyFetcher instances
34
type GhPropertyFetcherFactory interface {
35
        EntityPropertyFetcher(entType minderv1.Entity) GhPropertyFetcher
36
}
37

38
type ghEntityFetcher struct{}
39

40
// NewPropertyFetcherFactory creates a new GhPropertyFetcherFactory
41
func NewPropertyFetcherFactory() GhPropertyFetcherFactory {
48✔
42
        return ghEntityFetcher{}
48✔
43
}
48✔
44

45
// EntityPropertyFetcher returns a GhPropertyFetcher for the given entity type
46
func (_ ghEntityFetcher) EntityPropertyFetcher(entType minderv1.Entity) GhPropertyFetcher {
×
47
        // nolint:exhaustive
×
48
        switch entType {
×
49
        case minderv1.Entity_ENTITY_PULL_REQUESTS:
×
50
                return NewPullRequestFetcher()
×
51
        case minderv1.Entity_ENTITY_REPOSITORIES:
×
52
                return NewRepositoryFetcher()
×
53
        case minderv1.Entity_ENTITY_ARTIFACTS:
×
54
                return NewArtifactFetcher()
×
55
        case minderv1.Entity_ENTITY_RELEASE:
×
56
                return NewReleaseFetcher()
×
57
        }
58

59
        return nil
×
60
}
61

62
type propertyOrigin struct {
63
        keys    []string
64
        wrapper GhPropertyWrapper
65
}
66

67
type propertyFetcherBase struct {
68
        propertyOrigins       []propertyOrigin
69
        operationalProperties []string
70
}
71

72
var _ ghPropertyFetcherBase = propertyFetcherBase{}
73

74
// WrapperForProperty returns the property wrapper for the given property key
75
func (pfb propertyFetcherBase) WrapperForProperty(propertyKey string) GhPropertyWrapper {
×
76
        for _, po := range pfb.propertyOrigins {
×
77
                for _, k := range po.keys {
×
78
                        if k == propertyKey {
×
79
                                return po.wrapper
×
80
                        }
×
81
                }
82
        }
83

84
        return nil
×
85
}
86

87
// AllPropertyWrappers returns all property wrappers for the repository
88
func (pfb propertyFetcherBase) AllPropertyWrappers() []GhPropertyWrapper {
×
89
        wrappers := make([]GhPropertyWrapper, 0, len(pfb.propertyOrigins))
×
90
        for _, po := range pfb.propertyOrigins {
×
91
                wrappers = append(wrappers, po.wrapper)
×
92
        }
×
93
        return wrappers
×
94
}
95

96
// OperationalProperties returns the operational properties for the repository
97
func (pfb propertyFetcherBase) OperationalProperties() []string {
×
98
        return pfb.operationalProperties
×
99
}
×
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

© 2026 Coveralls, Inc