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

Set a default EventHandler if the provider's main module does not supply one #249

Merged
merged 1 commit into from
Aug 4, 2023

Conversation

ulucinar
Copy link
Collaborator

@ulucinar ulucinar commented Aug 3, 2023

Description of your changes

While updating the upjet dependency to the main HEAD, @haarchri figured out that the recently introduced changes with #231 are not backwards-compatible. This PR makes those changes backwards-compatible by setting a default event handler if one is not already set by the provider's main module. The provider may set the event handler with something like:

o := tjcontroller.Options{
		Options: xpcontroller.Options{
			Logger:                  log,
			GlobalRateLimiter:       ratelimiter.NewGlobal(*maxReconcileRate),
			PollInterval:            *pollInterval,
			MaxConcurrentReconciles: *maxReconcileRate,
			Features:                &feature.Flags{},
		},
		Provider:       config.GetProvider(),
		SetupFn:        clients.TerraformSetupBuilder(*terraformVersion, *nativeProviderSource, *providerVersion),
		WorkspaceStore: terraform.NewWorkspaceStore(log, terraform.WithDisableInit(len(*nativeProviderPath) != 0), terraform.WithProcessReportInterval(*pollInterval), terraform.WithFeatures(featureFlags)),
		EventHandler: handler.NewEventHandler(),
	}

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable to ensure this PR is ready for review.
  • Added backport release-x.y labels to auto-backport this PR if necessary.

How has this code been tested

Tested against crossplane-contrib/provider-pagerduty.

…ply one

- Setting a default EventHandler to keep backwards-compatibility
  for the generated providers

Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
Copy link
Contributor

@haarchri haarchri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its working

can also see the following change in generated files:

 func Setup(mgr ctrl.Manager, o controller.Options) error {
+       // set the default event handler if the provider's main module did not
+       // set one.
+       if o.EventHandler == nil {
+               o.EventHandler = handler.NewEventHandler()
+       }

@ulucinar ulucinar merged commit c0e39e7 into crossplane:main Aug 4, 2023
4 checks passed
@ulucinar ulucinar deleted the set-default-eventhandler branch August 4, 2023 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants