diff --git a/sdk/builder.go b/sdk/builder.go new file mode 100644 index 0000000000..1494f8f496 --- /dev/null +++ b/sdk/builder.go @@ -0,0 +1,29 @@ +package sdk + +type Builder interface { + // Name is the name of the operator. + Name(name string) Builder + // CRDName is the full name of the Custom Resource Resource that the operator operates on. + CRDName(crdName string) Builder + // APIVersion is the version from the groupVersion. + APIVersion(apiVersion string) Builder + // Callbacks registers the callbacks which notifies the creation, update, and deletion of any Custom Resource. + Callbacks(callBacks CallBacks) Builder + // Build builds an operator instance. + Build() (Operator, error) +} + +type CallBacks interface { + // OnAdd notifies a creation of a Custom Resource. + OnAdd(obj interface{}) + // OnUpdate notifies a update of an existing Custom Resource. + OnUpdate(oldObj, newObj interface{}) + // OnDelete notifies a deletion of an existing Custom Resource. + OnDelete(obj interface{}) +} + +// NewOperatorBuilder creates a operator builder. +func NewOperatorBuilder() Builder { + // Implement me! + return nil +} diff --git a/sdk/operatorSDK.go b/sdk/operatorSDK.go new file mode 100644 index 0000000000..01d711cf4e --- /dev/null +++ b/sdk/operatorSDK.go @@ -0,0 +1,8 @@ +package sdk + +import "context" + +type Operator interface { + // Start starts the operator. + Start(Context context.Context) error +}