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
DB User Translation Layer & SDK migration #1543
base: main
Are you sure you want to change the base?
Conversation
a99fea9
to
08779e8
Compare
1423146
to
5d11f7c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
general question: how does the "contract" look like which the translation layer seems to be a prerequisite for?
The contract is not really fully defined until you have the tests with the validations that check precisely the contract behavior. Here we only have the shape of the interactions in the service methods and the translations we make. This is NOT the contract test PoC, just the translation layer, which is probably more than half the code required. What is left now is the helper code to be able to put the API side in the state required to be able to test the API calls in the service in the situations that define the contract with the Atlas. Those tests inform how and when the service calls defined in the translation layer should be called from the controller to achieve the expected results. Which would allow to test the reconciliation without the API with a great deal of confidence, other than if something changes on the API side, which the contract tests will detect. Client Contract Tests do NOT need to cover all API behaviours, just the ones our client cares about. |
aadc13f
to
e7a7a23
Compare
2d3d6f7
to
9766008
Compare
9766008
to
0c42852
Compare
internal/translayer/client.go
Outdated
@@ -0,0 +1,29 @@ | |||
package translayer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: translayer
implies two terms, "translation" and "layer". The latter is somewhat obvious as every package is a layer. How about just translation
? That naming is pretty idiomatic and immediately implies what is done here, namely translating things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will rename, I will also rename the translation.go
files to conversion.go
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coming on next PR update
return &User{AtlasDatabaseUserSpec: spec, ProjectID: projectID, Password: password} | ||
} | ||
|
||
func Normalize(spec *akov2.AtlasDatabaseUserSpec) (*akov2.AtlasDatabaseUserSpec, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add godoc on making a copy before calling, as this makes changes on input
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coming next
Signed-off-by: jose.vazquez <jose.vazquez@mongodb.com>
Signed-off-by: jose.vazquez <jose.vazquez@mongodb.com>
Signed-off-by: jose.vazquez <jose.vazquez@mongodb.com>
Signed-off-by: jose.vazquez <jose.vazquez@mongodb.com>
Signed-off-by: jose.vazquez <jose.vazquez@mongodb.com>
Signed-off-by: jose.vazquez <jose.vazquez@mongodb.com>
Signed-off-by: jose.vazquez <jose.vazquez@mongodb.com>
b4c82cb
to
b1584ec
Compare
Sample Translation layer for your consideration:
The packages under
internal/translation
contain per Altas resource translation layers for users and deployments.Files in the controller package should not import the SDK library to call the API or use its types.
All translations and upgrades are confined to the
translation
code.Contract tests would use the translation layer directly.
This layout also enforces proper translations and comparisons, no more funky CMP or JSONCopies.
See commit 1423146 for a version when the translation layer is on an
atlas.go
file within the same package using the old Go API clientSee commit 5d11f7c for the migration changes to the nee SDK alone.
Engineering Proposal: Translation Layer
All Submissions: