Use runtime.Copier instead of hardcoding api.Scheme

Allow other schemes to be supported by etcd_helper.go

runtime.Scheme.Copy() should be using the built in DeepCopy()
This commit is contained in:
Clayton Coleman
2015-06-17 14:59:12 -04:00
parent 8ebd896351
commit 6970dda54e
2 changed files with 8 additions and 8 deletions

View File

@@ -459,15 +459,12 @@ func (s *Scheme) DecodeInto(data []byte, obj Object) error {
}
// Copy does a deep copy of an API object. Useful mostly for tests.
// TODO(dbsmith): implement directly instead of via Encode/Decode
// TODO(claytonc): Copy cannot be used for objects which do not encode type information, such
// as lists of runtime.Objects
func (s *Scheme) Copy(obj Object) (Object, error) {
data, err := s.EncodeToVersion(obj, "")
func (s *Scheme) Copy(src Object) (Object, error) {
dst, err := s.raw.DeepCopy(src)
if err != nil {
return nil, err
}
return s.Decode(data)
return dst.(Object), nil
}
func (s *Scheme) CopyOrDie(obj Object) Object {