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 should apply default values #239

Merged
merged 3 commits into from
May 30, 2024

Conversation

thomas11
Copy link
Contributor

Currently, defaults get applied by non-standard Check but not by infer.DefaultCheck. Since the purpose of infer.DefaultCheck is to mirror the default behavior of the Check call, defaults should be applied.

Resolves #238

@thomas11 thomas11 requested review from iwahbe and a team May 24, 2024 10:21
@thomas11 thomas11 force-pushed the tkappler/defaultcheck-apply-defaults branch from ba469d2 to 1a6b4f8 Compare May 24, 2024 10:28
Copy link
Member

@danielrbradley danielrbradley left a comment

Choose a reason for hiding this comment

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

This looks reasonable to me ... a little tricky to follow how each of these functions are called and how they might interact with each other, but seems like they're just parallel implementation from your experimentation.

Looks like this just replicates the behaviour from:

if err := applyDefaults(&i); err != nil {
return p.CheckResponse{}, fmt.Errorf("unable to apply defaults: %w", err)
}

Would it be possible to make derivedResourceController.Check call into this method so we inherit the behaviour rather than mirror the implementation (no idea if this would be feasible and I think this tactical fix is good for an initial change - just thinking for future consideration)?

Copy link
Member

@iwahbe iwahbe left a comment

Choose a reason for hiding this comment

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

A couple suggestions (very similar to @danielrbradley). The change looks good.

infer/resource.go Show resolved Hide resolved
infer/resource.go Outdated Show resolved Hide resolved
infer/resource_test.go Outdated Show resolved Hide resolved
@thomas11 thomas11 force-pushed the tkappler/defaultcheck-apply-defaults branch from 7f08139 to 45291d5 Compare May 30, 2024 07:13
@thomas11 thomas11 merged commit 33f9262 into main May 30, 2024
6 checks passed
@thomas11 thomas11 deleted the tkappler/defaultcheck-apply-defaults branch May 30, 2024 17:02
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.

Defaults are not applied by DefaultCheck
3 participants