-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Refactor packages to a more flattened structure #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
028c5fd
move source, event, eventhandler, predicate, reconcile packages under…
pwittrock 9f66295
Move required arguments for controller and manager creation as params…
pwittrock dee0a9c
namename ontroller_suite_test.go
pwittrock 0c4676b
split manager into its own package
pwittrock 440e011
Drop "Source" and "Handler" from source and handler implementations.
pwittrock cccff91
Fix lint errors
pwittrock f622cca
Lazily create caches if they aren't present
pwittrock 726fd0a
fix lint errors
pwittrock 183f5bc
Verify informers have started before waiting to sync.
pwittrock File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,55 +22,50 @@ import ( | |
"log" | ||
|
||
"github.com/kubernetes-sigs/controller-runtime/pkg/client" | ||
"github.com/kubernetes-sigs/controller-runtime/pkg/client/config" | ||
"github.com/kubernetes-sigs/controller-runtime/pkg/controller" | ||
"github.com/kubernetes-sigs/controller-runtime/pkg/controller/eventhandler" | ||
"github.com/kubernetes-sigs/controller-runtime/pkg/controller/reconcile" | ||
"github.com/kubernetes-sigs/controller-runtime/pkg/controller/source" | ||
"github.com/kubernetes-sigs/controller-runtime/pkg/handler" | ||
"github.com/kubernetes-sigs/controller-runtime/pkg/manager" | ||
"github.com/kubernetes-sigs/controller-runtime/pkg/reconcile" | ||
logf "github.com/kubernetes-sigs/controller-runtime/pkg/runtime/log" | ||
"github.com/kubernetes-sigs/controller-runtime/pkg/runtime/signals" | ||
"github.com/kubernetes-sigs/controller-runtime/pkg/source" | ||
appsv1 "k8s.io/api/apps/v1" | ||
corev1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/api/errors" | ||
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp" | ||
) | ||
|
||
func main() { | ||
flag.Parse() | ||
logf.SetLogger(logf.ZapLogger(false)) | ||
|
||
// Setup a Manager | ||
manager, err := controller.NewManager(controller.ManagerArgs{}) | ||
mrg, err := manager.New(config.GetConfigOrDie(), manager.Options{}) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
// Setup a new controller to Reconcile ReplicaSets | ||
c, err := manager.NewController( | ||
controller.Options{Name: "foo-controller", MaxConcurrentReconciles: 1}, | ||
&reconcileReplicaSet{client: manager.GetClient()}, | ||
) | ||
c, err := controller.New("foo-controller", mrg, controller.Options{ | ||
Reconcile: &reconcileReplicaSet{client: mrg.GetClient()}, | ||
}) | ||
if err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
err = c.Watch( | ||
// Watch ReplicaSets | ||
&source.KindSource{Type: &appsv1.ReplicaSet{}}, | ||
// Enqueue ReplicaSet object key | ||
&eventhandler.EnqueueHandler{}) | ||
if err != nil { | ||
// Watch ReplicaSets and enqueue ReplicaSet object key | ||
if err := c.Watch(&source.Kind{Type: &appsv1.ReplicaSet{}}, &handler.Enqueue{}); err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
err = c.Watch( | ||
// Watch Pods | ||
&source.KindSource{Type: &corev1.Pod{}}, | ||
// Enqueue Owning ReplicaSet object key | ||
&eventhandler.EnqueueOwnerHandler{OwnerType: &appsv1.ReplicaSet{}, IsController: true}) | ||
if err != nil { | ||
// Watch Pods and enqueue owning ReplicaSet key | ||
if err := c.Watch(&source.Kind{Type: &corev1.Pod{}}, | ||
&handler.EnqueueOwner{OwnerType: &appsv1.ReplicaSet{}, IsController: true}); err != nil { | ||
log.Fatal(err) | ||
} | ||
|
||
log.Fatal(manager.Start(signals.SetupSignalHandler())) | ||
log.Fatal(mrg.Start(signals.SetupSignalHandler())) | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks good from end-user's perspective. |
||
// reconcileReplicaSet reconciles ReplicaSets | ||
|
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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: mrg --> mgr