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

New Check: Discourage Usage of ResourceData.Partial() / ResourceData.SetPartial() #91

Closed
bflad opened this issue Feb 4, 2020 · 0 comments · Fixed by #93
Closed

New Check: Discourage Usage of ResourceData.Partial() / ResourceData.SetPartial() #91

bflad opened this issue Feb 4, 2020 · 0 comments · Fixed by #93
Labels
ast AST Handling check/resource Resource Check new-check New Lint Check

Comments

@bflad
Copy link
Owner

bflad commented Feb 4, 2020

Description

The (helper/schema.ResourceData).Partial() and (helper/schema.ResourceData).SetPartial() functionality represents the following:

Partial turns partial state mode on/off.

When partial state mode is enabled, then only key prefixes specified by SetPartial will be in the final state. This allows providers to return partial states for partially applied resources (when errors occur).

SetPartial adds the key to the final state output while in partial state mode. The key must be a root key in the schema (i.e. it cannot be "list.0").

If partial state mode is disabled, then this has no effect. Additionally, whenever partial state mode is toggled, the partial data is cleared.

In practice however, this functionality is of very limited usage as most errors will stop a dependency chain. Partial state writes would also represent the configuration passthrough values and not the API refreshed values usually calculated via re-reading after update. Also as noted above, the usage of d.SetPartial() without d.Partial() is extraneous.

This feels like it may be two checks:

  • New Check: Discourage usage of d.Partial()
  • New Check: Discourage usage of d.SetPartial()

Flagged Code

d.Partial(true)

d.SetPartial("example")

Passing Code

// Neither used :)

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ast AST Handling check/resource Resource Check new-check New Lint Check
Projects
None yet
1 participant