-
Notifications
You must be signed in to change notification settings - Fork 26
/
eventing.go
47 lines (36 loc) · 1.32 KB
/
eventing.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 launch
import (
api_v1 "k8s.io/api/core/v1"
"k8s.io/client-go/tools/record"
"github.com/sapcc/kubernikus/pkg/apis/kubernikus/v1"
"github.com/sapcc/kubernikus/pkg/controller/events"
)
type EventingPoolManager struct {
PoolManager PoolManager
Kluster *v1.Kluster
Recorder record.EventRecorder
}
func (epm *EventingPoolManager) GetStatus() (status *PoolStatus, err error) {
return epm.PoolManager.GetStatus()
}
func (epm *EventingPoolManager) SetStatus(status *PoolStatus) (err error) {
return epm.PoolManager.SetStatus(status)
}
func (epm *EventingPoolManager) CreateNode() (id string, err error) {
id, err = epm.PoolManager.CreateNode()
if err == nil {
epm.Recorder.Eventf(epm.Kluster, api_v1.EventTypeNormal, events.SuccessfulCreateNode, "Successfully created node %v", id)
} else {
epm.Recorder.Eventf(epm.Kluster, api_v1.EventTypeWarning, events.FailedCreateNode, "Failed to created node: %v", err)
}
return id, err
}
func (epm *EventingPoolManager) DeleteNode(id string) (err error) {
err = epm.PoolManager.DeleteNode(id)
if err == nil {
epm.Recorder.Eventf(epm.Kluster, api_v1.EventTypeNormal, events.SuccessfulDeleteNode, "Successfully deleted node %v", id)
} else {
epm.Recorder.Eventf(epm.Kluster, api_v1.EventTypeWarning, events.FailedDeleteNode, "Failed to delete node: %v", err)
}
return
}