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

Fix unmarshal for claim results #283

Merged
merged 1 commit into from
May 4, 2022
Merged

Conversation

carolynvs
Copy link
Contributor

Originally we were defining output metadata as a map[string]interface{}, and then just casting as needed any output metadata values to map[string]string. This worked fine when setting and then immediately checking values, because we set the metadata correctly to begin with.

When a result is unmarshaled though, the json decoder is unmarshaling the output metadata values as map[string]interface{} and this prevented the helper methods for reading the metadata from working.

I've updated the OutputMetadata type to be map[string]map[string]string so that we aren't relying on casts working, and to give the json decoder the hint it needs to initialize the types correctly.

Originally we were defining output metadata as a map[string]interface{},
and then just casting as needed any output metadata values to
map[string]string. This worked fine when setting and then immediately
checking values, because we set the metadata correctly to begin with.

When a result is unmarshaled though, the json decoder is unmarshaling
the output metadata values as map[string]interface{} and this prevented
the helper methods for reading the metadata from working.

I've updated the OutputMetadata type to be map[string]map[string]string
so that we aren't relying on casts working, and to give the json decoder
the hint it needs to initialize the types correctly.

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
@carolynvs carolynvs marked this pull request as ready for review May 3, 2022 21:21
@carolynvs carolynvs requested a review from vdice May 3, 2022 21:21
@carolynvs carolynvs merged commit 89f7156 into main May 4, 2022
@carolynvs carolynvs deleted the retrieve-output-metadata branch May 4, 2022 13:50
carolynvs added a commit to carolynvs/porter that referenced this pull request May 4, 2022
Pin to cnab-go v0.23.2 with a fix for reading output metadata from a
claim result after it has been unmarshaled from json.

cnabio/cnab-go#283

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants