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

Fauna Query Options #441

Merged
merged 2 commits into from
Nov 26, 2024
Merged

Fauna Query Options #441

merged 2 commits into from
Nov 26, 2024

Conversation

henryfauna
Copy link
Contributor

@henryfauna henryfauna commented Nov 26, 2024

Problem

We will always want to enable a certain set of options for commands that talk to fauna. These options include url, secret, database and role. At the moment these are spread around, some defined at the top level of the cli and other kept in the commonQueryOptions object.

Solution

Consolidate these options in one place and setup some validation on top of them so users are warned if they specify conflicting or redundant args.

Result

It will be easier to wire up just in time db keys for commands that talk to fauna.

Out of Scope

Doing the same things with the key commands.

Testing

Added new tests to make sure the arg validation works.

@henryfauna henryfauna requested a review from a team as a code owner November 26, 2024 18:41
Comment on lines +12 to +24
if (argv.secret && argv.database) {
// Providing a database and secret are conflicting options. If both are provided,
// it is not clear which one to use.
throw new Error(
"Cannot use both the '--secret' and '--database' options together. Please specify only one.",
);
} else if (argv.role && argv.secret) {
// The '--role' option is not supported when using a secret. Secrets have an
// implicit role.
logger.warn(
"The '--role' option is not supported when using a secret. It will be ignored.",
);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Could probably factor these checks out into command-helpers and then use that to check everywhere commonQueryOptions are used. If you agree, as a follow up sounds fine to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yup definitely - I'll factor stuff out when I get to updating keys

Comment on lines -49 to -54
// export async function ensureDbScopeClient({ scope, version, argv }) {
// const path = scope.split("/");

// const { connectionOptions } = await getClient({ version: "4", argv });
// const { hostname, port, protocol } = new URL(connectionOptions.url);

Copy link
Contributor

Choose a reason for hiding this comment

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

yay

Co-authored-by: echo-bravo-yahoo <[email protected]>
@echo-bravo-yahoo echo-bravo-yahoo merged commit 0285ab4 into v3 Nov 26, 2024
4 checks passed
@echo-bravo-yahoo echo-bravo-yahoo deleted the fauna-query-options branch November 26, 2024 18:55
@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