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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hugorut
changed the title
feat: exit early if Infracost API is invalid
feat: exit early if Infracost API Key is invalid
Mar 5, 2024
aliscott
reviewed
Mar 5, 2024
cmd/infracost/testdata/breakdown_invalid_apikey/breakdown_invalid_apikey.golden
Outdated
Show resolved
Hide resolved
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
force-pushed
the
IC-765
branch
2 times, most recently
from
March 5, 2024 11:02
0184d42
to
29a8804
Compare
vdmgolub
approved these changes
Mar 5, 2024
aliscott
approved these changes
Mar 5, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes the
breakdown
,diff
,upload
andcomment
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.