Commit f63f168b authored by Tim Hockin's avatar Tim Hockin

Comment and simplify a bit of conversion

There are ample opportunities to optimize and streamline here. For example, there's no reason to have a function to convert IntStr to IntStr. Removing the function does generate the right assignment, but it is unclear whether the registered function is needed or not. I opted to leave it alone for now. Another example is Convert_Slice_byte_To_Slice_byte, which just seems silly.
parent 291b51ec
...@@ -695,6 +695,11 @@ func (g *genConversion) doSlice(inType, outType *types.Type, sw *generator.Snipp ...@@ -695,6 +695,11 @@ func (g *genConversion) doSlice(inType, outType *types.Type, sw *generator.Snipp
funcName := g.funcNameTmpl(inType.Elem, outType.Elem) funcName := g.funcNameTmpl(inType.Elem, outType.Elem)
sw.Do(fmt.Sprintf("if err := %s(&(*in)[i], &(*out)[i], s); err != nil {\n", funcName), argsFromType(inType.Elem, outType.Elem)) sw.Do(fmt.Sprintf("if err := %s(&(*in)[i], &(*out)[i], s); err != nil {\n", funcName), argsFromType(inType.Elem, outType.Elem))
} else { } else {
// TODO: This triggers on v1.ObjectMeta <-> api.ObjectMeta and
// similar because neither package is the target package, and
// we really don't know which package will have the conversion
// function defined. This fires on basically every object
// conversion outside of pkg/api/v1.
sw.Do("// TODO: Inefficient conversion - can we improve it?\n", nil) sw.Do("// TODO: Inefficient conversion - can we improve it?\n", nil)
sw.Do("if err := s.Convert(&(*in)[i], &(*out)[i], 0); err != nil {\n", nil) sw.Do("if err := s.Convert(&(*in)[i], &(*out)[i], 0); err != nil {\n", nil)
} }
......
...@@ -100,15 +100,12 @@ func Convert_unversioned_TypeMeta_To_unversioned_TypeMeta(in, out *unversioned.T ...@@ -100,15 +100,12 @@ func Convert_unversioned_TypeMeta_To_unversioned_TypeMeta(in, out *unversioned.T
} }
func Convert_unversioned_ListMeta_To_unversioned_ListMeta(in, out *unversioned.ListMeta, s conversion.Scope) error { func Convert_unversioned_ListMeta_To_unversioned_ListMeta(in, out *unversioned.ListMeta, s conversion.Scope) error {
out.ResourceVersion = in.ResourceVersion *out = *in
out.SelfLink = in.SelfLink
return nil return nil
} }
func Convert_intstr_IntOrString_To_intstr_IntOrString(in, out *intstr.IntOrString, s conversion.Scope) error { func Convert_intstr_IntOrString_To_intstr_IntOrString(in, out *intstr.IntOrString, s conversion.Scope) error {
out.Type = in.Type *out = *in
out.IntVal = in.IntVal
out.StrVal = in.StrVal
return nil return nil
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment