You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: bundle/direct/dresources/README.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,10 @@
1
-
Guidelines on implementing a resource
1
+
# Guidelines on implementing a resource
2
2
3
3
- See adapter.go on what methods are needed and what constraints are present.
4
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.
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.
6
8
- 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
9
- 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
10
- 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
13
15
- Add link to corresponding API documentation before each method.
14
16
- Add link to corresponding terraform resource implementation at the top of the file.
15
17
16
-
Testing:
18
+
Testing
17
19
- Make sure to implement CRUD for testserver in libs/testserver
18
20
- Test first with go test ./bundle/direct/dresources
19
21
- You might need to add test fixture in all\_test.go
0 commit comments