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

DefaultCheck with context.Context #253

Merged
merged 1 commit into from
Jul 27, 2024
Merged

Conversation

iwahbe
Copy link
Member

@iwahbe iwahbe commented Jul 24, 2024

Following up on #252, this allows DefaultCheck to safely and accurately handle secrets application. The new signature for DefaultCheck is easier to extend without additional breaking changes. The downside to this design is that this makes DefaultCheck special. I think it's worth living with that until #212 is resolved.

I'd like to merge shortly after #252 (and before #252 is released) so that user's don't rely on #252 injecting secrets when CustomCheck is implemented and DefaultCheck is not called.

@iwahbe iwahbe requested review from thomas11, blampe and a team July 24, 2024 19:20
@iwahbe iwahbe self-assigned this Jul 24, 2024
Copy link
Member

@mjeffryes mjeffryes left a comment

Choose a reason for hiding this comment

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

I'm not sure I follow the motivation. Why do we want authors to apply secrets themselves rather than relying on the framework to apply them?

infer/configuration.go Outdated Show resolved Hide resolved
tests/config_test.go Outdated Show resolved Hide resolved
@iwahbe iwahbe force-pushed the iwahbe/inject-secrets-from-schemas branch 2 times, most recently from cd96ba2 to 4a5e543 Compare July 26, 2024 15:56
Base automatically changed from iwahbe/inject-secrets-from-schemas to main July 26, 2024 16:07
@iwahbe iwahbe force-pushed the iwahbe/default-check-with-context branch 3 times, most recently from 371ea13 to a187b9b Compare July 26, 2024 17:00
@iwahbe
Copy link
Member Author

iwahbe commented Jul 26, 2024

I'm not sure I follow the motivation. Why do we want authors to apply secrets themselves rather than relying on the framework to apply them?

I added this to the commit message:

Ideally, most users will not need to implement check. By design, not implementing
CustomCheck has the same behavior as implementing check with
return infer.DefaultCheck(...). If users do implement CustomCheck, then we don't want
to make any assumptions about what behavior they want. This includes not applying defaults
and not injecting secrets.

@iwahbe iwahbe requested a review from mjeffryes July 26, 2024 17:00
Copy link
Contributor

@EronWright EronWright left a comment

Choose a reason for hiding this comment

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

It is a breaking change (to DefaultCheck), right? Is that a concern?

The technique of using the context to pass information back up, I've not seen elsewhere. Maybe could use more commentary, like why the default check's encoder is so precious.

@iwahbe
Copy link
Member Author

iwahbe commented Jul 26, 2024

It is a breaking change (to DefaultCheck), right? Is that a concern?

It is. I think its a positive one though. This library is still in v0 and we tell users to expect breaking changes.

The technique of using the context to pass information back up, I've not seen elsewhere. Maybe could use more commentary, like why the default check's encoder is so precious.

ende.Encoders are the byproduct of going from resource.PropertyMap to C where C is some user supplied type. They carry a look-aside table of what is expressible with resource.PropertyMap but not expressible with C, such as secrets and unknown values. I'll add a comment to ende.Encoder to explain why it exists.

Copy link
Contributor

@EronWright EronWright left a comment

Choose a reason for hiding this comment

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

Approving because it seems fine.

Following up on #252, this allows `DefaultCheck` to safely and accurately handle secrets
application. The new signature for `DefaultCheck` is easier to extend without additional
breaking changes. The downside to this design is that this makes `DefaultCheck` special. I
think it's worth living with that until #212 is resolved.

I'd like to merge shortly after #252 (and before #252 is released) so that user's don't
rely on #252 injecting secrets when `CustomCheck` is implemented and `DefaultCheck` is not
called.

Rational for the change:

Ideally, most users will not need to implement check. By design, not implementing
`CustomCheck` has the same behavior as implementing check with
`return infer.DefaultCheck(...)`. If users do implement `CustomCheck`, then we don't want
to make any assumptions about what behavior they want. This includes not applying defaults
and not injecting secrets.
@iwahbe iwahbe force-pushed the iwahbe/default-check-with-context branch from a187b9b to 1807678 Compare July 27, 2024 00:29
@iwahbe iwahbe enabled auto-merge (rebase) July 27, 2024 00:30
@iwahbe iwahbe merged commit 41e6149 into main Jul 27, 2024
6 checks passed
@iwahbe iwahbe deleted the iwahbe/default-check-with-context branch July 27, 2024 00:38
@pulumi-bot
Copy link

This PR has been shipped in release v0.21.0.

@mjeffryes mjeffryes added this to the 0.108 milestone Aug 16, 2024
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.

4 participants