K8SPG-907 Fix panic on JSON marshal if PITRestoreDateTime is not a pointer #1368
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem:
Closes #1356
There's a panic when marshalling the
PITRestoreDateTimestruct to JSON if the variable isn't a pointer. See the issue for a full breakdown.Cause:
The
MarshalJSONfunction is on a pointer receiver sojson.Marshalskips over it and calls theMarshalTextfunction onmetav1.Timeinstead which panics on a nil receiver.Solution:
Moves
MarshalJSONonto a non-pointer receiver which Go will use for both non-pointer and pointer variables. I also added unit tests for this marshalling. I did not look at any other objects in the package to see if they have a similar problem.CHECKLIST
Jira
No JIRA cards were created or managed, just the github issue referenced above
Tests
Config/Logging/Testability
I don't believe any of these apply to this PR