Last active
May 6, 2021 20:56
-
-
Save epk/0784d0846aa9d748f7acb47a8008fe60 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package play | |
var _ = Buddy(&someBuddy{}) | |
type someBuddy struct{} | |
func (s *someBuddy) Name() string { | |
return "somebuddy" | |
} | |
func (s *someBuddy) Reconcilers() []Reconciler { | |
return nil | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package play | |
import ( | |
"context" | |
"sigs.k8s.io/controller-runtime/pkg/controller" | |
"sigs.k8s.io/controller-runtime/pkg/manager" | |
"sigs.k8s.io/controller-runtime/pkg/reconcile" | |
) | |
var _ = Reconciler(&reconciler1{}) | |
type reconciler1 struct { | |
something *somthingRunnable | |
} | |
func (r *reconciler1) SetupWithManager(context.Context, manager.Manager, controller.Options) error { | |
r.something = &somthingRunnable{} | |
return nil | |
} | |
func (r *reconciler1) Reconcile(context.Context, reconcile.Request) (reconcile.Result, error) { | |
return reconcile.Result{}, nil | |
} | |
func (r *reconciler1) Runnables() []Runnable { | |
return []Runnable{ | |
r.something, | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package play | |
import "context" | |
type somthingRunnable struct{} | |
func (s *somthingRunnable) Start(ctx context.Context) error { | |
s.Download(ctx) | |
// Block until done | |
<-ctx.Done() | |
s.Upload(context.Background()) | |
return nil | |
} | |
func (s *somthingRunnable) Upload(context.Context) error { | |
return nil | |
} | |
func (s *somthingRunnable) Download(context.Context) error { | |
return nil | |
} | |
func (s somthingRunnable) NeedLeaderElection() bool { | |
return true | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package play | |
import ( | |
"context" | |
"sigs.k8s.io/controller-runtime/pkg/controller" | |
"sigs.k8s.io/controller-runtime/pkg/manager" | |
"sigs.k8s.io/controller-runtime/pkg/reconcile" | |
) | |
type Buddy interface { | |
Name() string | |
Reconcilers() []Reconciler | |
} | |
type Reconciler interface { | |
reconcile.Reconciler | |
SetupWithManager(context.Context, manager.Manager, controller.Options) error | |
Runnables() []Runnable | |
} | |
type Runnable interface { | |
manager.LeaderElectionRunnable | |
manager.Runnable | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment