-
-
Notifications
You must be signed in to change notification settings - Fork 347
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
Allow YAML for human-edited metadata (YAMLKAN) #3367
Conversation
b8db3eb
to
b65698c
Compare
Have not reviewed the code, but I'm a very strong supporter of YAML where humans need to be involved. JSON is not human friendly. |
I just realized I forgot to add the "discussion needed" label, as it is very much not yet set in stone whether we would want to do this. Thanks for your two cents, @techman83. |
No worries. Not that this is on the table, but CKAN-meta should remain json only, it is preferable to let NetKAN do all the heavy lifting. But the amount of issues we've had with reasonable JSON mistakes over the years! |
Yeah, agreed. I will not be submitting my other branch that was converting everything to YAML. Not only are there way more changes needed, but some of the existing |
Executing netkan.exe for the JSON Astrogator.netkan:
It converts |
63d36db
to
99739a1
Compare
I know how to generate |
Luckily the parser keeps track of the original syntax for us. So if a field gives us trouble, after the latest commit we can change this: author: 123456 to this: author: "123456" |
A small side-effect I just encountered: People need to update their file type associations in their editors ^^ That aside, works pretty good so far in my testing. I'm also going to try to write some YAML netkans from scratch to find possible trouble spots that need mentioning in a guide. |
Indeed, my
Good point, will add to post-merge steps... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good. I tested YAML and JSON netkans, and they all seem to work fine and produce the same output as before.
Let's give this a go, for hopefully fewer syntax issues in the future 🤞
One of the tests queries SpaceDock, so it's failing for now because SpaceDock is having a relapse of KSP-SpaceDock/SpaceDock#226. Will have to re-run the Actions once it's working again. |
Motivation
Currently all metadata is in JSON. This is fine/great for machine-written metadata, but for humans it can be a bit tricky, as we have to worry about proper usage of quotes, commas, braces, brackets, etc.
YAML is a JSON superset format used for GitHub Actions and many other administrative/automation contexts. It is somewhat more human-friendly than JSON, as quotes, commas, braces, and brackets are assumed based on the structure and indenting of the data. For example, this JSON:
is equivalent to this YAML:
https://www.convertjson.com/yaml-to-json.htm
To cure our "notoriously resistance on implementing new features on CKAN" 🤣, we should be adventurous and always try new things. 🏴☠️ ⛷️ 🤹
Changes
Now the human-maintained parts of the metadata (the things that Netkan treats as inputs) are allowed to be in JSON or YAML (since all valid JSON is also valid YAML):
Netkan's output is still exclusively JSON, and none of the other JSON files that we save are affected (config, registry, etc.). The client still only deals in JSON. Tests are included to make sure our YAML parsing and JSON conversion are correct.
Future to-do
To deploy this fully, a few more changes will be needed in other repos:
NetKAN-Infra
(Allow YAML format for .netkans NetKAN-Infra#219)xKAN-meta_testing
(Allow YAML format for .netkans xKAN-meta_testing#75)metadata-webtool
(Allow YAML format for .netkans metadata-webtool#40)