-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor environment variables validation #110
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
Conversation
Environment validation had a design flaw resulting in environments not being validated as expected.
This removes some duplication by factorizing common code and using the type system to enforce defaults.
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.
I think this may not do what we want, but I may be misreading the code.
packages/internal-test-env/index.ts
Outdated
if ( | ||
vars.clientCredentials?.owner?.id && | ||
typeof vars.clientCredentials.owner.id !== "string" | ||
typeof process.env.E2E_TEST_OWNER_CLIENT_ID !== "string" |
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.
typeof process.env.E2E_TEST_OWNER_CLIENT_ID !== "string" | |
typeof process.env.E2E_TEST_OWNER_CLIENT_ID !== "string" && process.env.E2E_TEST_OWNER_CLIENT_ID !== "" |
We should be checking that we actually have a valid value set.
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.
Fixed in db46a19.
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.
This'll do for now, though I was looking at these:
- https://www.npmjs.com/package/yup-env
- https://www.npmjs.com/package/envalidate
- https://www.npmjs.com/package/zod
- https://github.com/lostfictions/znv
Which might be more maintainable in the future, as the index.ts
file is getting a bit unwieldy.
This changes the environment validation so that booleans are used to flag env vars that should be validated, instead of a value of their type. Meaning
becomes