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

feat: exit early if Infracost API Key is invalid #2927

Merged
merged 8 commits into from Mar 5, 2024
Merged

feat: exit early if Infracost API Key is invalid #2927

merged 8 commits into from Mar 5, 2024

Conversation

hugorut
Copy link
Contributor

@hugorut hugorut commented Mar 5, 2024

Changes the breakdown, diff, upload and comment commands to exit early if the INFRACOST_API_KEY is invalid. This is done so that users can better debug their pipelines where an API key might be incorrectly set.

To accomodate this change i've introduced the idea of command middleware which will wrap commands before their execution. This means we can easily chain on additional functionality/checks in the future if required. The specific checkAPIKeyIsValid middleware works by making a empty request to the pricing API service and check if the error returned has an Invalid API Key code. I think this the simplest and most effective way to achieve the API key validation. But you have thoughts of a better way, please let me know.

I have checked with @alikhajeh1 to make sure the error messaging is acceptable.

@hugorut hugorut self-assigned this Mar 5, 2024
@hugorut hugorut changed the title feat: exit early if Infracost API is invalid feat: exit early if Infracost API Key is invalid Mar 5, 2024
Changes the `breakdown`, `diff`, `upload` and `comment` commands to exit early if
the INFRACOST_API_KEY is invalid. This is done so that users can better debug their
pipelines where an API key might be incorrectly set.

To accomodate this change i've introduced the idea of command middleware which will
wrap commands before their execution. This means we can easily chain on additional
functionality/checks in the future if required.
@hugorut hugorut force-pushed the IC-765 branch 2 times, most recently from 0184d42 to 29a8804 Compare March 5, 2024 11:02
@hugorut hugorut requested a review from a team as a code owner March 5, 2024 11:18
@hugorut hugorut merged commit 55a34bb into master Mar 5, 2024
8 of 10 checks passed
@hugorut hugorut deleted the IC-765 branch March 5, 2024 13:46
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.

None yet

3 participants