Skip to content

Conversation

@rmohr
Copy link
Contributor

@rmohr rmohr commented Oct 11, 2016

Hi,

I wanted to map my uuid.UUID type from a field "UUID" to a string field called "UUID". Since this was not possible I added a feature to add custom converters for specific types.

I also added some unit tests. It seems to work but I want to write a little bit more tests and I have some documentation TODOs. Before I do the polishing I wanted to share it with you, to hear what you think about it.

@codecov-io
Copy link

codecov-io commented Oct 12, 2016

Current coverage is 97.94% (diff: 86.56%)

Merging #10 into master will decrease coverage by 2.05%

@@           master        #10   diff @@
========================================
  Files           2          2          
  Lines         396        438    +42   
  Methods         0          0          
  Messages        0          0          
  Branches        0          0          
========================================
+ Hits          396        429    +33   
- Misses          0          4     +4   
- Partials        0          5     +5   

Powered by Codecov. Last update 14db0d5...4368df9

@rmohr rmohr force-pushed the converter branch 2 times, most recently from 8294a15 to 0f7d612 Compare October 12, 2016 08:16
@rmohr
Copy link
Contributor Author

rmohr commented Oct 31, 2016

@jeevatkm is this of interest for you?

@jeevatkm
Copy link
Owner

I like this idea. I got stuck with my personal priorities right now. Thanks for your patience.

I will surely get back to this as soon as possible. Thanks.

@jeevatkm jeevatkm self-assigned this Dec 3, 2016
@jeevatkm
Copy link
Owner

jeevatkm commented Dec 3, 2016

@rmohr I have went through your implementation. Nice work 👍

Can you please delete IDE file .idea/vcs.xml from repo? If you would like to give final touch on this PR, please go ahead.

I'm planning to merge this PR into master and bumping version to 0.5. Release date I will let you know later.

@rmohr
Copy link
Contributor Author

rmohr commented Dec 5, 2016

@jeevatkm thx for looking int the PR. I removed the file and pushed two more commits on it. One makes sure that the custom converters work for slices and maps and the third one allows copyVal to propagate errors. I needed the error propagation to collect errors from converter invocations.

@jeevatkm
Copy link
Owner

@rmohr I'm planning to merge this PR.

I would like to confirm, did you get a chance to test it real-time?

Also can you please take care of git conflicts and squash all commits into one?

@rmohr
Copy link
Contributor Author

rmohr commented Dec 29, 2016

Herer are some references where we use it in kubevirt:

Mapping different structs and also UUID to string:
https://github.com/kubevirt/kubevirt/blob/master/pkg/api/v1/types.go#L52

Some generic mapping code based on this feature:
https://github.com/kubevirt/kubevirt/blob/master/pkg/util/mapper.go

Will rebase and squash everyting after the comming weekend.

@jeevatkm
Copy link
Owner

@rmohr Thank you for reference.

Can you please take care of model_test.go conflict and squash commits? Then I will straight away merge your PR.

If I do it, your commits will go under my user Id, I would like to keep yours.

By allowing to add converters for specific types, mapping mixed types is
possible.

AddConversion() allows to register callbacks for the conversion on a
very fine grained level.
@rmohr
Copy link
Contributor Author

rmohr commented Dec 29, 2016

@jeevatkm done

@jeevatkm
Copy link
Owner

Thank you @rmohr

@jeevatkm jeevatkm merged commit ebbcfe2 into jeevatkm:master Dec 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants