resticprofile
resticprofile copied to clipboard
Global json schema (auto versioning)
This PR:
- Generates a JSON schema that redirects to versioned schemas based on
versionandglobal.restic-versionproperties (see also SchemaStore). - Adds an URL for the schema: https://creativeprojects.github.io/resticprofile/jsonschema/config.json
- Fixes
generate --config-reference filename - Simplifies config-1 schema files (schema in
additionalPropertiesinstead of via regex matching with negative lookbehind)
The is the first step to add the schema to the schemastore catalog (we need a single schema for this) and is also more convenient if the URL doesn't need to be changed π
Codecov Report
Patch coverage: 95.00% and project coverage change: +0.04 :tada:
Comparison is base (
7f8554f) 76.02% compared to head (d458c2f) 76.05%.
Additional details and impacted files
@@ Coverage Diff @@
## master #195 +/- ##
==========================================
+ Coverage 76.02% 76.05% +0.04%
==========================================
Files 93 93
Lines 9777 9784 +7
==========================================
+ Hits 7432 7441 +9
Misses 2086 2086
+ Partials 259 257 -2
| Impacted Files | Coverage Ξ | |
|---|---|---|
| config/global.go | 84.21% <ΓΈ> (ΓΈ) |
|
| config/jsonschema/model.go | 94.26% <92.86%> (-0.16%) |
:arrow_down: |
| commands.go | 55.65% <100.00%> (+0.93%) |
:arrow_up: |
| config/jsonschema/schema.go | 97.98% <100.00%> (-0.04%) |
:arrow_down: |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
After some adjustments it works well for YAML and JSON now. "Even better TOML" doesn't support if/then/else, but without it, YAML and JSON report errors incorrectly, since not setting a version is also an error when only using implication and it is the first and only reported error in this case.
One improvement for "Even better TOML" however is that the updated version-1 schema now also works correctly. Previously it didn't support profile commands due to the lack of full regex support in the editor plugin.
For testing with local references, run:
SCHEMA_BASE_URL="http://localhost:1313/resticprofile/jsonschema" \
resticprofile generate --config-reference contrib/templates/config-schema.gojson > docs/static/jsonschema/config.json
Auto selection then works with:
# yaml-language-server: $schema=http://localhost:1313/resticprofile/jsonschema/config.json
version: "2"
global:
restic-version: "0.15"
This looks good to me, thanks for this PR ππ»
I was trying the new configuration locally but it seems that it doesn't recognise the version 2. Am I doing something wrong?
Might be due to implication. While most examples indicate that it should be fine to use it for versioning, I think it needs to be updated to select all versions first using if/then/else and only when this validates, choose a schema for the rest of the document. Otherwise editors will always struggle with priority of errors (or fail to select a different schema).
Will update the template.
Thanks!
I had a quick look at the JSON schema specs and hmmm it does look cutting edge π