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

[Feature Request] Generate json schema for registry from Go structs #623

Closed
4513ECHO opened this issue Apr 1, 2022 · 17 comments · Fixed by #927
Closed

[Feature Request] Generate json schema for registry from Go structs #623

4513ECHO opened this issue Apr 1, 2022 · 17 comments · Fixed by #927
Labels
enhancement New feature or request

Comments

@4513ECHO
Copy link
Contributor

4513ECHO commented Apr 1, 2022

Feature Overview

Generate json schema to validate registry files.

Why is the feature needed?

Please explain the problem you want to solve.

We can write registry with in yaml. It is declarative, but writing correctly has been difficult a bit lately. I want help of editor.

I suggest to give out json schema. It defines structure of json-like lanuage (yaml or toml), and it can be used by language server. It is useful for completion or linting, so we can develop registry more easily.

Also, generated schema should be served on the website (https://aquaproj.github.io is suitable)

Ready-made projects to do that:

Does the feature include Breaking Changes?

No.

Example Code

command and configuration

$ 
@suzuki-shunsuke suzuki-shunsuke added the enhancement New feature or request label Apr 1, 2022
@4513ECHO
Copy link
Contributor Author

4513ECHO commented Apr 1, 2022

It is kind in registry to add parameter than adding custom templates.
String is hard to validate for linter or language server.

@suzuki-shunsuke
Copy link
Member

suzuki-shunsuke commented Apr 1, 2022

Thank you for your proposal.

I use JSON Schema in the other project and I think it's useful.

In the project, I maintain JSON Schema manually, but it's useful to generate JSON Schema from Go.

@suzuki-shunsuke
Copy link
Member

@suzuki-shunsuke
Copy link
Member

#624

@suzuki-shunsuke
Copy link
Member

Unfortunately, json-schema-for-humans doesn't support JSON Schema 2020-12.
coveooss/json-schema-for-humans#131 (comment)

@suzuki-shunsuke
Copy link
Member

suzuki-shunsuke commented Apr 1, 2022

@suzuki-shunsuke
Copy link
Member

Hmm...
Maybe https://raw.githubusercontent.com/aquaproj/aqua/main/json-schema/aqua-yaml.json is better than GitHub Pages in terms of versioning.

@suzuki-shunsuke
Copy link
Member

I've removed the repository aquaproj/json-schema.

This was referenced Apr 2, 2022
@suzuki-shunsuke
Copy link
Member

I found a bug with JSON Schema. 🙂
aquaproj/aqua-registry#2777

@suzuki-shunsuke
Copy link
Member

@4513ECHO
Copy link
Contributor Author

4513ECHO commented Apr 2, 2022

Schema looks nice. Linting works correctly on my editor. However I have one suggest.
I think the properties of replacements should be possible values of GOOS.
In the same way, goos and goarch of (format_)overrides should be enum of posiible values of GOOS/GOARCH.
It is more useful for validating.

@suzuki-shunsuke
Copy link
Member

Thank you for your feedback.
It makes sense.

https://pkg.go.dev/runtime#pkg-constants

GOARCH is the running program's architecture target: one of 386, amd64, arm, s390x, and so on.
GOOS is the running program's operating system target: one of darwin, freebsd, linux, and so on.
To view possible combinations of GOOS and GOARCH, run "go tool dist list".

$ go tool dist list
aix/ppc64
android/386
android/amd64
android/arm
android/arm64
darwin/amd64
darwin/arm64
dragonfly/amd64
freebsd/386
freebsd/amd64
freebsd/arm
freebsd/arm64
illumos/amd64
ios/amd64
ios/arm64
js/wasm
linux/386
linux/amd64
linux/arm
linux/arm64
linux/mips
linux/mips64
linux/mips64le
linux/mipsle
linux/ppc64
linux/ppc64le
linux/riscv64
linux/s390x
netbsd/386
netbsd/amd64
netbsd/arm
netbsd/arm64
openbsd/386
openbsd/amd64
openbsd/arm
openbsd/arm64
openbsd/mips64
plan9/386
plan9/amd64
plan9/arm
solaris/amd64
windows/386
windows/amd64
windows/arm
windows/arm64

@suzuki-shunsuke
Copy link
Member

suzuki-shunsuke commented Apr 2, 2022

GOOS

$ go tool dist list | xargs dirname | sort -u
aix
android
darwin
dragonfly
freebsd
illumos
ios
js
linux
netbsd
openbsd
plan9
solaris
windows

GOARCH

$ go tool dist list | xargs basename | sort -u
386
amd64
arm
arm64
mips
mips64
mips64le
mipsle
ppc64
ppc64le
riscv64
s390x
wasm

@suzuki-shunsuke
Copy link
Member

suzuki-shunsuke commented Apr 2, 2022

#628

TODO: replacements's key

@suzuki-shunsuke
Copy link
Member

Test standard registry with JSON Schema. aquaproj/aqua-registry#2779

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants