-
Notifications
You must be signed in to change notification settings - Fork 4.8k
/
sourcer.go
36 lines (30 loc) · 1.02 KB
/
sourcer.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
package source
import (
"github.com/goharbor/harbor/src/replication"
"github.com/goharbor/harbor/src/replication/registry"
)
// Sourcer is used to manage and/or handle all the artifacts and information related with source registry.
// All the things with replication source should be covered in this object.
type Sourcer struct {
// Keep the adaptors we support now
adaptors map[string]registry.Adaptor
}
// NewSourcer is the constructor of Sourcer
func NewSourcer() *Sourcer {
return &Sourcer{
adaptors: make(map[string]registry.Adaptor),
}
}
// Init will do some initialization work like registrying all the adaptors we support
func (sc *Sourcer) Init() {
// Register Harbor adaptor
sc.adaptors[replication.AdaptorKindHarbor] = ®istry.HarborAdaptor{}
}
// GetAdaptor returns the required adaptor with the specified kind.
// If no adaptor with the specified kind existing, nil will be returned.
func (sc *Sourcer) GetAdaptor(kind string) registry.Adaptor {
if len(kind) == 0 {
return nil
}
return sc.adaptors[kind]
}