kubeshop / vscode-monokle

An extension for Visual Studio Code to validate your Kubernetes configuration
https://marketplace.visualstudio.com/items?itemName=kubeshop.monokle
MIT License
6 stars 0 forks source link

Validate files on type or save #62

Closed f1ames closed 8 months ago

f1ames commented 9 months ago

This PR fixes #49. It allows to configure if resources should be validated on save or on type (which is default one).

Changes

See API docs for reference - https://code.visualstudio.com/api/references/vscode-api.

Fixes

Remarks

I'm not fully happy with the solution. From functional and performance-related perspective I think it's really good improvement. For example, before, for every file saved, entire workspace directory was read to get files via globing **/**.yaml (even to get single file content πŸ˜“πŸ™ˆ), so now with dedicated listeners it's much better. But from the code and architecture perspective after spending some time with this and all the edge cases - where you need to validate dirty files, keeping track of resources in the file to determine if use incremental validation, local config can get dirty, etc. it become complex in the existing form. I think the better approach would be keeping and abstract "living" file list with all the manifests and their content which reacts on file changes and stores most recent content (dirty or read from fs) and then always validate using this abstraction instead of directly reading from fs when validating. But it will be another 2-3 days of work and since I realized this a bit too early, didn't want to spend more time on refactoring working solution.

Checklist