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

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

Closed
e-gineer opened this issue Oct 20, 2022 · 6 comments
Closed
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@e-gineer
Copy link
Contributor

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:

  • It's run in the home directory
  • It's run in a directory with a lot of files or subdirectories (e.g. >5 files that are not .sql or .sp)
@e-gineer e-gineer added enhancement New feature or request good first issue Good for newcomers labels Oct 20, 2022
@SaumyaBhushan
Copy link
Contributor

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

@kaidaguerre
Copy link
Contributor

kaidaguerre commented Oct 20, 2022

Hey @SaumyaBhushan thanks for that.

The mod init is performed by this function:

func runModInitCmd(cmd *cobra.Command, args []string) {

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:

  • It's run in the home directory
  • It's run in a directory with a lot of files or subdirectories (e.g. >5 files that are not .sql or .sp)
    then display a warning and ask the user for confirmation to continue

@MichaelBurgess MichaelBurgess changed the title steampipe mod init should warn users when the directory is large / unusal steampipe mod init should warn users when the directory is large / unusual Oct 24, 2022
@github-actions
Copy link

'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 github-actions bot added the stale No recent activity has been detected on this issue/PR and it will be closed label Dec 24, 2022
@github-actions
Copy link

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

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 25, 2023
@kaidaguerre kaidaguerre reopened this Jan 25, 2023
@github-actions github-actions bot removed the stale No recent activity has been detected on this issue/PR and it will be closed label Jan 26, 2023
@Aaronstotle
Copy link
Contributor

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

@Aaronstotle
Copy link
Contributor

Aaronstotle@fac993c

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

4 participants