This repository has been archived by the owner on Oct 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
initializers.go
47 lines (38 loc) · 1.24 KB
/
initializers.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 scribe
import (
"context"
"github.com/grafana/scribe/pipeline"
"github.com/grafana/scribe/pipeline/clients"
"github.com/grafana/scribe/pipeline/clients/cli"
"github.com/grafana/scribe/pipeline/clients/dagger"
"github.com/grafana/scribe/pipeline/clients/drone"
"github.com/grafana/scribe/pipeline/clients/graphviz"
)
var (
ClientCLI string = "cli"
ClientDrone = "drone"
ClientDagger = "dagger"
ClientGraphviz = "graphviz"
)
func NewDefaultCollection(opts clients.CommonOpts) *pipeline.Collection {
p := pipeline.NewCollection()
if err := p.AddPipelines(pipeline.New(opts.Name, DefaultPipelineID)); err != nil {
panic(err)
}
p.Root = []int64{DefaultPipelineID}
return p
}
func NewMultiCollection() *pipeline.Collection {
return pipeline.NewCollection()
}
type InitializerFunc func(context.Context, clients.CommonOpts) (pipeline.Client, error)
// The ClientInitializers define how different RunModes initialize the Scribe client
var ClientInitializers = map[string]InitializerFunc{
ClientCLI: cli.New,
ClientDrone: drone.New,
ClientDagger: dagger.New,
ClientGraphviz: graphviz.New,
}
func RegisterClient(name string, initializer InitializerFunc) {
ClientInitializers[name] = initializer
}