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

[infer] DefaultDiff - Make it easy to customize diff behavior without re-implementing diff #277

Open
iwahbe opened this issue Sep 23, 2024 · 0 comments
Labels
kind/enhancement Improvements or new features

Comments

@iwahbe
Copy link
Member

iwahbe commented Sep 23, 2024

Hello!

  • Vote on this issue by adding a 👍 reaction
  • If you want to implement this feature, comment to let us know (we'll work with you on design, scheduling, etc.)

Issue details

When infer based resources want to customize the Diff call, they can implement CustomDiff. This is great when the author wants full control of Diff's functionality, but it's expensive and bug-prone if the provider author only wants to tweak diff's behavior (example: #113).

Check & CustomCheck had the same problem, which was solved by the DefaultCheck function:

DefaultCheck is implemented so that if a resource r implements CustomCheck with DefaultCheck, they get the same behavior as not implementing CustomCheck at all:

func (r MyResource) Check(
	ctx context.Context, name string, oldInputs, newInputs resource.PropertyMap,
) (I, []p.CheckFailure, error) {
	return infer.DefaultCheck(ctx, name, oldInputs, newInputs)
}

By allowing custom implementations to wrap the default behavior, provider authors can make arbitrary tweaks to how Check works without the need for re-implementing existing behavior.

We should bring this same functionality to Diff & CustomDiff.

DefaultDiff should work for infer.Resource and infer based provider configuration.

Motivated by #113

@iwahbe iwahbe added kind/enhancement Improvements or new features needs-triage Needs attention from the triage team and removed needs-triage Needs attention from the triage team labels Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements or new features
Projects
None yet
Development

No branches or pull requests

1 participant