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

feat: improve linter #154

Merged
merged 7 commits into from
Jul 20, 2024
Merged

feat: improve linter #154

merged 7 commits into from
Jul 20, 2024

Conversation

bzp2010
Copy link
Collaborator

@bzp2010 bzp2010 commented Jul 19, 2024

Description

The current linter schema is somewhat outdated and incomplete, this PR fixes these flaws and provides a JSON Schema export for the benefit of IDE users.

As far as I know, you can enable schema checking in your VSCode using a syntax like:

# yaml-language-server: $schema=https://raw.githubusercontent.com/api7/adc/main/schema.json
services: []

Note that the file schema.json is generated by the program, so the JSON Schema may not fully reflect the complete configuration schema, as some of the checksums are done at runtime by code.
I don't think you need to worry about this, execute adc lint to check the declaration file in its entirety.

In addition to this, I must say that since API7 and APISIX do not currently support the same features, and it is possible that a feature is not yet implemented on a particular platform, the configuration checked by lint does not always ensure that all fields are submited to the API, it is a best-effort effort based on the back-end API version. If you encounter a field that is not supported, the ADC or backend API may discard it or report an error.

Checklist

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible

@bzp2010 bzp2010 marked this pull request as ready for review July 19, 2024 17:53
@bzp2010
Copy link
Collaborator Author

bzp2010 commented Jul 19, 2024

Test with the following:

# yaml-language-server: $schema=https://github.com/api7/adc/blob/994a43177405c410743ac377cc198a44e252975d/schema.json

@bzp2010 bzp2010 merged commit 1ca4d2c into main Jul 20, 2024
6 checks passed
@pottekkat
Copy link
Contributor

Excellent idea!

@bzp2010 bzp2010 deleted the bzp/feat-improve-linter branch July 24, 2024 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants