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

Support .gitignore when scanning workspace for manifests #71

Open
f1ames opened this issue Dec 11, 2023 · 0 comments
Open

Support .gitignore when scanning workspace for manifests #71

f1ames opened this issue Dec 11, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@f1ames
Copy link
Contributor

f1ames commented Dec 11, 2023

Extracted from #68 (comment). Initially I thought it could be the part of mentioned PR but since it's more complex and the PR itself resolves initial issue, it will be better handled separately.

The reason for this task are further performance improvements. As described in the PR:

...especially that reading yamls from workspace (which is a part of validation) takes, like 10 - 20 seconds (see below).

(...) What is used now for scanning for manifests is native workspace.findeFiles. It takes into account files ignored in VSC via files.exclude but does not look on .gitignore.

Now measuring times for monokle-saas repo, it seems not finding files but parsing them takes most time (...) interestingly we got 50 resources from 837 files, which means most files are not K8s resources (I quickly check and just by ignoring node_modules we get to 137 files and less than 5 seconds).

For context, scanning took less than 500ms while parsing more than 7 second.


Possible solutions

Adjust workspace.findeFiles to take into account .gitignores

There is no build in support for this and would need to be done manually. And this is a bit tricky because:

  • This method accepts only single glob pattern as exclude pattern. So all gitignore entries needs to be glued correctly (like {line1,line2} AFAIU) also making sure that ** are added if needed.
  • There can be multiple gitignores (in monokle-saas there are 17) which needs to be found first, parsed and glued to exclude glob.
    • And also while initially reading gitignores, you will get ones in gitignored folders (chicken and egg problem).

As an alternative, we could scan the same way as now and then just filter out ignored files (still requires parsing all gitgnores and glob filtering on resulted files list).

What is important here, I did a bit of benchmarking, and this method is pretty efficient (in relation to other approaches). For monokle-saas repo it took less than 500ms, and found 807 yamls.

Use 3rd-party library

I tested this with globby. It has a build-in option to take gitignore files automatically into account. And it is considered one of the fastest JS implementations from what I see.

However, there are 2 issues I see - the results are quite different - for build-in method I got 807 files while with globby only 78 (even with gitignores not taken into account). Also scanning entire repo takes globby around 15 seconds on my machine (while VSC build in is less than 500ms).

Others

It might be worth looking into how other extension do this maybe 🤔 I did quite searching in VSCode docs and outside for a build-in way or quick solution to do this in VSCode extension but haven't found anything worth mentioning here.

@f1ames f1ames added the enhancement New feature or request label Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant