lints: implement json.Unmarshaler for LintStatus.#297
Merged
zakird merged 1 commit intozmap:masterfrom Jul 30, 2019
Merged
Conversation
The `lints.LintStatus` type implements `json.Marshaler` to marshal to a human readable string (e.g. `"error"` instead of `6`). Without providing a compatible `json.Unmarshaler` implementation downstream users that marshal a `lints.LintStatus` to JSON will encounter an error when they try to unmarshal it due to a mixmatch of types (`int` vs `string`).
This was referenced Jul 30, 2019
zakird
approved these changes
Jul 30, 2019
Member
Author
|
@zakird Thanks for the quick 🔍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The
lints.LintStatustype implementsjson.Marshalerto marshal to a human readable string (e.g."error"instead of6). Without providing a compatiblejson.Unmarshalerimplementation downstream users that marshal alints.LintStatusto JSON will encounter an error when they try to unmarshal it due to a mismatch of types (intvsstring).Notably this is causing me problems because when I added pre-issuance linting to CFSSL I made the configuration value on the
cfssl.config.SigningProfiletype azlint.lints.LintStatusafter a suggestion by the maintainers. That seemed fine at the time but I later discovered in Boulder we expect to be able to round-trip our CFSSL config to/from JSON without error.Without the changes in this branch the de-serialization of the CFSSL config fails with an error like: