-
Notifications
You must be signed in to change notification settings - Fork 1
/
definitions.go
56 lines (47 loc) · 1.45 KB
/
definitions.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
51
52
53
54
55
56
package definition
import (
"fmt"
"github.com/echocat/lingress/support"
"k8s.io/client-go/kubernetes"
"time"
)
type Definitions struct {
ServiceSecrets *ServiceSecret
Ingress *Ingress
Service *Service
}
func New(client kubernetes.Interface, resyncAfter time.Duration) (*Definitions, error) {
if serviceSecrets, err := NewServiceSecrets(client, resyncAfter); err != nil {
return nil, fmt.Errorf("cannot create service secrets definition store: %v", err)
} else if ingress, err := NewIngress(client, resyncAfter); err != nil {
return nil, fmt.Errorf("cannot create ingress definition store: %v", err)
} else if service, err := NewService(client, resyncAfter); err != nil {
return nil, fmt.Errorf("cannot create service definition store: %v", err)
} else {
return &Definitions{
ServiceSecrets: serviceSecrets,
Ingress: ingress,
Service: service,
}, nil
}
}
func (instance *Definitions) SetNamespace(namespace string) {
instance.ServiceSecrets.SetNamespace(namespace)
}
func (instance *Definitions) Init(stop support.Channel) error {
if err := instance.ServiceSecrets.Init(stop); err != nil {
return err
}
if err := instance.Service.Init(stop); err != nil {
return err
}
if err := instance.Ingress.Init(stop); err != nil {
return err
}
return nil
}
func (instance *Definitions) HasSynced() bool {
return instance.Ingress.HasSynced() &&
instance.Service.HasSynced() &&
instance.ServiceSecrets.HasSynced()
}