Skip to content

Commit 31bfca0

Browse files
authored
Avoid the stuttering; Group tests by methods (#13)
* Reformat the comments to avoid lines wrapping in smaller terminals * Avoid the stuttering; Group tests by methods
1 parent 9db1e01 commit 31bfca0

File tree

2 files changed

+199
-204
lines changed

2 files changed

+199
-204
lines changed

handler/enqueue_annotation.go

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ import (
3232
var log = logf.Log.WithName("event_handler")
3333

3434
const (
35-
// NamespacedNameAnnotation is an annotation whose value encodes the name and namespace of a resource to reconcile
36-
// when a resource containing this annotation changes. Valid values are of the form `<namespace>/<name>` for
37-
// namespace-scoped owners and `<name>` for cluster-scoped owners.
35+
// NamespacedNameAnnotation is an annotation whose value encodes the name and namespace of a resource to
36+
// reconcile when a resource containing this annotation changes. Valid values are of the form
37+
// `<namespace>/<name>` for namespace-scoped owners and `<name>` for cluster-scoped owners.
3838
NamespacedNameAnnotation = "operator-sdk/primary-resource"
3939
// TypeAnnotation is an annotation whose value encodes the group and kind of a resource to reconcil when a
4040
// resource containing this annotation changes. Valid values are of the form `<Kind>` for resource in the
@@ -44,16 +44,19 @@ const (
4444

4545
// EnqueueRequestForAnnotation enqueues Request containing the Name and Namespace specified in the
4646
// annotations of the object that is the source of the Event. The source of the event triggers reconciliation
47-
// of the parent resource which is identified by annotations. `NamespacedNameAnnotation` and `TypeAnnotation` together uniquely
48-
// identify an owner resource to reconcile.
49-
// handler.EnqueueRequestForAnnotation can be used to trigger reconciliation of resources which are cross-referenced.
50-
// This allows a namespace-scoped dependent to trigger reconciliation of an owner which is in a different namespace, and
51-
// a cluster-scoped dependent can trigger the reconciliation of a namespace(scoped)-owner.
52-
53-
// As an example, consider the case where we would like to watch clusterroles based on which we reconcile namespace-scoped replicasets.
54-
// With native owner references, this would not be possible since the cluster-scoped dependent (clusterroles) is trying to
55-
// specify a namespace-scoped owner (replicasets). Whereas in case of annotations-based handlers, we could implement the following:
56-
47+
// of the parent resource which is identified by annotations. `NamespacedNameAnnotation` and
48+
// `TypeAnnotation` together uniquely identify an owner resource to reconcile.
49+
//
50+
// handler.EnqueueRequestForAnnotation can be used to trigger reconciliation of resources which are
51+
// cross-referenced. This allows a namespace-scoped dependent to trigger reconciliation of an owner which
52+
// is in a different namespace, and a cluster-scoped dependent can trigger the reconciliation of a
53+
// namespace(scoped)-owner.
54+
//
55+
// As an example, consider the case where we would like to watch clusterroles based on which we reconcile
56+
// namespace-scoped replicasets. With native owner references, this would not be possible since the
57+
// cluster-scoped dependent (clusterroles) is trying to specify a namespace-scoped owner (replicasets).
58+
// Whereas in case of annotations-based handlers, we could implement the following:
59+
//
5760
// ...
5861
// if err := c.Watch(&source.Kind{
5962
// // Watch clusterroles
@@ -66,13 +69,13 @@ const (
6669
// }
6770
// }
6871
// ...
69-
70-
// With this watch, the ReplicaSet reconciler would receive a request to reconcile "my-namespace/my-replicaset" based
71-
// on a change to a ClusterRole that has the following annotations:
72+
//
73+
// With this watch, the ReplicaSet reconciler would receive a request to reconcile
74+
// "my-namespace/my-replicaset" based on a change to a ClusterRole that has the following annotations:
7275
//
7376
// annotations:
74-
// operator-sdk/primary-resource:"my-namespace/my-replicaset"
75-
// operator-sdk/primary-resource-type:"ReplicaSet.apps"
77+
// operator-sdk/primary-resource:"my-namespace/my-replicaset"
78+
// operator-sdk/primary-resource-type:"ReplicaSet.apps"
7679
//
7780
// Though an annotation-based watch handler removes the boundaries set by native owner reference implementation,
7881
// the garbage collector still respects the scope restrictions. For example,
@@ -149,10 +152,10 @@ func parseNamespacedName(namespacedNameString string) types.NamespacedName {
149152
}
150153
}
151154

152-
// SetOwnerAnnotations helps in adding 'NamespacedNameAnnotation' and 'TypeAnnotation' to object based on the values
153-
// obtained from owner. The object gets the annotations from owner's namespace, name, group and kind. In other terms,
154-
// object can be said to be the dependent having annotations from the owner. When a watch is set on the object, the
155-
// annotations help to identify the owner and trigger reconciliation.
155+
// SetOwnerAnnotations helps in adding 'NamespacedNameAnnotation' and 'TypeAnnotation' to object based on
156+
// the values obtained from owner. The object gets the annotations from owner's namespace, name, group
157+
// and kind. In other terms, object can be said to be the dependent having annotations from the owner.
158+
// When a watch is set on the object, the annotations help to identify the owner and trigger reconciliation.
156159
// Annotations are ALWAYS overwritten.
157160
func SetOwnerAnnotations(owner, object controllerutil.Object) error {
158161
if owner.GetName() == "" {

0 commit comments

Comments
 (0)