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

Create an Attributes() method for each model struct in the schema #27

Open
ctjnkns opened this issue Jan 13, 2024 · 0 comments
Open

Create an Attributes() method for each model struct in the schema #27

ctjnkns opened this issue Jan 13, 2024 · 0 comments

Comments

@ctjnkns
Copy link
Owner

ctjnkns commented Jan 13, 2024

It can be difficult to track giant nested schemas.

Instead, create an Attributes() method for each model struct in the schema. This way I can keep the struct definition (tfsdk tags and whatnot) and its schema elements together. For example, check out the nesting in this resource. You'd never suspect it from the six-line Schema() method. The top-level model has an Attributes() method which invokes Attributes() methods of nested models which invoke Attributes() methods of nested models... I dunno if you'll find it helpful, but it did wonders for my sanity (lots of re-use of these models and identical chunks of schema in my case).

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

No branches or pull requests

1 participant