Add initial controller boilerplate and example controller

Signed-off-by: Monis Khan <mok@vmware.com>
This commit is contained in:
Monis Khan
2020-07-22 22:27:55 -04:00
parent 31c4e6560d
commit d4eeb74641
18 changed files with 1460 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
/*
Copyright 2020 VMware, Inc.
SPDX-License-Identifier: Apache-2.0
*/
package controller
import (
"context"
"k8s.io/client-go/tools/events"
)
var _ Syncer = SyncFunc(nil)
type Syncer interface {
Sync(ctx Context) error
}
type SyncFunc func(ctx Context) error
func (s SyncFunc) Sync(ctx Context) error {
return s(ctx)
}
type Context struct {
Context context.Context
Name string
Key Key
Queue Queue
Recorder events.EventRecorder
}
type Key struct {
Namespace string
Name string
// TODO determine if it makes sense to add a field like:
// Extra interface{}
// This would allow a custom ParentFunc to pass extra data through to the Syncer
// The boxed type would have to be comparable (i.e. usable as a map key)
}
type SyncWrapperFunc func(syncer Syncer) Syncer