/
reconciliationentity.go
54 lines (45 loc) · 1.52 KB
/
reconciliationentity.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
package model
import (
"fmt"
"time"
"github.com/kyma-incubator/reconciler/pkg/db"
)
const tblReconciliation string = "scheduler_reconciliations"
type ReconciliationEntity struct {
Lock string `db:"notNull"`
RuntimeID string `db:"notNull"`
ClusterConfig int64 `db:"notNull"`
ClusterConfigStatus int64 `db:"notNull"`
Finished bool `db:"notNull"`
SchedulingID string `db:"notNull"`
Created time.Time `db:"readOnly"`
Updated time.Time `db:""`
Status Status `db:"notNull"`
}
func (r *ReconciliationEntity) String() string {
return fmt.Sprintf("ReconciliationEntity [Cluster=%s,ClusterConfigVersion=%d,SchedulingID=%s]",
r.RuntimeID, r.ClusterConfig, r.SchedulingID)
}
func (*ReconciliationEntity) New() db.DatabaseEntity {
return &ReconciliationEntity{}
}
func (r *ReconciliationEntity) Marshaller() *db.EntityMarshaller {
marshaller := db.NewEntityMarshaller(&r)
marshaller.AddUnmarshaller("Created", convertTimestampToTime)
marshaller.AddUnmarshaller("Updated", convertTimestampToTime)
marshaller.AddUnmarshaller("Status", convertStringToStatus)
return marshaller
}
func (*ReconciliationEntity) Table() string {
return tblReconciliation
}
func (r *ReconciliationEntity) Equal(other db.DatabaseEntity) bool {
if other == nil {
return false
}
otherOpProp, ok := other.(*ReconciliationEntity)
if !ok {
return false
}
return r.RuntimeID == otherOpProp.RuntimeID && r.SchedulingID == otherOpProp.SchedulingID
}