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

mindersec / minder / 13123580854

03 Feb 2025 09:54PM UTC coverage: 57.505% (-0.005%) from 57.51%
13123580854

push

github

web-flow
Expose data source list method to querier (#5400)

0 of 8 new or added lines in 1 file covered. (0.0%)

18140 of 31545 relevant lines covered (57.51%)

37.68 hits per line

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

0.0
/pkg/querier/datasource.go
1
// SPDX-FileCopyrightText: Copyright 2025 The Minder Authors
2
// SPDX-License-Identifier: Apache-2.0
3

4
// Package querier provides tools to interact with the Minder database
5
package querier
6

7
import (
8
        "context"
9

10
        "github.com/google/uuid"
11

12
        dsservice "github.com/mindersec/minder/internal/datasources/service"
13
        pb "github.com/mindersec/minder/pkg/api/protobuf/go/minder/v1"
14
)
15

16
// DataSourceHandlers interface provides functions to interact with data sources
17
type DataSourceHandlers interface {
18
        ListDataSourcesByProject(
19
                ctx context.Context,
20
                projectID uuid.UUID,
21
        ) ([]*pb.DataSource, error)
22
        CreateDataSource(
23
                ctx context.Context,
24
                projectID uuid.UUID,
25
                subscriptionID uuid.UUID,
26
                dataSource *pb.DataSource,
27
        ) (*pb.DataSource, error)
28
        GetDataSourceByName(
29
                ctx context.Context,
30
                projectID uuid.UUID,
31
                name string,
32
        ) (*pb.DataSource, error)
33
        UpdateDataSource(
34
                ctx context.Context,
35
                projectID uuid.UUID,
36
                subscriptionID uuid.UUID,
37
                dataSource *pb.DataSource,
38
        ) (*pb.DataSource, error)
39
        DeleteDataSource(
40
                ctx context.Context,
41
                projectID uuid.UUID,
42
                dataSourceID uuid.UUID,
43
        ) error
44
}
45

46
// ListDataSourcesByProject returns a list of data sources by project ID
NEW
47
func (q *querierType) ListDataSourcesByProject(ctx context.Context, projectID uuid.UUID) ([]*pb.DataSource, error) {
×
NEW
48
        if q.querier == nil {
×
NEW
49
                return nil, ErrQuerierMissing
×
NEW
50
        }
×
NEW
51
        if q.dataSourceSvc == nil {
×
NEW
52
                return nil, ErrDataSourceSvcMissing
×
NEW
53
        }
×
NEW
54
        return q.dataSourceSvc.List(ctx, projectID, dsservice.ReadBuilder().WithTransaction(q.querier))
×
55
}
56

57
// CreateDataSource creates a data source
58
func (q *querierType) CreateDataSource(
59
        ctx context.Context,
60
        projectID uuid.UUID,
61
        subscriptionID uuid.UUID,
62
        dataSource *pb.DataSource,
63
) (*pb.DataSource, error) {
×
64
        if q.querier == nil {
×
65
                return nil, ErrQuerierMissing
×
66
        }
×
67
        if q.dataSourceSvc == nil {
×
68
                return nil, ErrDataSourceSvcMissing
×
69
        }
×
70
        return q.dataSourceSvc.Create(ctx, projectID, subscriptionID, dataSource, dsservice.OptionsBuilder().WithTransaction(q.querier))
×
71
}
72

73
// UpdateDataSource updates a data source
74
func (q *querierType) UpdateDataSource(
75
        ctx context.Context,
76
        projectID uuid.UUID,
77
        subscriptionID uuid.UUID,
78
        dataSource *pb.DataSource,
79
) (*pb.DataSource, error) {
×
80
        if q.querier == nil {
×
81
                return nil, ErrQuerierMissing
×
82
        }
×
83
        if q.dataSourceSvc == nil {
×
84
                return nil, ErrDataSourceSvcMissing
×
85
        }
×
86
        return q.dataSourceSvc.Update(ctx, projectID, subscriptionID, dataSource, dsservice.OptionsBuilder().WithTransaction(q.querier))
×
87
}
88

89
// GetDataSourceByName returns a data source by name and project IDs
90
func (q *querierType) GetDataSourceByName(ctx context.Context, projectID uuid.UUID, name string) (*pb.DataSource, error) {
×
91
        if q.querier == nil {
×
92
                return nil, ErrQuerierMissing
×
93
        }
×
94
        if q.dataSourceSvc == nil {
×
95
                return nil, ErrDataSourceSvcMissing
×
96
        }
×
97
        return q.dataSourceSvc.GetByName(ctx, name, projectID, dsservice.ReadBuilder().WithTransaction(q.querier))
×
98
}
99

100
// DeleteDataSource deletes a data source
101
func (q *querierType) DeleteDataSource(ctx context.Context, projectID uuid.UUID, dataSourceID uuid.UUID) error {
×
102
        if q.querier == nil {
×
103
                return ErrQuerierMissing
×
104
        }
×
105
        if q.dataSourceSvc == nil {
×
106
                return ErrDataSourceSvcMissing
×
107
        }
×
108
        return q.dataSourceSvc.Delete(ctx, projectID, dataSourceID, dsservice.OptionsBuilder().WithTransaction(q.querier))
×
109
}
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