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

Embed json schema in the binary #34

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Embed json schema in the binary #34

wants to merge 9 commits into from

Conversation

thedae
Copy link
Member

@thedae thedae commented Dec 19, 2024

Added new ways to lint the config file

Embed schema

Use cmd.NewCheckCmd(schema) when building the root command to embed a json schema in string format.

Spawn the krakend check command with a -n|--lint-no-network lint against it

Custom schema

Spawn the krakend check command with a -s|--lint-schema [url|path] to lint against a custom URL or local file

⚠️ --lint, --lint-no-network and --lint-schema flags are mutually exclusive

ℹ️ This PR bumps jsonschema dependency to v6 and cobra to v1.8.1

Copy link
Contributor

@dhontecillas dhontecillas left a comment

Choose a reason for hiding this comment

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

Looks good to me. I've just put a couple of comments, but up to you to modify something or not :)

check.go Outdated
Comment on lines 196 to 200
if err != nil {
return nil, err
}

return body, resp.Body.Close()
Copy link
Contributor

Choose a reason for hiding this comment

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

I am not sure about this, but either we add a resp.Body.Close() before line 197, or we do not need to call resp.Body.Close() in line 200, no ? Does jsonschema.UnmarshalJSON call Close itself?

Copy link
Member Author

Choose a reason for hiding this comment

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

UnmarshalJSON does not close the reader, but it's true that we should close it if there's an error

cmd.go Outdated
Cmd *cobra.Command
Flags []FlagBuilder
once *sync.Once
Constraints []ContraintBuilder
Copy link
Contributor

Choose a reason for hiding this comment

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

nittypicky: ContraintBuilder is missing an s -> ConstraintBuilder.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ups

@thedae thedae changed the title [WIP] Embed json schema in the binary Embed json schema in the binary Dec 20, 2024
@thedae thedae marked this pull request as ready for review December 20, 2024 16:18
@thedae thedae requested review from kpacha and taik0 December 20, 2024 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants