This repository has been archived by the owner on Jul 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 279
/
catalog.go
50 lines (42 loc) · 1.74 KB
/
catalog.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
48
49
50
package catalog
import (
"time"
"github.com/openservicemesh/osm/pkg/certificate"
"github.com/openservicemesh/osm/pkg/configurator"
"github.com/openservicemesh/osm/pkg/endpoint"
"github.com/openservicemesh/osm/pkg/k8s"
"github.com/openservicemesh/osm/pkg/messaging"
"github.com/openservicemesh/osm/pkg/policy"
"github.com/openservicemesh/osm/pkg/service"
"github.com/openservicemesh/osm/pkg/smi"
"github.com/openservicemesh/osm/pkg/ticker"
)
// NewMeshCatalog creates a new service catalog
func NewMeshCatalog(kubeController k8s.Controller, meshSpec smi.MeshSpec, certManager *certificate.Manager,
policyController policy.Controller, stop <-chan struct{},
cfg configurator.Configurator, serviceProviders []service.Provider, endpointsProviders []endpoint.Provider,
msgBroker *messaging.Broker) *MeshCatalog {
mc := &MeshCatalog{
serviceProviders: serviceProviders,
endpointsProviders: endpointsProviders,
meshSpec: meshSpec,
policyController: policyController,
configurator: cfg,
certManager: certManager,
kubeController: kubeController,
}
// Start the Resync ticker to tick based on the resync interval.
// Starting the resync ticker only starts the ticker config watcher which
// internally manages the lifecycle of the ticker routine.
resyncTicker := ticker.NewResyncTicker(msgBroker, 30*time.Second /* min resync interval */)
resyncTicker.Start(stop)
return mc
}
// GetKubeController returns the kube controller instance handling the current cluster
func (mc *MeshCatalog) GetKubeController() k8s.Controller {
return mc.kubeController
}
// GetTrustDomain returns the currently configured trust domain, ie: cluster.local
func (mc *MeshCatalog) GetTrustDomain() string {
return mc.certManager.GetTrustDomain()
}