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

Add updatecli subcommand to generate json schema #587

Merged
merged 47 commits into from
Apr 6, 2022

Conversation

olblak
Copy link
Member

@olblak olblak commented Mar 15, 2022

Add updatecli subcommand to generate json schema

PR related to #540 but the current one focus on generating json schema while #540 test updatecli manifest with json schema

Fix #524

The current pullrequest introduces several requirements

  1. To retrieve field description, a comment must be one line maximum and me precede the field such
// Source defines parameters to retrieve an information from a specific location
type Source struct {
    // Title defines a source title
    title string // This is not a valid comment anymore
} 
  1. Configuration key must be lowercase to be valid, while we could use another convention, we can't mix them.
--- 
    sources:
        default: 
            scmID: # not valid
            scmid: # valid  

Test

To test this pullrequest, you can:

  1. Ensure that test in package github.com/pkg/core/jsonschema are passing.
make test
  1. You can try to generate an Updatecli jsonschema using the new jsonschema argument
go build -o bin/updatecli && ./bin/updatecli jsonschema --directory schema
  1. Finally, you can configure your IDE such as vscode to match files like ["/updatecli.di//.yaml","/updatecli.di//.yml","/updatecli.di//*.tpl"] with the jsonschema file that you generated locally such as "$HOME/Projects/Updatecli/updatecli/schema/config.json" as explained on vscode documentation

Additional Information

Tradeoff

/

Potential improvement

This pullrequest won't be usable as is as we need additional cleanup.
.1 Ensure that every field expected lowercase value. for example this tag must be removed

Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
@olblak olblak added the enhancement New feature or request label Mar 15, 2022
@olblak olblak marked this pull request as draft March 15, 2022 21:38
olblak and others added 17 commits March 22, 2022 20:36
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
@olblak olblak marked this pull request as ready for review March 29, 2022 09:39
olblak and others added 4 commits April 2, 2022 21:00
Signed-off-by: Olivier Vernin <olivier@vernin.me>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
@olblak olblak changed the title Generate Json schema based on updatecli code Add updatecli subcommand to generate json schema Apr 6, 2022
dduportal
dduportal previously approved these changes Apr 6, 2022
Copy link
Contributor

@dduportal dduportal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

cmd/jsonschema.go Outdated Show resolved Hide resolved
Signed-off-by: Olblak <me@olblak.com>
@olblak olblak merged commit 1acc3b6 into updatecli:main Apr 6, 2022
kind := strings.ToLower(rs.Kind)

if _, ok := GetResourceMapping()[kind]; !ok {
return nil, fmt.Errorf("⚠ Don't support resource kind: %v", rs.Kind)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded warning sign

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 this pull request may close these issues.

Feature Request: Add jsonschema to validate updatecli configuration
3 participants