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

Add type checks to generated methods #2

Open
hasheddan opened this issue Oct 4, 2019 · 2 comments
Open

Add type checks to generated methods #2

hasheddan opened this issue Oct 4, 2019 · 2 comments
Labels
enhancement New feature or request wontfix This will not be worked on

Comments

@hasheddan
Copy link
Member

What problem are you facing?

Before generation was used for claim / class / managed resource methods, we made sure that methods were implemented such that each struct satisfied its desired interface. For example:

var _ resource.Claim = &RedisCluster{}

How could Crossplane help solve your problem?

Though these type checks are less important now that the methods are generated, they are helpful for someone who is trying to understand how these types are used in crossplane-runtime. It would be useful to generate these type checks alongside the methods.

@negz
Copy link
Member

negz commented Oct 17, 2019

Implementation wise I think it might be possible to do this using a generate.WriteOption. Something like:

	err := generate.WriteMethods(p, methods, filepath.Join(filepath.Dir(p.GoFiles[0]), filename),
		generate.Satisfies(i),  // i is however we choose to represent an interface here.
		generate.WithHeaders(header),
		generate.WithImportAliases(map[string]string{RuntimeImport: RuntimeAlias}),
		generate.WithMatcher(match.AllOf(
			match.Class(),
			match.DoesNotHaveMarker(comments.In(p), DisableMarker, "false")),
		),
	)

@stale
Copy link

stale bot commented Aug 13, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Aug 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants