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

json.RawMessage Metadata #19

Merged
merged 7 commits into from
May 6, 2020
Merged

json.RawMessage Metadata #19

merged 7 commits into from
May 6, 2020

Conversation

patrick-ogrady
Copy link
Contributor

@patrick-ogrady patrick-ogrady commented May 6, 2020

Fixes #16 .

Motivation

To use the metadata fields extensively, it would be very useful to be able to encode/decode the field using the encoding/json library (or any other JSON encoding library). This would prevent the need to step through each key of the map[string]interface{} to populate a custom struct.

Solution

This PR changes all map[string]interface{} usage to json.RawMessage. Because json.RawMessage is not necessarily a JSON object (as required by 1.3.1 of the specification), this PR also adds asserts all json.RawMessage fields are JSON objects.

Other Improvements

  • Add a deterministic Hash function for comparing struct equality when containing json.RawMessage. reflect.DeepEqual does not always work if a struct contains json.RawMessage.
  • Return client configuration as Configuration instead of a list of items.
  • Add/Subtract Amount.Value utility function

Future PR

Find a cleaner way to create a deterministic hash of any struct in types.

@coveralls
Copy link

coveralls commented May 6, 2020

Pull Request Test Coverage Report for Build 869

  • 117 of 140 (83.57%) changed or added relevant lines in 8 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.8%) to 86.056%

Changes Missing Coverage Covered Lines Changed/Added Lines %
asserter/asserter.go 9 10 90.0%
asserter/block.go 6 8 75.0%
types/utils.go 79 99 79.8%
Totals Coverage Status
Change from base Build 813: -0.8%
Covered Lines: 648
Relevant Lines: 753

💛 - Coveralls

@patrick-ogrady patrick-ogrady changed the title Use json.RawMessage json.RawMessage Metadata May 6, 2020
@heimdall-asguard
Copy link

Review Error for annieke @ 2020-05-06 17:36:40 UTC
User failed mfa authentication, see go/mfa-help

@patrick-ogrady patrick-ogrady merged commit b8e6986 into master May 6, 2020
@patrick-ogrady patrick-ogrady deleted the patrick/json-rawMessage branch May 6, 2020 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Replace metadata request map type with json.RawMessage type
4 participants