feat(crd): add update custom resource status
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
var managedJobs = map[types.UID]managed_job.ManagedJob{}
|
||||
|
||||
func Setup(client *api.Client, db *buntdb.DB) {
|
||||
func Setup(client *api.Client, db *buntdb.DB, crdInstance *crd.Crd) {
|
||||
ticker := time.NewTicker(5 * time.Second)
|
||||
quit := make(chan struct{})
|
||||
|
||||
@@ -20,7 +20,7 @@ func Setup(client *api.Client, db *buntdb.DB) {
|
||||
for {
|
||||
select {
|
||||
case <-ticker.C:
|
||||
cycle(client, db)
|
||||
cycle(client, db, crdInstance)
|
||||
case <-quit:
|
||||
ticker.Stop()
|
||||
return
|
||||
@@ -29,14 +29,14 @@ func Setup(client *api.Client, db *buntdb.DB) {
|
||||
}()
|
||||
}
|
||||
|
||||
func cycle(client *api.Client, db *buntdb.DB) {
|
||||
func cycle(client *api.Client, db *buntdb.DB, crdInstance *crd.Crd) {
|
||||
for _, uid := range crd.GetAllJobKeys() {
|
||||
def := crd.GetJob(uid)
|
||||
managedJob, ok := managedJobs[uid]
|
||||
if ok {
|
||||
managedJob.Update(def)
|
||||
} else {
|
||||
managedJob := managed_job.NewManagedJob(client, db, def)
|
||||
managedJob := managed_job.NewManagedJob(client, db, def, crdInstance)
|
||||
managedJobs[uid] = *managedJob
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user