turbot / steampipe

Zero-ETL, infinite possibilities. Live query APIs, code & more with SQL. No DB required.
https://steampipe.io
GNU Affero General Public License v3.0
6.84k stars 264 forks source link

steampipe mod init should warn users when the directory is large / unusual #2562

Closed e-gineer closed 1 year ago

e-gineer commented 1 year ago

We've seen a few users accidentally run steampipe mod init in their home directory, which then causes steampipe commands in that location or lower to try and load all files (slow performance, easy to error if files are invalid).

When running steampipe mod init It would be great to warn if:

SaumyaBhushan commented 1 year ago

Hey @e-gineer I would like to work on this . Can you please guide me how to do this?

kaidaguerre commented 1 year ago

Hey @SaumyaBhushan thanks for that.

The mod init is performed by this function: https://github.com/turbot/steampipe/blob/f80f9c1b21b9a3d8edc6c54b5f4de15d29bef55b/cmd/mod.go#L215

I suggest adding a function verifyModLocation which returns a bool indicating whether to proceed.

verifyModLocation should to be called before CreateDefaultMod

You could move the existing mod checking into this function:

if parse.ModfileExists(workspacePath) {
        fmt.Println("Working folder already contains a mod definition file")
        return
    }

Then after that, add the checking described by the issue. If:

github-actions[bot] commented 1 year ago

'This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.'

github-actions[bot] commented 1 year ago

'This issue was closed because it has been stalled for 90 days with no activity.'

Aaronstotle commented 1 year ago

Hello, I'd like to work on this issue, thanks for the description/breaking it down

Aaronstotle commented 1 year ago

https://github.com/Aaronstotle/steampipe_mod_init/commit/fac993ccd4ecbc3ee2d45471bc35b53ccc0e70bc

So I have a basic function here that will trigger when I run this in my home directory, however I'm not sure how I stop make the program stop and confirm for the user