-
Notifications
You must be signed in to change notification settings - Fork 171
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
refactor: remove magic strings in struct tags #2787
Conversation
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
Codecov ReportAttention: Patch coverage is
|
Signed-off-by: Austin Abro <AustinAbro321@gmail.com>
|
||
// JSONSchemaExtend extends the generated json schema during `zarf internal gen-config-schema` | ||
func (Variable) JSONSchemaExtend(schema *jsonschema.Schema) { | ||
kind, _ := schema.Properties.Get("type") |
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.
Is this ignoring an error 🤔
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.
It's ignoring the present flag but I'd rather have the code panic if it doesn't find something since this is only run on zarf internal gen-config-schema
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 can't change the signature to return an error, since this signature is necessary for this function to get called by the jsonschema package during schema creation
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.
We cannot be a production grade tool that panics.
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.
This function is only called during schema generation, zarf internal gen-config-schema
, and this would only panic if, during development, someone changed the json tag to not equal what is in the schema.Properties.Get
call.
Given that we don't have control over this function signature I think there's two options:
- return when the key isn't found - IMO this is worse because there won't be any signal from the CLI that something went wrong during schema generation. I'm fine with this though, it would happen rarely & it should be relatively obvious from the git diff that something went wrong.
- Keep panicing, maybe explicitly panic with a clear error message.
Closing this as we decided we don't like the fact that it's possible for jsonschemextend to panic |
Description
Fixes #2786
This should be merged after #2781
Checklist before merging