buildctl: consider supporting VScode's dialect of JSON for unmarshalling source policy JSON, etc. (allows comments and trailing commas)
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 10.3k
- Forks
- 1.5k
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 48
Description
It might be useful to allow VScode's dialect of JSON (jsonc) to allow comments and trailing commas in buildctl,
e.g., for source policy file:
https://github.com/moby/buildkit/blob/4b95d741629df82804c410c18a6d9222bf7a9cde/cmd/buildctl/build.go#L234-L245
ref: https://code.visualstudio.com/docs/languages/json
In addition to the default JSON mode following the JSON specification, VS Code also has a JSON with Comments (jsonc) mode. This mode is used for the VS Code configuration files such as
settings.json,tasks.json, orlaunch.json. When in the JSON with Comments mode, you can use single line (//) as well as block comments (/* */) as used in JavaScript. The mode also accepts trailing commas, but they are discouraged and the editor will display a warning.
I'm not a huge fan of this kind of the "15th competing standard" microformat, but I think VScode and its surrounding ecosystem have become popular enough to allow this.
For implementation, probably https://github.com/muhammadmuzzammil1998/jsonc can be used.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in cmd/buildctl/build.go around lines 234-245, where the source policy JSON is unmarshalled, and trace whether other buildctl inputs use the same parsing path. Confirm which inputs should accept VS Code JSON with comments and trailing commas, then check the relevant buildctl tests or add coverage demonstrating the accepted syntax.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- build-system, cli
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100