@@ -4,9 +4,10 @@ import (
44 "context"
55 "fmt"
66
7- "github.com/cluttrdev/gitlab-clickhouse-exporter/pkg/clickhouse"
87 gitlab "github.com/cluttrdev/gitlab-clickhouse-exporter/pkg/gitlab"
98 "github.com/cluttrdev/gitlab-clickhouse-exporter/pkg/models"
9+
10+ "github.com/cluttrdev/gitlab-clickhouse-exporter/internal/datastore"
1011)
1112
1213type ExportPipelineHierarchyOptions struct {
@@ -18,11 +19,11 @@ type ExportPipelineHierarchyOptions struct {
1819 ExportTraces bool
1920}
2021
21- func ExportPipelineHierarchy (ctx context.Context , opts ExportPipelineHierarchyOptions , gl * gitlab.Client , ch * clickhouse. Client ) error {
22- return <- exportPipelineHierarchy (ctx , opts , gl , ch )
22+ func ExportPipelineHierarchy (ctx context.Context , opts ExportPipelineHierarchyOptions , gl * gitlab.Client , ds datastore. DataStore ) error {
23+ return <- exportPipelineHierarchy (ctx , opts , gl , ds )
2324}
2425
25- func exportPipelineHierarchy (ctx context.Context , opts ExportPipelineHierarchyOptions , gl * gitlab.Client , ch * clickhouse. Client ) <- chan error {
26+ func exportPipelineHierarchy (ctx context.Context , opts ExportPipelineHierarchyOptions , gl * gitlab.Client , ds datastore. DataStore ) <- chan error {
2627 out := make (chan error )
2728
2829 go func () {
@@ -39,14 +40,14 @@ func exportPipelineHierarchy(ctx context.Context, opts ExportPipelineHierarchyOp
3940 }
4041 ph := phr .PipelineHierarchy
4142
42- if err := clickhouse .InsertPipelineHierarchy (ctx , ph , ch ); err != nil {
43+ if err := ds .InsertPipelineHierarchy (ctx , ph ); err != nil {
4344 out <- fmt .Errorf ("error inserting pipeline hierarchy: %w" , err )
4445 return
4546 }
4647
4748 if opts .ExportTraces {
4849 pts := ph .GetAllTraces ()
49- if err := clickhouse .InsertTraces (ctx , pts , ch ); err != nil {
50+ if err := ds .InsertTraces (ctx , pts ); err != nil {
5051 out <- fmt .Errorf ("error inserting traces: %w" , err )
5152 return
5253 }
@@ -66,15 +67,15 @@ func exportPipelineHierarchy(ctx context.Context, opts ExportPipelineHierarchyOp
6667 tcs = append (tcs , ts .TestCases ... )
6768 }
6869 }
69- if err = clickhouse .InsertTestReports (ctx , trs , ch ); err != nil {
70+ if err = ds .InsertTestReports (ctx , trs ); err != nil {
7071 out <- fmt .Errorf ("error inserting testreports: %w" , err )
7172 return
7273 }
73- if err = clickhouse .InsertTestSuites (ctx , tss , ch ); err != nil {
74+ if err = ds .InsertTestSuites (ctx , tss ); err != nil {
7475 out <- fmt .Errorf ("error inserting testsuites: %w" , err )
7576 return
7677 }
77- if err = clickhouse .InsertTestCases (ctx , tcs , ch ); err != nil {
78+ if err = ds .InsertTestCases (ctx , tcs ); err != nil {
7879 out <- fmt .Errorf ("error inserting testcases: %w" , err )
7980 return
8081 }
0 commit comments