-
Notifications
You must be signed in to change notification settings - Fork 103
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
fix: use ctx.Codec when marshaling for generated batch json in CLI #514
Conversation
@@ -16,7 +16,7 @@ var reLocation = regexp.MustCompile(`^([A-Z]{2})(?:-([A-Z0-9]{1,3})(?: ([a-zA-Z0 | |||
func validateLocation(location string) error { | |||
matches := reLocation.FindStringSubmatch(location) | |||
if matches == nil { | |||
return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "Invalid retirement location: %s.\nLocation should have format <country-code>[-<region-code>[ <postal-code>]].\n", location) | |||
return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "Invalid location: %s.\nLocation should have format <country-code>[-<region-code>[ <postal-code>]].\n", location) |
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 error gets thrown sometimes for an invalid project_location, so I updated this to make it generic to project and/or retirement location.
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.
looks like a few test cases need to be updated for this
"start_date": "1990-01-01", | ||
"end_date": "1995-10-31", | ||
"project_location": "AB-CDE FG1 345", | ||
} |
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.
the Long
help text argument doesn't have access to the *cobra.Command
, so its not possible to retrieve the sdkcontext and the JSON marshaler... So I hardcoded an example JSON help text here.
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.
Looks great, thanks @clevinson
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.
lgtm
Description
When reviewing #513 I noticed that we weren't using the ctx.Codec's JSON marshaler for generating batch JSON. This is a pretty minor thing, but I figured it's good practice for us to use the same serializer as we use across other parts of the SDK, especially as we may be making use of jsonpb's configuration to serialize using the original field names (independent of explicit JSON field names defined in the proto file).
I could have written this up in an issue, but figured it'd be easier to just put in a fix. Happy to re-evaluate this decision if I'm missing some reason why we were using the standard
json
package before.Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change