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

mindersec / minder / 18553979900

16 Oct 2025 07:39AM UTC coverage: 57.814% (+0.3%) from 57.553%
18553979900

Pull #5899

github

web-flow
Merge 20bdbbb89 into f6fa9e20a
Pull Request #5899: Add Provider authentication for DataSources

111 of 160 new or added lines in 8 files covered. (69.38%)

1 existing line in 1 file now uncovered.

18837 of 32582 relevant lines covered (57.81%)

37.07 hits per line

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

42.11
/internal/datasources/service/options.go
1
// SPDX-FileCopyrightText: Copyright 2024 The Minder Authors
2
// SPDX-License-Identifier: Apache-2.0
3

4
package service
5

6
import (
7
        "github.com/google/uuid"
8

9
        "github.com/mindersec/minder/internal/db"
10
        provinfv1 "github.com/mindersec/minder/pkg/providers/v1"
11
)
12

13
// Options is a struct that contains the options for a service call
14
type Options struct {
15
        qtx      db.ExtendQuerier
16
        provider provinfv1.Provider
17
}
18

19
// OptionsBuilder is a function that returns a new Options struct
20
func OptionsBuilder() *Options {
3✔
21
        return &Options{}
3✔
22
}
3✔
23

24
// WithTransaction is a function that sets the transaction field in the Options struct
25
func (o *Options) WithTransaction(qtx db.ExtendQuerier) *Options {
3✔
26
        if o == nil {
3✔
NEW
27
                o = &Options{}
×
28
        }
×
29
        o.qtx = qtx
3✔
30
        return o
3✔
31
}
32

33
// WithProvider is a function that sets the provider field in the Options struct
NEW
34
func (o *Options) WithProvider(provider provinfv1.Provider) *Options {
×
NEW
35
        if o == nil {
×
NEW
36
                o = &Options{}
×
NEW
37
        }
×
NEW
38
        o.provider = provider
×
NEW
39
        return o
×
40
}
41

42
func (o *Options) getTransaction() db.ExtendQuerier {
×
43
        if o == nil {
×
44
                return nil
×
45
        }
×
46
        return o.qtx
×
47
}
48

49
func (o *Options) getProvider() provinfv1.Provider {
1✔
50
        if o == nil {
1✔
NEW
51
                return nil
×
NEW
52
        }
×
53
        return o.provider
1✔
54
}
55

56
type txGetter interface {
57
        getTransaction() db.ExtendQuerier
58
}
59

60
// ReadOptions is a struct that contains the options for a read service call
61
// This extends the Options struct and adds a hierarchical field.
62
type ReadOptions struct {
63
        Options
64
        hierarchical bool
65

66
        // Use the actual project hierarchy to search for the data source.
67
        hierarchy []uuid.UUID
68
}
69

70
// ReadBuilder is a function that returns a new ReadOptions struct
71
func ReadBuilder() *ReadOptions {
17✔
72
        return &ReadOptions{}
17✔
73
}
17✔
74

75
// Hierarchical allows the service to search in the project hierarchy
76
func (o *ReadOptions) Hierarchical() *ReadOptions {
×
77
        if o == nil {
×
NEW
78
                o = &ReadOptions{}
×
79
        }
×
80
        o.hierarchical = true
×
81
        return o
×
82
}
83

84
// WithTransaction is a function that sets the transaction field in the Options struct
85
func (o *ReadOptions) WithTransaction(qtx db.ExtendQuerier) *ReadOptions {
17✔
86
        if o == nil {
17✔
NEW
87
                o = &ReadOptions{}
×
88
        }
×
89
        o.qtx = qtx
17✔
90
        return o
17✔
91
}
92

93
// WithProvider is a function that sets the provider field in the ReadOptions struct
NEW
94
func (o *ReadOptions) WithProvider(provider provinfv1.Provider) *ReadOptions {
×
NEW
95
        if o == nil {
×
NEW
96
                o = &ReadOptions{}
×
NEW
97
        }
×
NEW
98
        o.provider = provider
×
NEW
99
        return o
×
100
}
101

102
// withHierarchy allows the service to search in the project hierarchy.
103
// This is left internal for now to disallow external use.
104
func (o *ReadOptions) withHierarchy(projs []uuid.UUID) *ReadOptions {
4✔
105
        if o == nil {
4✔
NEW
106
                o = &ReadOptions{}
×
107
        }
×
108
        o.hierarchy = projs
4✔
109
        return o
4✔
110
}
111

112
func (o *ReadOptions) canSearchHierarchical() bool {
22✔
113
        if o == nil {
22✔
114
                return false
×
115
        }
×
116
        return o.hierarchical
22✔
117
}
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