// SetupWithManager sets up the controller with the Manager.
SetupWithManager sets up the controller with the Manager.
// SetupWithManager sets up the controller with the Manager .
func (r *VegetaReconciler) SetupWithManager(mgr ctrl.Manager) error {
	if err := mgr.GetFieldIndexer().IndexField(context.Background(), &corev1.Pod{}, podOwnerKey, func(rawObj client.Object) []string {
		pod := rawObj.(*corev1.Pod)
		owner := metav1.GetControllerOf(pod)
		if owner == nil {
			return nil
		}
		if owner.APIVersion != apiGVStr || owner.Kind != "Vegeta" {
			return nil
		}
		return []string{owner.Name}
	}); err != nil {
		return fmt.Errorf("SetupWithManager: %v", err)
	}
	return ctrl.NewControllerManagedBy(mgr).
		For(&vegetav1alpha1.Vegeta{}).
		Owns(&corev1.Pod{}).
		Complete(r)
}
func ( r * VegetaReconciler ) SetupWithManager ( mgr ctrl . Manager ) error { if err := mgr . GetFieldIndexer ( ) . IndexField ( context . Background ( ) , & corev1 . Pod { } , podOwnerKey , func ( rawObj client . Object ) [ ] string { pod := rawObj . ( * corev1 . Pod ) owner := metav1 . GetControllerOf ( pod ) if owner == nil { return nil } if owner . APIVersion != apiGVStr || owner . Kind != " " { return nil } return [ ] string { owner . Name } } ) ; err != nil { return fmt . Errorf ( " " , err ) } return ctrl . NewControllerManagedBy ( mgr ) . For ( & vegetav1alpha1 . Vegeta { } ) . Owns ( & corev1 . Pod { } ) . Complete ( r ) }
SetupWithManager sets up the controller with the Manager.
SetupWithManager sets up the controller with the Manager .
// grab the job object, extract the owner... // ...make sure it's a Vegeta... // ...and if so, return it