Skip to content

Commit 1690788

Browse files
authored
Update dresources/README.md regarding empty ids (#3700)
1 parent e24d19a commit 1690788

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

bundle/direct/dresources/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
Guidelines on implementing a resource
1+
# Guidelines on implementing a resource
22

33
- See adapter.go on what methods are needed and what constraints are present.
44
- 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.
5+
- Although the arguments are pointers, they are never nil, so nil checks are not needed. The passed id argument is never empty string.
6+
- When returning id from DoCreate() and from DoUpdateWithID() there is no need to check that returned id is non-empty, this will be done by the framework and converted to error.
7+
An exception could be made if default error message lacks the necessary context.
68
- 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.
79
- 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.
810
- 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.
@@ -13,7 +15,7 @@ Nice to have
1315
- Add link to corresponding API documentation before each method.
1416
- Add link to corresponding terraform resource implementation at the top of the file.
1517

16-
Testing:
18+
Testing
1719
- Make sure to implement CRUD for testserver in libs/testserver
1820
- Test first with go test ./bundle/direct/dresources
1921
- You might need to add test fixture in all\_test.go

0 commit comments

Comments
 (0)