Skip to content

Commit c248b5b

Browse files
authored
Add bundle/direct/dresources/README.md (#3693)
Something for people and LLMs to refer to.
1 parent bf3356b commit c248b5b

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

bundle/direct/dresources/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Guidelines on implementing a resource
2+
3+
- See adapter.go on what methods are needed and what constraints are present.
4+
- Return SDK errors directly, no need to wrap them. Things like current operation, resource key, id are already added by the caller and will be part of the error message.
5+
- Although the arguments are pointers, they are never nil, so nil checks are not needed.
6+
- The arguments point to actual struct that will be persisted in state, any changes to it will affect what is stored in state. Usually there is no need to change it, but if there is, there should always be detailed explanation.
7+
- Each Create/Update/Delete method should correspond to one API call. We persist state right after, so there is minimum chance of having orphaned resources.
8+
- The logic what kind of update it is should be in FieldTriggers / ClassifyChange methods. The methods performing update should not have logic in them on what method to call.
9+
- Create/Update/Delete methods should not need to read any state. (We can implement support for passing remoteState we already to these methods if such need arises though).
10+
- Prefer “with refresh” variants of methods if resource API supports that. That avoids explicit DoRefresh() call.
11+
12+
Nice to have
13+
- Add link to corresponding API documentation before each method.
14+
- Add link to corresponding terraform resource implementation at the top of the file.
15+
16+
Testing:
17+
- Make sure to implement CRUD for testserver in libs/testserver
18+
- Test first with go test ./bundle/direct/dresources
19+
- You might need to add test fixture in all\_test.go
20+
- Implement acceptance tests in acceptance/bundle/resources/<resource>/<subtest>
21+
- See acceptance/bundle/resources/volumes
22+
- Prefer smaller tests for each operation.
23+
- Make sure bundle deploy/plan/debug plan/summary/destroy are covered

0 commit comments

Comments
 (0)