mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 23:47:50 +00:00
Add support for manually defined DeepCopy methods
In bringing back Clayton's PR piece-by-piece this was almost as easy to implement as his version, and is much more like what I think we should be doing. Specifically, any time which defines a .DeepCopy() method will have that method called preferentially. Otherwise we generate our own functions for deep-copying. This affected exactly one type - resource.Quantity. In applying this heuristic, several places in the generated code were simplified. To achieve this I had to convert types.Type.Methods from a slice to a map, which seems correct anyway (to do by-name lookups).
This commit is contained in:
@@ -33,6 +33,13 @@ type Time struct {
|
||||
time.Time `protobuf:"-"`
|
||||
}
|
||||
|
||||
// DeepCopy returns a deep-copy of the Time value. The underlying time.Time
|
||||
// type is effectively immutable in the time API, so it is safe to
|
||||
// copy-by-assign, despite the presence of (unexported) Pointer fields.
|
||||
func (t Time) DeepCopy() Time {
|
||||
return t
|
||||
}
|
||||
|
||||
// NewTime returns a wrapped instance of the provided time
|
||||
func NewTime(time time.Time) Time {
|
||||
return Time{time}
|
||||
|
||||
Reference in New Issue
Block a user