infracost / vscode-infracost

See cost estimates for Terraform right in your editor💰📉

Home Page:https://www.infracost.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extension throws error on non-Terraform projects

aliscott opened this issue · comments

After installing the extension, when I open a non-Terraform project I see an error message.

Expected result:

I don't see anything since I'm not expecting Infracost to try to run on my non-Terraform projects.

Actual result:

The following error pops up:

Could not run the infracost cmd in the XXX directory. If this is a multi-project workspace please try opening just a single project. If this problem continues please open an issue here: https://github.com/infracost/vscode-infracost.

Yeah, interesting, I'm not sure how we detect that it's a non-Terraform project vs a project we can't parse. Maybe we just don't show this message if we have failures but instead change the icon (bottom right) to red? And then hover on the icon shows more info

I'm not sure how we detect that it's a non-Terraform project vs a project we can't parse.

Can we only run it if the current open file is a .tf file?

@aliscott yes this is what it currently does, but on the open of the workspace we "init" the workspace and the projects associated with that workspace. I guess we could only run that init step when a file is in focus, for the first time.

but on the open of the workspace we "init" the workspace and the projects associated with that workspace. I guess we could only run that init step when a file is in focus, for the first time.

During the "init" stage can we check for any.tf files in the project (up to a certain depth)? Otherwise, I think doing that init step when a file is in focus for the first time is ok.

During the "init" stage can we check for any.tf files in the project (up to a certain depth)? Otherwise, I think doing that init step when a file is in focus for the first time is ok.

Yeah, I was thinking of checking for tf files to a set depth, this should mirror the depth of the CLI. If we don't find any valid tf files we can change the status of the Infracost bar to be a x and not set any save listeners.

@aliscott I've updated the extension to only activate on projects with tf files as part of https://github.com/infracost/vscode-infracost/releases/tag/v0.1.6. So could you update the extension on your side and see if this fixes for you.

@aliscott I'm closing this issue as I believe this is now fixed, please reopen if it's still a problem for you