Skip to content

Commit

Permalink
Reconciler manual trigger (#148)
Browse files Browse the repository at this point in the history
* expose manual reconcile triggers
* changelog
* return interface
* comment describing private interface
* return base reconciler, reuse existing ReconcileGeneric function
* remove unused import
harveyxia authored Sep 22, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 5626c50 commit 8a5e734
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions changelog/v0.12.2/reconciler-manual-trigger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
changelog:
- type: NEW_FEATURE
description: Expose manual triggers on generated reconcilers.
issueLink: https://github.com/solo-io/skv2/issues/147
12 changes: 7 additions & 5 deletions contrib/codegen/templates/input/input_reconciler.gotmpl
Original file line number Diff line number Diff line change
@@ -40,6 +40,7 @@ import (
)

// the multiClusterReconciler reconciles events for input resources across clusters
// this private interface is used to ensure that the generated struct implements the intended functions
type multiClusterReconciler interface {
{{/* implement reconciler interfaces here */}}
{{- range $group := $groups }}
@@ -84,7 +85,7 @@ func RegisterMultiClusterReconciler(
reconcileInterval time.Duration,
options ReconcileOptions,
predicates ...predicate.Predicate,
) {
) input.MultiClusterReconciler {

base := input.NewMultiClusterReconcilerImpl(
ctx,
@@ -109,7 +110,7 @@ func RegisterMultiClusterReconciler(

{{- end }}
{{- end }}

return r.base
}

{{- range $group := $groups }}
@@ -139,6 +140,7 @@ func (r *multiClusterReconcilerImpl) Reconcile{{ $resource.Kind }}Deletion(clust


// the singleClusterReconciler reconciles events for input resources across clusters
// this private interface is used to ensure that the generated struct implements the intended functions
type singleClusterReconciler interface {
{{/* implement reconciler interfaces here */}}
{{- range $group := $groups }}
@@ -167,7 +169,7 @@ func RegisterSingleClusterReconciler(
reconcileInterval time.Duration,
options reconcile.Options,
predicates ...predicate.Predicate,
) error {
) (input.SingleClusterReconciler, error) {

base := input.NewSingleClusterReconciler(
ctx,
@@ -187,12 +189,12 @@ func RegisterSingleClusterReconciler(
{{- $kindLowerCamel := lower_camel $resource.Kind }}
{{- $kindLowerCamelPlural := pluralize $kindLowerCamel }}
if err := {{ $controller_import_prefix }}.New{{ $resource.Kind }}ReconcileLoop("{{ $resource.Kind }}", mgr, options).Run{{ $resource.Kind }}Reconciler(ctx, r, predicates...); err != nil {
return err
return nil, err
}
{{- end }}
{{- end }}

return nil
return r.base, nil
}

{{- range $group := $groups }}

0 comments on commit 8a5e734

Please sign in to comment.