Skip to content
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

Format source code in go doc. #16

Merged
merged 2 commits into from
Jul 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions handler/enqueue_annotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,32 +48,30 @@ const (
// `TypeAnnotation` together uniquely identify an owner resource to reconcile.
//
// handler.EnqueueRequestForAnnotation can be used to trigger reconciliation of resources which are
// cross-referenced. This allows a namespace-scoped dependent to trigger reconciliation of an owner which
// is in a different namespace, and a cluster-scoped dependent can trigger the reconciliation of a
// namespace(scoped)-owner.
// cross-referenced. This allows a namespace-scoped dependent to trigger reconciliation of an owner
// which is in a different namespace, and a cluster-scoped dependent can trigger the reconciliation
// of a namespace(scoped)-owner.
//
// As an example, consider the case where we would like to watch clusterroles based on which we reconcile
// namespace-scoped replicasets. With native owner references, this would not be possible since the
// cluster-scoped dependent (clusterroles) is trying to specify a namespace-scoped owner (replicasets).
// Whereas in case of annotations-based handlers, we could implement the following:
//
// ...
// if err := c.Watch(&source.Kind{
// // Watch clusterroles
// Type: &rbacv1.ClusterRole{}},
// if err := c.Watch(&source.Kind{
// // Watch clusterroles
// Type: &rbacv1.ClusterRole{}},
//
// // Enqueue ReplicaSet reconcile requests using the namespacedName annotation value in the request.
// &handler.EnqueueRequestForAnnotation{schema.GroupKind{Group:"apps", Kind:"ReplicaSet"}}); err != nil {
// entryLog.Error(err, "unable to watch ClusterRole")
// os.Exit(1)
// }
// }
// ...
// // Enqueue ReplicaSet reconcile requests using the namespacedName annotation value in the request.
// &handler.EnqueueRequestForAnnotation{schema.GroupKind{Group:"apps", Kind:"ReplicaSet"}}); err != nil {
// entryLog.Error(err, "unable to watch ClusterRole")
// os.Exit(1)
// }
// }
//
// With this watch, the ReplicaSet reconciler would receive a request to reconcile
// "my-namespace/my-replicaset" based on a change to a ClusterRole that has the following annotations:
//
// annotations:
// annotations:
// operator-sdk/primary-resource:"my-namespace/my-replicaset"
// operator-sdk/primary-resource-type:"ReplicaSet.apps"
//
Expand Down
10 changes: 6 additions & 4 deletions handler/instrumented_enqueue_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ import (

// InstrumentedEnqueueRequestForObject wraps controller-runtime handler for
// "EnqueueRequestForObject", and sets up primary resource metrics on event
// handlers. The main objective of this handler is to set prometheues metrics
// when create/update/delete events occur. These metrics contain below
// handlers. The main objective of this handler is to set prometheus metrics
// when create/update/delete events occur. These metrics contain the following
// information on resource.
//
// resource_created_at_seconds{"name", "namespace", "group", "version", "kind"}
// resource_created_at_seconds{"name", "namespace", "group", "version", "kind"}
//
// '&handler.InstrumentedEnqueueRequestForObject{}' is used to call the handler.
// To call the handler use:
//
// &handler.InstrumentedEnqueueRequestForObject{}
type InstrumentedEnqueueRequestForObject struct {
handler.EnqueueRequestForObject
}
Expand Down