-
Notifications
You must be signed in to change notification settings - Fork 7
/
store.go
47 lines (41 loc) · 870 Bytes
/
store.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package store
import (
"context"
"fmt"
"github.com/jackc/pgx/v4/pgxpool"
"github.com/jenkins-x/cd-indicators/store/migration"
)
type Store struct {
Pipelines *PipelineStore
PullRequests *PullRequestStore
Releases *ReleaseStore
Deployments *DeploymentStore
}
func New(ctx context.Context, connPool *pgxpool.Pool) (*Store, error) {
store := &Store{
Pipelines: &PipelineStore{
connPool: connPool,
},
PullRequests: &PullRequestStore{
connPool: connPool,
},
Releases: &ReleaseStore{
connPool: connPool,
},
Deployments: &DeploymentStore{
connPool: connPool,
},
}
err := (&migration.Migrator{
ConnPool: connPool,
}).Migrate(ctx,
store.Pipelines,
store.PullRequests,
store.Releases,
store.Deployments,
)
if err != nil {
return nil, fmt.Errorf("failed to run store migrations: %w", err)
}
return store, nil
}