go-openapi / strfmt

openapi toolkit common string formats
Apache License 2.0
102 stars 62 forks source link

Add DeepCopy and DeepCopyInto methods to all types #44

Closed vadorovsky closed 5 years ago

vadorovsky commented 5 years ago

Kubernetes has a project called code-generator[0] which generates DeepCopy methods for API models.

Cilium[1] is using code-generator on top of models generated by go-swagger, to allow deep copying of API models. Hovewer, code-generator assumes that every type which is not a basic type in Golang, needs to have its own DeepCopy and DeepCopyIn methods. It includes also type extensions which are built on top of basic types just to add methods.

Currently, if code-generator is executed on go-swagger API models which use types from strfmt, generated DeepCopy methods fail, because strfmt types do not implement DeepCopy.

This change adds implementations of DeepCopy and DeepCopyInto which will allow to use go-generator together with go-swagger and strfmt.

[0] https://github.com/kubernetes/code-generator [1] https://github.com/cilium/cilium

Signed-off-by: Michal Rostecki mrostecki@suse.de

codecov[bot] commented 5 years ago

Codecov Report

Merging #44 into master will increase coverage by 1.56%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #44      +/-   ##
==========================================
+ Coverage   87.69%   89.25%   +1.56%     
==========================================
  Files          10       10              
  Lines        1422     1629     +207     
==========================================
+ Hits         1247     1454     +207     
  Misses        146      146              
  Partials       29       29
Impacted Files Coverage Δ
date.go 95.89% <100%> (+0.57%) :arrow_up:
bson.go 77.58% <100%> (+4.11%) :arrow_up:
duration.go 96.47% <100%> (+0.41%) :arrow_up:
time.go 96.7% <100%> (+0.36%) :arrow_up:
default.go 93.61% <100%> (+1.26%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 870f786...13e5106. Read the comment docs.