The plugin makes a request with your Gitlab Yaml file to the Gitlab Lint API, which returns a response whether the file is valid or not. The plugin then parses the response and displays the errors in the editor.
To make this happen, it does the following:
- Checks if the current file is a Gitlab Yaml file.
- Tries to resolve the repository URL and Git branch for current file.
- Parses Gitlab URL from the repository URL.
- Checks if Gitlab API token exists for the Gitlab URL.
- If it doesn't exist:
- Saves the Gitlab URL to the Gitlab URL Token table in the plugin settings.
- Shows a notification to the user to set the Gitlab API token for the Gitlab URL.
- If it doesn't exist:
- Sends a request to the Gitlab Lint API with the current file content and the current branch as reference.
- If the reference branch does not exist on the remote and fallback branch is set, tries again with the fallback branch.
- Parses the response:
- displays the errors in the editor, if the file is not valid
- shows merged preview, if the file is valid and the preview is enabled