Skip to content

Commit

Permalink
fix: manager for controller
Browse files Browse the repository at this point in the history
  • Loading branch information
ansh-devs committed Jul 21, 2024
1 parent b7f4e25 commit bfd9d3c
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions internal/controller/jenkins_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"
)

type reconcileError struct {
Expand Down Expand Up @@ -79,18 +78,30 @@ type JenkinsReconciler struct {
// SetupWithManager sets up the controller with the Manager.
func (r *JenkinsReconciler) SetupWithManager(mgr ctrl.Manager) error {
jenkinsHandler := &enqueueRequestForJenkins{}
// configMapResource := &source.Kind{Type: &corev1.ConfigMap{TypeMeta: metav1.TypeMeta{APIVersion: APIVersion, Kind: ConfigMapKind}}}
configMapResource := source.Kind(mgr.GetCache(), internal.Kind())
secretResource := &source.Kind{Type: &corev1.Secret{TypeMeta: metav1.TypeMeta{APIVersion: APIVersion, Kind: SecretKind}}}
decorator := jenkinsDecorator{handler: &handler.EnqueueRequestForObject{}}
configMapResource := &corev1.Secret{
TypeMeta: metav1.TypeMeta{
APIVersion: APIVersion,
Kind: SecretKind,
},
}
secretResource := &corev1.Secret{
TypeMeta: metav1.TypeMeta{
APIVersion: APIVersion,
Kind: SecretKind,
},
}
decorator := jenkinsDecorator{
handler: &handler.EnqueueRequestForObject{},
}

return ctrl.NewControllerManagedBy(mgr).
For(&v1alpha2.Jenkins{}).
Owns(&corev1.Pod{}).
Owns(&corev1.Secret{}).
Owns(&corev1.ConfigMap{}).
Watches(secretResource, jenkinsHandler).
Watches(configMapResource, jenkinsHandler).
Watches(&source.Kind{Type: &v1alpha2.Jenkins{}}, &decorator).
Watches(&v1alpha2.Jenkins{}, &decorator).
Complete(r)
}

Expand Down

0 comments on commit bfd9d3c

Please sign in to comment.