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

Add dynamic key support to schema #466

Merged
merged 6 commits into from
Dec 4, 2024
Merged

Add dynamic key support to schema #466

merged 6 commits into from
Dec 4, 2024

Conversation

ecooper
Copy link

@ecooper ecooper commented Dec 4, 2024

Problem

Schema commands do not support dynamic database keys.

Solution

Add support for dynamic database keys via getSecret() and retryInvalidCredsOnce.

Result

➜  fauna-shell (v3-db-schema) ./src/user-entrypoint.mjs schema pull -d us-std/demo --dir /tmp/schema -p dev                                                                                                                                           ✱
Pull will make the following changes:
overwrite: collections.fsl
overwrite: functions.fsl
overwrite: main.fsl
✔ Accept the changes? yes
➜  fauna-shell (v3-db-schema) ls -la /tmp/schema/                                                                                                                                                                                                     ✱
total 32
drwxr-xr-x  5 ericcooper  wheel   160 Dec  4 12:45 .
drwxrwxrwt  5 root        wheel   160 Dec  4 12:45 ..
-rw-r--r--  1 ericcooper  wheel  2780 Dec  4 12:49 collections.fsl
-rw-r--r--  1 ericcooper  wheel  4539 Dec  4 12:49 functions.fsl
-rw-r--r--  1 ericcooper  wheel   263 Dec  4 12:49 main.fsl
➜  fauna-shell (v3-db-schema)      

Testing

Existing tests should work as-is since this should be a transparent change.

Follow-up

  • Consider combining getSecret and retryInvalidCredsOnce into one wrapper.

Comment on lines +86 to +90
export function makeRetryableFaunaRequest(opts) {
return retryInvalidCredsOnce(opts.secret, (secret) =>
makeFaunaRequest({ ...opts, secret }),
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

not for this PR, but i think it'd be lower mental overhead to have just one entrypoint (makeFaunaRequest) and pass it opts, argv, and have it choose if it should be retryable or not. exporting multiple entrypoints and expecting consumers to pick correctly is more brittle.

@echo-bravo-yahoo echo-bravo-yahoo merged commit 9abff40 into v3 Dec 4, 2024
4 checks passed
@echo-bravo-yahoo echo-bravo-yahoo deleted the v3-db-schema branch December 4, 2024 23:38
@cleve-fauna cleve-fauna mentioned this pull request Dec 5, 2024
This was referenced Dec 6, 2024
@cleve-fauna cleve-fauna mentioned this pull request Dec 13, 2024
@wildemat wildemat mentioned this pull request Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants