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

DB User Translation Layer & SDK migration #1543

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

josvazg
Copy link
Collaborator

@josvazg josvazg commented Apr 24, 2024

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 client

  • See commit 5d11f7c for the migration changes to the nee SDK alone.

Engineering Proposal: Translation Layer

All Submissions:

  • Have you signed our CLA?

@josvazg josvazg changed the title [PoC] dbuser translation layer [PoC] db user translation layer Apr 24, 2024
@josvazg josvazg force-pushed the CLOUDP-242997/poc-translation-layer branch from a99fea9 to 08779e8 Compare April 24, 2024 16:50
Copy link
Contributor

github-actions bot commented Apr 24, 2024

@josvazg josvazg marked this pull request as draft April 24, 2024 16:57
@josvazg josvazg force-pushed the CLOUDP-242997/poc-translation-layer branch 2 times, most recently from 1423146 to 5d11f7c Compare April 25, 2024 06:27
Copy link
Collaborator

@s-urbaniak s-urbaniak left a 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?

@josvazg
Copy link
Collaborator Author

josvazg commented Apr 26, 2024

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.

@@ -0,0 +1,29 @@
package translayer
Copy link
Collaborator

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.

Copy link
Collaborator Author

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

Copy link
Collaborator Author

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) {
Copy link
Collaborator Author

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

coming next

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cloud-tests Run expensive Cloud Tests: Integration & E2E
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants