|
|
|
@ -75,11 +75,13 @@ type ForInput struct {
|
|
|
|
|
err error
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// For 方法监控的对象只能是一个
|
|
|
|
|
// For defines the type of Object being *reconciled*, and configures the ControllerManagedBy to respond to create / delete /
|
|
|
|
|
// update events by *reconciling the object*.
|
|
|
|
|
// This is the equivalent of calling
|
|
|
|
|
// Watches(&source.Kind{Type: apiType}, &handler.EnqueueRequestForObject{}).
|
|
|
|
|
func (blder *Builder) For(object client.Object, opts ...ForOption) *Builder {
|
|
|
|
|
// 如果已经存在就报错退出,完成了之间空一个对象的逻辑
|
|
|
|
|
if blder.forInput.object != nil {
|
|
|
|
|
blder.forInput.err = fmt.Errorf("For(...) should only be called once, could not assign multiple objects for reconciliation")
|
|
|
|
|
return blder
|
|
|
|
@ -173,6 +175,7 @@ func (blder *Builder) Complete(r reconcile.Reconciler) error {
|
|
|
|
|
|
|
|
|
|
// Build builds the Application Controller and returns the Controller it created.
|
|
|
|
|
func (blder *Builder) Build(r reconcile.Reconciler) (controller.Controller, error) {
|
|
|
|
|
// 异常检查,保证后续的执行不会产生空指针的 panic
|
|
|
|
|
if r == nil {
|
|
|
|
|
return nil, fmt.Errorf("must provide a non-nil Reconciler")
|
|
|
|
|
}
|
|
|
|
|