mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 07:20:13 +00:00
Merge pull request #19047 from smarterclayton/avoid_reflection_during_convert
Auto commit by PR queue bot
This commit is contained in:
commit
cf359053f0
@ -118,7 +118,10 @@ func main() {
|
||||
|
||||
b, err := imports.Process("", data.Bytes(), nil)
|
||||
if err != nil {
|
||||
glog.Fatalf("Error while update imports: %v", err)
|
||||
for i, s := range bytes.Split(data.Bytes(), []byte("\n")) {
|
||||
glog.Infof("%d:\t%s", i, s)
|
||||
}
|
||||
glog.Fatalf("Error while update imports: %v\n", err)
|
||||
}
|
||||
if _, err := funcOut.Write(b); err != nil {
|
||||
glog.Fatalf("Error while writing out the resulting file: %v", err)
|
||||
|
@ -23,6 +23,7 @@ import (
|
||||
"k8s.io/kubernetes/pkg/fields"
|
||||
"k8s.io/kubernetes/pkg/labels"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
"k8s.io/kubernetes/pkg/util/intstr"
|
||||
)
|
||||
|
||||
// Codec is the identity codec for this package - it can only convert itself
|
||||
@ -41,45 +42,75 @@ func init() {
|
||||
},
|
||||
)
|
||||
Scheme.AddConversionFuncs(
|
||||
func(in *unversioned.Time, out *unversioned.Time, s conversion.Scope) error {
|
||||
// Cannot deep copy these, because time.Time has unexported fields.
|
||||
*out = *in
|
||||
return nil
|
||||
},
|
||||
func(in *string, out *labels.Selector, s conversion.Scope) error {
|
||||
selector, err := labels.Parse(*in)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*out = selector
|
||||
return nil
|
||||
},
|
||||
func(in *string, out *fields.Selector, s conversion.Scope) error {
|
||||
selector, err := fields.ParseSelector(*in)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*out = selector
|
||||
return nil
|
||||
},
|
||||
func(in *labels.Selector, out *string, s conversion.Scope) error {
|
||||
if *in == nil {
|
||||
return nil
|
||||
}
|
||||
*out = (*in).String()
|
||||
return nil
|
||||
},
|
||||
func(in *fields.Selector, out *string, s conversion.Scope) error {
|
||||
if *in == nil {
|
||||
return nil
|
||||
}
|
||||
*out = (*in).String()
|
||||
return nil
|
||||
},
|
||||
func(in *resource.Quantity, out *resource.Quantity, s conversion.Scope) error {
|
||||
// Cannot deep copy these, because inf.Dec has unexported fields.
|
||||
*out = *in.Copy()
|
||||
return nil
|
||||
},
|
||||
Convert_unversioned_TypeMeta_To_unversioned_TypeMeta,
|
||||
Convert_unversioned_ListMeta_To_unversioned_ListMeta,
|
||||
Convert_intstr_IntOrString_To_intstr_IntOrString,
|
||||
Convert_unversioned_Time_To_unversioned_Time,
|
||||
Convert_string_To_labels_Selector,
|
||||
Convert_string_To_fields_Selector,
|
||||
Convert_labels_Selector_To_string,
|
||||
Convert_fields_Selector_To_string,
|
||||
Convert_resource_Quantity_To_resource_Quantity,
|
||||
)
|
||||
}
|
||||
|
||||
func Convert_unversioned_TypeMeta_To_unversioned_TypeMeta(in, out *unversioned.TypeMeta, s conversion.Scope) error {
|
||||
// These values are explicitly not copied
|
||||
//out.APIVersion = in.APIVersion
|
||||
//out.Kind = in.Kind
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_unversioned_ListMeta_To_unversioned_ListMeta(in, out *unversioned.ListMeta, s conversion.Scope) error {
|
||||
out.ResourceVersion = in.ResourceVersion
|
||||
out.SelfLink = in.SelfLink
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_intstr_IntOrString_To_intstr_IntOrString(in, out *intstr.IntOrString, s conversion.Scope) error {
|
||||
out.Type = in.Type
|
||||
out.IntVal = in.IntVal
|
||||
out.StrVal = in.StrVal
|
||||
return nil
|
||||
}
|
||||
|
||||
func Convert_unversioned_Time_To_unversioned_Time(in *unversioned.Time, out *unversioned.Time, s conversion.Scope) error {
|
||||
// Cannot deep copy these, because time.Time has unexported fields.
|
||||
*out = *in
|
||||
return nil
|
||||
}
|
||||
func Convert_string_To_labels_Selector(in *string, out *labels.Selector, s conversion.Scope) error {
|
||||
selector, err := labels.Parse(*in)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*out = selector
|
||||
return nil
|
||||
}
|
||||
func Convert_string_To_fields_Selector(in *string, out *fields.Selector, s conversion.Scope) error {
|
||||
selector, err := fields.ParseSelector(*in)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*out = selector
|
||||
return nil
|
||||
}
|
||||
func Convert_labels_Selector_To_string(in *labels.Selector, out *string, s conversion.Scope) error {
|
||||
if *in == nil {
|
||||
return nil
|
||||
}
|
||||
*out = (*in).String()
|
||||
return nil
|
||||
}
|
||||
func Convert_fields_Selector_To_string(in *fields.Selector, out *string, s conversion.Scope) error {
|
||||
if *in == nil {
|
||||
return nil
|
||||
}
|
||||
*out = (*in).String()
|
||||
return nil
|
||||
}
|
||||
func Convert_resource_Quantity_To_resource_Quantity(in *resource.Quantity, out *resource.Quantity, s conversion.Scope) error {
|
||||
// Cannot deep copy these, because inf.Dec has unexported fields.
|
||||
*out = *in.Copy()
|
||||
return nil
|
||||
}
|
||||
|
@ -36,14 +36,14 @@ const (
|
||||
func addConversionFuncs(scheme *runtime.Scheme) {
|
||||
// Add non-generated conversion functions
|
||||
err := scheme.AddConversionFuncs(
|
||||
convert_api_Pod_To_v1_Pod,
|
||||
convert_api_PodSpec_To_v1_PodSpec,
|
||||
convert_api_ReplicationControllerSpec_To_v1_ReplicationControllerSpec,
|
||||
convert_api_ServiceSpec_To_v1_ServiceSpec,
|
||||
convert_v1_Pod_To_api_Pod,
|
||||
convert_v1_PodSpec_To_api_PodSpec,
|
||||
convert_v1_ReplicationControllerSpec_To_api_ReplicationControllerSpec,
|
||||
convert_v1_ServiceSpec_To_api_ServiceSpec,
|
||||
Convert_api_Pod_To_v1_Pod,
|
||||
Convert_api_PodSpec_To_v1_PodSpec,
|
||||
Convert_api_ReplicationControllerSpec_To_v1_ReplicationControllerSpec,
|
||||
Convert_api_ServiceSpec_To_v1_ServiceSpec,
|
||||
Convert_v1_Pod_To_api_Pod,
|
||||
Convert_v1_PodSpec_To_api_PodSpec,
|
||||
Convert_v1_ReplicationControllerSpec_To_api_ReplicationControllerSpec,
|
||||
Convert_v1_ServiceSpec_To_api_ServiceSpec,
|
||||
)
|
||||
if err != nil {
|
||||
// If one of the conversion functions is malformed, detect it immediately.
|
||||
@ -200,7 +200,7 @@ func addConversionFuncs(scheme *runtime.Scheme) {
|
||||
}
|
||||
}
|
||||
|
||||
func convert_api_ReplicationControllerSpec_To_v1_ReplicationControllerSpec(in *api.ReplicationControllerSpec, out *ReplicationControllerSpec, s conversion.Scope) error {
|
||||
func Convert_api_ReplicationControllerSpec_To_v1_ReplicationControllerSpec(in *api.ReplicationControllerSpec, out *ReplicationControllerSpec, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*api.ReplicationControllerSpec))(in)
|
||||
}
|
||||
@ -216,7 +216,7 @@ func convert_api_ReplicationControllerSpec_To_v1_ReplicationControllerSpec(in *a
|
||||
}
|
||||
//if in.TemplateRef != nil {
|
||||
// out.TemplateRef = new(ObjectReference)
|
||||
// if err := convert_api_ObjectReference_To_v1_ObjectReference(in.TemplateRef, out.TemplateRef, s); err != nil {
|
||||
// if err := Convert_api_ObjectReference_To_v1_ObjectReference(in.TemplateRef, out.TemplateRef, s); err != nil {
|
||||
// return err
|
||||
// }
|
||||
//} else {
|
||||
@ -224,7 +224,7 @@ func convert_api_ReplicationControllerSpec_To_v1_ReplicationControllerSpec(in *a
|
||||
//}
|
||||
if in.Template != nil {
|
||||
out.Template = new(PodTemplateSpec)
|
||||
if err := convert_api_PodTemplateSpec_To_v1_PodTemplateSpec(in.Template, out.Template, s); err != nil {
|
||||
if err := Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec(in.Template, out.Template, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
@ -233,7 +233,7 @@ func convert_api_ReplicationControllerSpec_To_v1_ReplicationControllerSpec(in *a
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_v1_ReplicationControllerSpec_To_api_ReplicationControllerSpec(in *ReplicationControllerSpec, out *api.ReplicationControllerSpec, s conversion.Scope) error {
|
||||
func Convert_v1_ReplicationControllerSpec_To_api_ReplicationControllerSpec(in *ReplicationControllerSpec, out *api.ReplicationControllerSpec, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*ReplicationControllerSpec))(in)
|
||||
}
|
||||
@ -248,7 +248,7 @@ func convert_v1_ReplicationControllerSpec_To_api_ReplicationControllerSpec(in *R
|
||||
}
|
||||
//if in.TemplateRef != nil {
|
||||
// out.TemplateRef = new(api.ObjectReference)
|
||||
// if err := convert_v1_ObjectReference_To_api_ObjectReference(in.TemplateRef, out.TemplateRef, s); err != nil {
|
||||
// if err := Convert_v1_ObjectReference_To_api_ObjectReference(in.TemplateRef, out.TemplateRef, s); err != nil {
|
||||
// return err
|
||||
// }
|
||||
//} else {
|
||||
@ -256,7 +256,7 @@ func convert_v1_ReplicationControllerSpec_To_api_ReplicationControllerSpec(in *R
|
||||
//}
|
||||
if in.Template != nil {
|
||||
out.Template = new(api.PodTemplateSpec)
|
||||
if err := convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(in.Template, out.Template, s); err != nil {
|
||||
if err := Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(in.Template, out.Template, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
@ -267,14 +267,14 @@ func convert_v1_ReplicationControllerSpec_To_api_ReplicationControllerSpec(in *R
|
||||
|
||||
// The following two PodSpec conversions are done here to support ServiceAccount
|
||||
// as an alias for ServiceAccountName.
|
||||
func convert_api_PodSpec_To_v1_PodSpec(in *api.PodSpec, out *PodSpec, s conversion.Scope) error {
|
||||
func Convert_api_PodSpec_To_v1_PodSpec(in *api.PodSpec, out *PodSpec, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*api.PodSpec))(in)
|
||||
}
|
||||
if in.Volumes != nil {
|
||||
out.Volumes = make([]Volume, len(in.Volumes))
|
||||
for i := range in.Volumes {
|
||||
if err := convert_api_Volume_To_v1_Volume(&in.Volumes[i], &out.Volumes[i], s); err != nil {
|
||||
if err := Convert_api_Volume_To_v1_Volume(&in.Volumes[i], &out.Volumes[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -284,7 +284,7 @@ func convert_api_PodSpec_To_v1_PodSpec(in *api.PodSpec, out *PodSpec, s conversi
|
||||
if in.Containers != nil {
|
||||
out.Containers = make([]Container, len(in.Containers))
|
||||
for i := range in.Containers {
|
||||
if err := convert_api_Container_To_v1_Container(&in.Containers[i], &out.Containers[i], s); err != nil {
|
||||
if err := Convert_api_Container_To_v1_Container(&in.Containers[i], &out.Containers[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -319,7 +319,7 @@ func convert_api_PodSpec_To_v1_PodSpec(in *api.PodSpec, out *PodSpec, s conversi
|
||||
out.NodeName = in.NodeName
|
||||
if in.SecurityContext != nil {
|
||||
out.SecurityContext = new(PodSecurityContext)
|
||||
if err := convert_api_PodSecurityContext_To_v1_PodSecurityContext(in.SecurityContext, out.SecurityContext, s); err != nil {
|
||||
if err := Convert_api_PodSecurityContext_To_v1_PodSecurityContext(in.SecurityContext, out.SecurityContext, s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -332,7 +332,7 @@ func convert_api_PodSpec_To_v1_PodSpec(in *api.PodSpec, out *PodSpec, s conversi
|
||||
if in.ImagePullSecrets != nil {
|
||||
out.ImagePullSecrets = make([]LocalObjectReference, len(in.ImagePullSecrets))
|
||||
for i := range in.ImagePullSecrets {
|
||||
if err := convert_api_LocalObjectReference_To_v1_LocalObjectReference(&in.ImagePullSecrets[i], &out.ImagePullSecrets[i], s); err != nil {
|
||||
if err := Convert_api_LocalObjectReference_To_v1_LocalObjectReference(&in.ImagePullSecrets[i], &out.ImagePullSecrets[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -342,14 +342,14 @@ func convert_api_PodSpec_To_v1_PodSpec(in *api.PodSpec, out *PodSpec, s conversi
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_v1_PodSpec_To_api_PodSpec(in *PodSpec, out *api.PodSpec, s conversion.Scope) error {
|
||||
func Convert_v1_PodSpec_To_api_PodSpec(in *PodSpec, out *api.PodSpec, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*PodSpec))(in)
|
||||
}
|
||||
if in.Volumes != nil {
|
||||
out.Volumes = make([]api.Volume, len(in.Volumes))
|
||||
for i := range in.Volumes {
|
||||
if err := convert_v1_Volume_To_api_Volume(&in.Volumes[i], &out.Volumes[i], s); err != nil {
|
||||
if err := Convert_v1_Volume_To_api_Volume(&in.Volumes[i], &out.Volumes[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -359,7 +359,7 @@ func convert_v1_PodSpec_To_api_PodSpec(in *PodSpec, out *api.PodSpec, s conversi
|
||||
if in.Containers != nil {
|
||||
out.Containers = make([]api.Container, len(in.Containers))
|
||||
for i := range in.Containers {
|
||||
if err := convert_v1_Container_To_api_Container(&in.Containers[i], &out.Containers[i], s); err != nil {
|
||||
if err := Convert_v1_Container_To_api_Container(&in.Containers[i], &out.Containers[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -397,7 +397,7 @@ func convert_v1_PodSpec_To_api_PodSpec(in *PodSpec, out *api.PodSpec, s conversi
|
||||
out.NodeName = in.NodeName
|
||||
if in.SecurityContext != nil {
|
||||
out.SecurityContext = new(api.PodSecurityContext)
|
||||
if err := convert_v1_PodSecurityContext_To_api_PodSecurityContext(in.SecurityContext, out.SecurityContext, s); err != nil {
|
||||
if err := Convert_v1_PodSecurityContext_To_api_PodSecurityContext(in.SecurityContext, out.SecurityContext, s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -413,7 +413,7 @@ func convert_v1_PodSpec_To_api_PodSpec(in *PodSpec, out *api.PodSpec, s conversi
|
||||
if in.ImagePullSecrets != nil {
|
||||
out.ImagePullSecrets = make([]api.LocalObjectReference, len(in.ImagePullSecrets))
|
||||
for i := range in.ImagePullSecrets {
|
||||
if err := convert_v1_LocalObjectReference_To_api_LocalObjectReference(&in.ImagePullSecrets[i], &out.ImagePullSecrets[i], s); err != nil {
|
||||
if err := Convert_v1_LocalObjectReference_To_api_LocalObjectReference(&in.ImagePullSecrets[i], &out.ImagePullSecrets[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -424,8 +424,8 @@ func convert_v1_PodSpec_To_api_PodSpec(in *PodSpec, out *api.PodSpec, s conversi
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_api_Pod_To_v1_Pod(in *api.Pod, out *Pod, s conversion.Scope) error {
|
||||
if err := autoconvert_api_Pod_To_v1_Pod(in, out, s); err != nil {
|
||||
func Convert_api_Pod_To_v1_Pod(in *api.Pod, out *Pod, s conversion.Scope) error {
|
||||
if err := autoConvert_api_Pod_To_v1_Pod(in, out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
// We need to reset certain fields for mirror pods from pre-v1.1 kubelet
|
||||
@ -442,12 +442,12 @@ func convert_api_Pod_To_v1_Pod(in *api.Pod, out *Pod, s conversion.Scope) error
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_v1_Pod_To_api_Pod(in *Pod, out *api.Pod, s conversion.Scope) error {
|
||||
return autoconvert_v1_Pod_To_api_Pod(in, out, s)
|
||||
func Convert_v1_Pod_To_api_Pod(in *Pod, out *api.Pod, s conversion.Scope) error {
|
||||
return autoConvert_v1_Pod_To_api_Pod(in, out, s)
|
||||
}
|
||||
|
||||
func convert_api_ServiceSpec_To_v1_ServiceSpec(in *api.ServiceSpec, out *ServiceSpec, s conversion.Scope) error {
|
||||
if err := autoconvert_api_ServiceSpec_To_v1_ServiceSpec(in, out, s); err != nil {
|
||||
func Convert_api_ServiceSpec_To_v1_ServiceSpec(in *api.ServiceSpec, out *ServiceSpec, s conversion.Scope) error {
|
||||
if err := autoConvert_api_ServiceSpec_To_v1_ServiceSpec(in, out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
// Publish both externalIPs and deprecatedPublicIPs fields in v1.
|
||||
@ -457,8 +457,8 @@ func convert_api_ServiceSpec_To_v1_ServiceSpec(in *api.ServiceSpec, out *Service
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_v1_ServiceSpec_To_api_ServiceSpec(in *ServiceSpec, out *api.ServiceSpec, s conversion.Scope) error {
|
||||
if err := autoconvert_v1_ServiceSpec_To_api_ServiceSpec(in, out, s); err != nil {
|
||||
func Convert_v1_ServiceSpec_To_api_ServiceSpec(in *ServiceSpec, out *api.ServiceSpec, s conversion.Scope) error {
|
||||
if err := autoConvert_v1_ServiceSpec_To_api_ServiceSpec(in, out, s); err != nil {
|
||||
return err
|
||||
}
|
||||
// Prefer the legacy deprecatedPublicIPs field, if provided.
|
||||
@ -471,7 +471,7 @@ func convert_v1_ServiceSpec_To_api_ServiceSpec(in *ServiceSpec, out *api.Service
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_api_PodSecurityContext_To_v1_PodSecurityContext(in *api.PodSecurityContext, out *PodSecurityContext, s conversion.Scope) error {
|
||||
func Convert_api_PodSecurityContext_To_v1_PodSecurityContext(in *api.PodSecurityContext, out *PodSecurityContext, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*api.PodSecurityContext))(in)
|
||||
}
|
||||
@ -479,7 +479,7 @@ func convert_api_PodSecurityContext_To_v1_PodSecurityContext(in *api.PodSecurity
|
||||
out.SupplementalGroups = in.SupplementalGroups
|
||||
if in.SELinuxOptions != nil {
|
||||
out.SELinuxOptions = new(SELinuxOptions)
|
||||
if err := convert_api_SELinuxOptions_To_v1_SELinuxOptions(in.SELinuxOptions, out.SELinuxOptions, s); err != nil {
|
||||
if err := Convert_api_SELinuxOptions_To_v1_SELinuxOptions(in.SELinuxOptions, out.SELinuxOptions, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
@ -506,7 +506,7 @@ func convert_api_PodSecurityContext_To_v1_PodSecurityContext(in *api.PodSecurity
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_v1_PodSecurityContext_To_api_PodSecurityContext(in *PodSecurityContext, out *api.PodSecurityContext, s conversion.Scope) error {
|
||||
func Convert_v1_PodSecurityContext_To_api_PodSecurityContext(in *PodSecurityContext, out *api.PodSecurityContext, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*PodSecurityContext))(in)
|
||||
}
|
||||
@ -514,7 +514,7 @@ func convert_v1_PodSecurityContext_To_api_PodSecurityContext(in *PodSecurityCont
|
||||
out.SupplementalGroups = in.SupplementalGroups
|
||||
if in.SELinuxOptions != nil {
|
||||
out.SELinuxOptions = new(api.SELinuxOptions)
|
||||
if err := convert_v1_SELinuxOptions_To_api_SELinuxOptions(in.SELinuxOptions, out.SELinuxOptions, s); err != nil {
|
||||
if err := Convert_v1_SELinuxOptions_To_api_SELinuxOptions(in.SELinuxOptions, out.SELinuxOptions, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -26,11 +26,11 @@ import (
|
||||
conversion "k8s.io/kubernetes/pkg/conversion"
|
||||
)
|
||||
|
||||
func autoconvert_componentconfig_KubeProxyConfiguration_To_v1alpha1_KubeProxyConfiguration(in *componentconfig.KubeProxyConfiguration, out *KubeProxyConfiguration, s conversion.Scope) error {
|
||||
func autoConvert_componentconfig_KubeProxyConfiguration_To_v1alpha1_KubeProxyConfiguration(in *componentconfig.KubeProxyConfiguration, out *KubeProxyConfiguration, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*componentconfig.KubeProxyConfiguration))(in)
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
if err := api.Convert_unversioned_TypeMeta_To_unversioned_TypeMeta(&in.TypeMeta, &out.TypeMeta, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.BindAddress = in.BindAddress
|
||||
@ -57,15 +57,15 @@ func autoconvert_componentconfig_KubeProxyConfiguration_To_v1alpha1_KubeProxyCon
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_componentconfig_KubeProxyConfiguration_To_v1alpha1_KubeProxyConfiguration(in *componentconfig.KubeProxyConfiguration, out *KubeProxyConfiguration, s conversion.Scope) error {
|
||||
return autoconvert_componentconfig_KubeProxyConfiguration_To_v1alpha1_KubeProxyConfiguration(in, out, s)
|
||||
func Convert_componentconfig_KubeProxyConfiguration_To_v1alpha1_KubeProxyConfiguration(in *componentconfig.KubeProxyConfiguration, out *KubeProxyConfiguration, s conversion.Scope) error {
|
||||
return autoConvert_componentconfig_KubeProxyConfiguration_To_v1alpha1_KubeProxyConfiguration(in, out, s)
|
||||
}
|
||||
|
||||
func autoconvert_v1alpha1_KubeProxyConfiguration_To_componentconfig_KubeProxyConfiguration(in *KubeProxyConfiguration, out *componentconfig.KubeProxyConfiguration, s conversion.Scope) error {
|
||||
func autoConvert_v1alpha1_KubeProxyConfiguration_To_componentconfig_KubeProxyConfiguration(in *KubeProxyConfiguration, out *componentconfig.KubeProxyConfiguration, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*KubeProxyConfiguration))(in)
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
if err := api.Convert_unversioned_TypeMeta_To_unversioned_TypeMeta(&in.TypeMeta, &out.TypeMeta, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.BindAddress = in.BindAddress
|
||||
@ -92,14 +92,14 @@ func autoconvert_v1alpha1_KubeProxyConfiguration_To_componentconfig_KubeProxyCon
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_v1alpha1_KubeProxyConfiguration_To_componentconfig_KubeProxyConfiguration(in *KubeProxyConfiguration, out *componentconfig.KubeProxyConfiguration, s conversion.Scope) error {
|
||||
return autoconvert_v1alpha1_KubeProxyConfiguration_To_componentconfig_KubeProxyConfiguration(in, out, s)
|
||||
func Convert_v1alpha1_KubeProxyConfiguration_To_componentconfig_KubeProxyConfiguration(in *KubeProxyConfiguration, out *componentconfig.KubeProxyConfiguration, s conversion.Scope) error {
|
||||
return autoConvert_v1alpha1_KubeProxyConfiguration_To_componentconfig_KubeProxyConfiguration(in, out, s)
|
||||
}
|
||||
|
||||
func init() {
|
||||
err := api.Scheme.AddGeneratedConversionFuncs(
|
||||
autoconvert_componentconfig_KubeProxyConfiguration_To_v1alpha1_KubeProxyConfiguration,
|
||||
autoconvert_v1alpha1_KubeProxyConfiguration_To_componentconfig_KubeProxyConfiguration,
|
||||
autoConvert_componentconfig_KubeProxyConfiguration_To_v1alpha1_KubeProxyConfiguration,
|
||||
autoConvert_v1alpha1_KubeProxyConfiguration_To_componentconfig_KubeProxyConfiguration,
|
||||
)
|
||||
if err != nil {
|
||||
// If one of the conversion functions is malformed, detect it immediately.
|
||||
|
@ -30,14 +30,14 @@ import (
|
||||
func addConversionFuncs(scheme *runtime.Scheme) {
|
||||
// Add non-generated conversion functions
|
||||
err := scheme.AddConversionFuncs(
|
||||
convert_api_PodSpec_To_v1_PodSpec,
|
||||
convert_v1_PodSpec_To_api_PodSpec,
|
||||
convert_extensions_DeploymentSpec_To_v1beta1_DeploymentSpec,
|
||||
convert_v1beta1_DeploymentSpec_To_extensions_DeploymentSpec,
|
||||
convert_extensions_DeploymentStrategy_To_v1beta1_DeploymentStrategy,
|
||||
convert_v1beta1_DeploymentStrategy_To_extensions_DeploymentStrategy,
|
||||
convert_extensions_RollingUpdateDeployment_To_v1beta1_RollingUpdateDeployment,
|
||||
convert_v1beta1_RollingUpdateDeployment_To_extensions_RollingUpdateDeployment,
|
||||
Convert_api_PodSpec_To_v1_PodSpec,
|
||||
Convert_v1_PodSpec_To_api_PodSpec,
|
||||
Convert_extensions_DeploymentSpec_To_v1beta1_DeploymentSpec,
|
||||
Convert_v1beta1_DeploymentSpec_To_extensions_DeploymentSpec,
|
||||
Convert_extensions_DeploymentStrategy_To_v1beta1_DeploymentStrategy,
|
||||
Convert_v1beta1_DeploymentStrategy_To_extensions_DeploymentStrategy,
|
||||
Convert_extensions_RollingUpdateDeployment_To_v1beta1_RollingUpdateDeployment,
|
||||
Convert_v1beta1_RollingUpdateDeployment_To_extensions_RollingUpdateDeployment,
|
||||
)
|
||||
if err != nil {
|
||||
// If one of the conversion functions is malformed, detect it immediately.
|
||||
@ -48,14 +48,14 @@ func addConversionFuncs(scheme *runtime.Scheme) {
|
||||
// The following two PodSpec conversions functions where copied from pkg/api/conversion.go
|
||||
// for the generated functions to work properly.
|
||||
// This should be fixed: https://github.com/kubernetes/kubernetes/issues/12977
|
||||
func convert_api_PodSpec_To_v1_PodSpec(in *api.PodSpec, out *v1.PodSpec, s conversion.Scope) error {
|
||||
func Convert_api_PodSpec_To_v1_PodSpec(in *api.PodSpec, out *v1.PodSpec, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*api.PodSpec))(in)
|
||||
}
|
||||
if in.Volumes != nil {
|
||||
out.Volumes = make([]v1.Volume, len(in.Volumes))
|
||||
for i := range in.Volumes {
|
||||
if err := convert_api_Volume_To_v1_Volume(&in.Volumes[i], &out.Volumes[i], s); err != nil {
|
||||
if err := Convert_api_Volume_To_v1_Volume(&in.Volumes[i], &out.Volumes[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -65,7 +65,7 @@ func convert_api_PodSpec_To_v1_PodSpec(in *api.PodSpec, out *v1.PodSpec, s conve
|
||||
if in.Containers != nil {
|
||||
out.Containers = make([]v1.Container, len(in.Containers))
|
||||
for i := range in.Containers {
|
||||
if err := convert_api_Container_To_v1_Container(&in.Containers[i], &out.Containers[i], s); err != nil {
|
||||
if err := Convert_api_Container_To_v1_Container(&in.Containers[i], &out.Containers[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -100,7 +100,7 @@ func convert_api_PodSpec_To_v1_PodSpec(in *api.PodSpec, out *v1.PodSpec, s conve
|
||||
out.NodeName = in.NodeName
|
||||
if in.SecurityContext != nil {
|
||||
out.SecurityContext = new(v1.PodSecurityContext)
|
||||
if err := convert_api_PodSecurityContext_To_v1_PodSecurityContext(in.SecurityContext, out.SecurityContext, s); err != nil {
|
||||
if err := Convert_api_PodSecurityContext_To_v1_PodSecurityContext(in.SecurityContext, out.SecurityContext, s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ func convert_api_PodSpec_To_v1_PodSpec(in *api.PodSpec, out *v1.PodSpec, s conve
|
||||
if in.ImagePullSecrets != nil {
|
||||
out.ImagePullSecrets = make([]v1.LocalObjectReference, len(in.ImagePullSecrets))
|
||||
for i := range in.ImagePullSecrets {
|
||||
if err := convert_api_LocalObjectReference_To_v1_LocalObjectReference(&in.ImagePullSecrets[i], &out.ImagePullSecrets[i], s); err != nil {
|
||||
if err := Convert_api_LocalObjectReference_To_v1_LocalObjectReference(&in.ImagePullSecrets[i], &out.ImagePullSecrets[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -121,14 +121,14 @@ func convert_api_PodSpec_To_v1_PodSpec(in *api.PodSpec, out *v1.PodSpec, s conve
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_v1_PodSpec_To_api_PodSpec(in *v1.PodSpec, out *api.PodSpec, s conversion.Scope) error {
|
||||
func Convert_v1_PodSpec_To_api_PodSpec(in *v1.PodSpec, out *api.PodSpec, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*v1.PodSpec))(in)
|
||||
}
|
||||
if in.Volumes != nil {
|
||||
out.Volumes = make([]api.Volume, len(in.Volumes))
|
||||
for i := range in.Volumes {
|
||||
if err := convert_v1_Volume_To_api_Volume(&in.Volumes[i], &out.Volumes[i], s); err != nil {
|
||||
if err := Convert_v1_Volume_To_api_Volume(&in.Volumes[i], &out.Volumes[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -138,7 +138,7 @@ func convert_v1_PodSpec_To_api_PodSpec(in *v1.PodSpec, out *api.PodSpec, s conve
|
||||
if in.Containers != nil {
|
||||
out.Containers = make([]api.Container, len(in.Containers))
|
||||
for i := range in.Containers {
|
||||
if err := convert_v1_Container_To_api_Container(&in.Containers[i], &out.Containers[i], s); err != nil {
|
||||
if err := Convert_v1_Container_To_api_Container(&in.Containers[i], &out.Containers[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -177,7 +177,7 @@ func convert_v1_PodSpec_To_api_PodSpec(in *v1.PodSpec, out *api.PodSpec, s conve
|
||||
|
||||
if in.SecurityContext != nil {
|
||||
out.SecurityContext = new(api.PodSecurityContext)
|
||||
if err := convert_v1_PodSecurityContext_To_api_PodSecurityContext(in.SecurityContext, out.SecurityContext, s); err != nil {
|
||||
if err := Convert_v1_PodSecurityContext_To_api_PodSecurityContext(in.SecurityContext, out.SecurityContext, s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -190,7 +190,7 @@ func convert_v1_PodSpec_To_api_PodSpec(in *v1.PodSpec, out *api.PodSpec, s conve
|
||||
if in.ImagePullSecrets != nil {
|
||||
out.ImagePullSecrets = make([]api.LocalObjectReference, len(in.ImagePullSecrets))
|
||||
for i := range in.ImagePullSecrets {
|
||||
if err := convert_v1_LocalObjectReference_To_api_LocalObjectReference(&in.ImagePullSecrets[i], &out.ImagePullSecrets[i], s); err != nil {
|
||||
if err := Convert_v1_LocalObjectReference_To_api_LocalObjectReference(&in.ImagePullSecrets[i], &out.ImagePullSecrets[i], s); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -200,7 +200,7 @@ func convert_v1_PodSpec_To_api_PodSpec(in *v1.PodSpec, out *api.PodSpec, s conve
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_extensions_DeploymentSpec_To_v1beta1_DeploymentSpec(in *extensions.DeploymentSpec, out *DeploymentSpec, s conversion.Scope) error {
|
||||
func Convert_extensions_DeploymentSpec_To_v1beta1_DeploymentSpec(in *extensions.DeploymentSpec, out *DeploymentSpec, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*extensions.DeploymentSpec))(in)
|
||||
}
|
||||
@ -214,10 +214,10 @@ func convert_extensions_DeploymentSpec_To_v1beta1_DeploymentSpec(in *extensions.
|
||||
} else {
|
||||
out.Selector = nil
|
||||
}
|
||||
if err := convert_api_PodTemplateSpec_To_v1_PodTemplateSpec(&in.Template, &out.Template, s); err != nil {
|
||||
if err := Convert_api_PodTemplateSpec_To_v1_PodTemplateSpec(&in.Template, &out.Template, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := convert_extensions_DeploymentStrategy_To_v1beta1_DeploymentStrategy(&in.Strategy, &out.Strategy, s); err != nil {
|
||||
if err := Convert_extensions_DeploymentStrategy_To_v1beta1_DeploymentStrategy(&in.Strategy, &out.Strategy, s); err != nil {
|
||||
return err
|
||||
}
|
||||
out.UniqueLabelKey = new(string)
|
||||
@ -225,7 +225,7 @@ func convert_extensions_DeploymentSpec_To_v1beta1_DeploymentSpec(in *extensions.
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_v1beta1_DeploymentSpec_To_extensions_DeploymentSpec(in *DeploymentSpec, out *extensions.DeploymentSpec, s conversion.Scope) error {
|
||||
func Convert_v1beta1_DeploymentSpec_To_extensions_DeploymentSpec(in *DeploymentSpec, out *extensions.DeploymentSpec, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*DeploymentSpec))(in)
|
||||
}
|
||||
@ -240,10 +240,10 @@ func convert_v1beta1_DeploymentSpec_To_extensions_DeploymentSpec(in *DeploymentS
|
||||
} else {
|
||||
out.Selector = nil
|
||||
}
|
||||
if err := convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(&in.Template, &out.Template, s); err != nil {
|
||||
if err := Convert_v1_PodTemplateSpec_To_api_PodTemplateSpec(&in.Template, &out.Template, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := convert_v1beta1_DeploymentStrategy_To_extensions_DeploymentStrategy(&in.Strategy, &out.Strategy, s); err != nil {
|
||||
if err := Convert_v1beta1_DeploymentStrategy_To_extensions_DeploymentStrategy(&in.Strategy, &out.Strategy, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if in.UniqueLabelKey != nil {
|
||||
@ -252,14 +252,14 @@ func convert_v1beta1_DeploymentSpec_To_extensions_DeploymentSpec(in *DeploymentS
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_extensions_DeploymentStrategy_To_v1beta1_DeploymentStrategy(in *extensions.DeploymentStrategy, out *DeploymentStrategy, s conversion.Scope) error {
|
||||
func Convert_extensions_DeploymentStrategy_To_v1beta1_DeploymentStrategy(in *extensions.DeploymentStrategy, out *DeploymentStrategy, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*extensions.DeploymentStrategy))(in)
|
||||
}
|
||||
out.Type = DeploymentStrategyType(in.Type)
|
||||
if in.RollingUpdate != nil {
|
||||
out.RollingUpdate = new(RollingUpdateDeployment)
|
||||
if err := convert_extensions_RollingUpdateDeployment_To_v1beta1_RollingUpdateDeployment(in.RollingUpdate, out.RollingUpdate, s); err != nil {
|
||||
if err := Convert_extensions_RollingUpdateDeployment_To_v1beta1_RollingUpdateDeployment(in.RollingUpdate, out.RollingUpdate, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
@ -268,14 +268,14 @@ func convert_extensions_DeploymentStrategy_To_v1beta1_DeploymentStrategy(in *ext
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_v1beta1_DeploymentStrategy_To_extensions_DeploymentStrategy(in *DeploymentStrategy, out *extensions.DeploymentStrategy, s conversion.Scope) error {
|
||||
func Convert_v1beta1_DeploymentStrategy_To_extensions_DeploymentStrategy(in *DeploymentStrategy, out *extensions.DeploymentStrategy, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*DeploymentStrategy))(in)
|
||||
}
|
||||
out.Type = extensions.DeploymentStrategyType(in.Type)
|
||||
if in.RollingUpdate != nil {
|
||||
out.RollingUpdate = new(extensions.RollingUpdateDeployment)
|
||||
if err := convert_v1beta1_RollingUpdateDeployment_To_extensions_RollingUpdateDeployment(in.RollingUpdate, out.RollingUpdate, s); err != nil {
|
||||
if err := Convert_v1beta1_RollingUpdateDeployment_To_extensions_RollingUpdateDeployment(in.RollingUpdate, out.RollingUpdate, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
@ -284,7 +284,7 @@ func convert_v1beta1_DeploymentStrategy_To_extensions_DeploymentStrategy(in *Dep
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_extensions_RollingUpdateDeployment_To_v1beta1_RollingUpdateDeployment(in *extensions.RollingUpdateDeployment, out *RollingUpdateDeployment, s conversion.Scope) error {
|
||||
func Convert_extensions_RollingUpdateDeployment_To_v1beta1_RollingUpdateDeployment(in *extensions.RollingUpdateDeployment, out *RollingUpdateDeployment, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*extensions.RollingUpdateDeployment))(in)
|
||||
}
|
||||
@ -304,7 +304,7 @@ func convert_extensions_RollingUpdateDeployment_To_v1beta1_RollingUpdateDeployme
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_v1beta1_RollingUpdateDeployment_To_extensions_RollingUpdateDeployment(in *RollingUpdateDeployment, out *extensions.RollingUpdateDeployment, s conversion.Scope) error {
|
||||
func Convert_v1beta1_RollingUpdateDeployment_To_extensions_RollingUpdateDeployment(in *RollingUpdateDeployment, out *extensions.RollingUpdateDeployment, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*RollingUpdateDeployment))(in)
|
||||
}
|
||||
@ -318,7 +318,7 @@ func convert_v1beta1_RollingUpdateDeployment_To_extensions_RollingUpdateDeployme
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_api_PodSecurityContext_To_v1_PodSecurityContext(in *api.PodSecurityContext, out *v1.PodSecurityContext, s conversion.Scope) error {
|
||||
func Convert_api_PodSecurityContext_To_v1_PodSecurityContext(in *api.PodSecurityContext, out *v1.PodSecurityContext, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*api.PodSecurityContext))(in)
|
||||
}
|
||||
@ -326,7 +326,7 @@ func convert_api_PodSecurityContext_To_v1_PodSecurityContext(in *api.PodSecurity
|
||||
out.SupplementalGroups = in.SupplementalGroups
|
||||
if in.SELinuxOptions != nil {
|
||||
out.SELinuxOptions = new(v1.SELinuxOptions)
|
||||
if err := convert_api_SELinuxOptions_To_v1_SELinuxOptions(in.SELinuxOptions, out.SELinuxOptions, s); err != nil {
|
||||
if err := Convert_api_SELinuxOptions_To_v1_SELinuxOptions(in.SELinuxOptions, out.SELinuxOptions, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
@ -353,7 +353,7 @@ func convert_api_PodSecurityContext_To_v1_PodSecurityContext(in *api.PodSecurity
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_v1_PodSecurityContext_To_api_PodSecurityContext(in *v1.PodSecurityContext, out *api.PodSecurityContext, s conversion.Scope) error {
|
||||
func Convert_v1_PodSecurityContext_To_api_PodSecurityContext(in *v1.PodSecurityContext, out *api.PodSecurityContext, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*v1.PodSecurityContext))(in)
|
||||
}
|
||||
@ -361,7 +361,7 @@ func convert_v1_PodSecurityContext_To_api_PodSecurityContext(in *v1.PodSecurityC
|
||||
out.SupplementalGroups = in.SupplementalGroups
|
||||
if in.SELinuxOptions != nil {
|
||||
out.SELinuxOptions = new(api.SELinuxOptions)
|
||||
if err := convert_v1_SELinuxOptions_To_api_SELinuxOptions(in.SELinuxOptions, out.SELinuxOptions, s); err != nil {
|
||||
if err := Convert_v1_SELinuxOptions_To_api_SELinuxOptions(in.SELinuxOptions, out.SELinuxOptions, s); err != nil {
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -26,68 +26,68 @@ import (
|
||||
conversion "k8s.io/kubernetes/pkg/conversion"
|
||||
)
|
||||
|
||||
func autoconvert_metrics_RawNode_To_v1alpha1_RawNode(in *metrics.RawNode, out *RawNode, s conversion.Scope) error {
|
||||
func autoConvert_metrics_RawNode_To_v1alpha1_RawNode(in *metrics.RawNode, out *RawNode, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*metrics.RawNode))(in)
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
if err := api.Convert_unversioned_TypeMeta_To_unversioned_TypeMeta(&in.TypeMeta, &out.TypeMeta, s); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_metrics_RawNode_To_v1alpha1_RawNode(in *metrics.RawNode, out *RawNode, s conversion.Scope) error {
|
||||
return autoconvert_metrics_RawNode_To_v1alpha1_RawNode(in, out, s)
|
||||
func Convert_metrics_RawNode_To_v1alpha1_RawNode(in *metrics.RawNode, out *RawNode, s conversion.Scope) error {
|
||||
return autoConvert_metrics_RawNode_To_v1alpha1_RawNode(in, out, s)
|
||||
}
|
||||
|
||||
func autoconvert_metrics_RawPod_To_v1alpha1_RawPod(in *metrics.RawPod, out *RawPod, s conversion.Scope) error {
|
||||
func autoConvert_metrics_RawPod_To_v1alpha1_RawPod(in *metrics.RawPod, out *RawPod, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*metrics.RawPod))(in)
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
if err := api.Convert_unversioned_TypeMeta_To_unversioned_TypeMeta(&in.TypeMeta, &out.TypeMeta, s); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_metrics_RawPod_To_v1alpha1_RawPod(in *metrics.RawPod, out *RawPod, s conversion.Scope) error {
|
||||
return autoconvert_metrics_RawPod_To_v1alpha1_RawPod(in, out, s)
|
||||
func Convert_metrics_RawPod_To_v1alpha1_RawPod(in *metrics.RawPod, out *RawPod, s conversion.Scope) error {
|
||||
return autoConvert_metrics_RawPod_To_v1alpha1_RawPod(in, out, s)
|
||||
}
|
||||
|
||||
func autoconvert_v1alpha1_RawNode_To_metrics_RawNode(in *RawNode, out *metrics.RawNode, s conversion.Scope) error {
|
||||
func autoConvert_v1alpha1_RawNode_To_metrics_RawNode(in *RawNode, out *metrics.RawNode, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*RawNode))(in)
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
if err := api.Convert_unversioned_TypeMeta_To_unversioned_TypeMeta(&in.TypeMeta, &out.TypeMeta, s); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_v1alpha1_RawNode_To_metrics_RawNode(in *RawNode, out *metrics.RawNode, s conversion.Scope) error {
|
||||
return autoconvert_v1alpha1_RawNode_To_metrics_RawNode(in, out, s)
|
||||
func Convert_v1alpha1_RawNode_To_metrics_RawNode(in *RawNode, out *metrics.RawNode, s conversion.Scope) error {
|
||||
return autoConvert_v1alpha1_RawNode_To_metrics_RawNode(in, out, s)
|
||||
}
|
||||
|
||||
func autoconvert_v1alpha1_RawPod_To_metrics_RawPod(in *RawPod, out *metrics.RawPod, s conversion.Scope) error {
|
||||
func autoConvert_v1alpha1_RawPod_To_metrics_RawPod(in *RawPod, out *metrics.RawPod, s conversion.Scope) error {
|
||||
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
|
||||
defaulting.(func(*RawPod))(in)
|
||||
}
|
||||
if err := s.Convert(&in.TypeMeta, &out.TypeMeta, 0); err != nil {
|
||||
if err := api.Convert_unversioned_TypeMeta_To_unversioned_TypeMeta(&in.TypeMeta, &out.TypeMeta, s); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func convert_v1alpha1_RawPod_To_metrics_RawPod(in *RawPod, out *metrics.RawPod, s conversion.Scope) error {
|
||||
return autoconvert_v1alpha1_RawPod_To_metrics_RawPod(in, out, s)
|
||||
func Convert_v1alpha1_RawPod_To_metrics_RawPod(in *RawPod, out *metrics.RawPod, s conversion.Scope) error {
|
||||
return autoConvert_v1alpha1_RawPod_To_metrics_RawPod(in, out, s)
|
||||
}
|
||||
|
||||
func init() {
|
||||
err := api.Scheme.AddGeneratedConversionFuncs(
|
||||
autoconvert_metrics_RawNode_To_v1alpha1_RawNode,
|
||||
autoconvert_metrics_RawPod_To_v1alpha1_RawPod,
|
||||
autoconvert_v1alpha1_RawNode_To_metrics_RawNode,
|
||||
autoconvert_v1alpha1_RawPod_To_metrics_RawPod,
|
||||
autoConvert_metrics_RawNode_To_v1alpha1_RawNode,
|
||||
autoConvert_metrics_RawPod_To_v1alpha1_RawPod,
|
||||
autoConvert_v1alpha1_RawNode_To_metrics_RawNode,
|
||||
autoConvert_v1alpha1_RawPod_To_metrics_RawPod,
|
||||
)
|
||||
if err != nil {
|
||||
// If one of the conversion functions is malformed, detect it immediately.
|
||||
|
@ -87,12 +87,12 @@ func NewConverter() *Converter {
|
||||
inputFieldMappingFuncs: map[reflect.Type]FieldMappingFunc{},
|
||||
inputDefaultFlags: map[reflect.Type]FieldMatchingFlags{},
|
||||
}
|
||||
c.RegisterConversionFunc(byteSliceCopy)
|
||||
c.RegisterConversionFunc(ByteSliceCopy)
|
||||
return c
|
||||
}
|
||||
|
||||
// Prevent recursing into every byte...
|
||||
func byteSliceCopy(in *[]byte, out *[]byte, s Scope) error {
|
||||
// ByteSliceCopy prevents recursing into every byte
|
||||
func ByteSliceCopy(in *[]byte, out *[]byte, s Scope) error {
|
||||
*out = make([]byte, len(*in))
|
||||
copy(*out, *in)
|
||||
return nil
|
||||
@ -322,6 +322,11 @@ func (c *Converter) HasConversionFunc(inType, outType reflect.Type) bool {
|
||||
return found
|
||||
}
|
||||
|
||||
func (c *Converter) ConversionFuncValue(inType, outType reflect.Type) (reflect.Value, bool) {
|
||||
value, found := c.conversionFuncs[typePair{inType, outType}]
|
||||
return value, found
|
||||
}
|
||||
|
||||
// SetStructFieldCopy registers a correspondence. Whenever a struct field is encountered
|
||||
// which has a type and name matching srcFieldType and srcFieldName, it wil be copied
|
||||
// into the field in the destination struct matching destFieldType & Name, if such a
|
||||
|
@ -19,8 +19,10 @@ package runtime
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"path"
|
||||
"reflect"
|
||||
goruntime "runtime"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
@ -42,8 +44,13 @@ type ConversionGenerator interface {
|
||||
|
||||
func NewConversionGenerator(scheme *conversion.Scheme, targetPkg string) ConversionGenerator {
|
||||
g := &conversionGenerator{
|
||||
scheme: scheme,
|
||||
targetPkg: targetPkg,
|
||||
scheme: scheme,
|
||||
|
||||
nameFormat: "Convert_%s_%s_To_%s_%s",
|
||||
generatedNamePrefix: "auto",
|
||||
targetPkg: targetPkg,
|
||||
|
||||
publicFuncs: make(map[typePair]string),
|
||||
convertibles: make(map[reflect.Type]reflect.Type),
|
||||
overridden: make(map[reflect.Type]bool),
|
||||
pkgOverwrites: make(map[string]string),
|
||||
@ -59,8 +66,13 @@ func NewConversionGenerator(scheme *conversion.Scheme, targetPkg string) Convers
|
||||
var complexTypes []reflect.Kind = []reflect.Kind{reflect.Map, reflect.Ptr, reflect.Slice, reflect.Interface, reflect.Struct}
|
||||
|
||||
type conversionGenerator struct {
|
||||
scheme *conversion.Scheme
|
||||
targetPkg string
|
||||
scheme *conversion.Scheme
|
||||
|
||||
nameFormat string
|
||||
generatedNamePrefix string
|
||||
targetPkg string
|
||||
|
||||
publicFuncs map[typePair]string
|
||||
convertibles map[reflect.Type]reflect.Type
|
||||
overridden map[reflect.Type]bool
|
||||
// If pkgOverwrites is set for a given package name, that package name
|
||||
@ -138,6 +150,14 @@ func (g *conversionGenerator) generateConversionsBetween(inType, outType reflect
|
||||
return nil
|
||||
}
|
||||
if inType == outType {
|
||||
switch inType.Kind() {
|
||||
case reflect.Ptr:
|
||||
return g.generateConversionsBetween(inType.Elem(), inType.Elem())
|
||||
case reflect.Struct:
|
||||
// pointers to structs invoke new(inType)
|
||||
g.addImportByPath(inType.PkgPath())
|
||||
}
|
||||
g.rememberConversionFunction(inType, inType, false)
|
||||
// Don't generate conversion methods for the same type.
|
||||
return nil
|
||||
}
|
||||
@ -148,6 +168,8 @@ func (g *conversionGenerator) generateConversionsBetween(inType, outType reflect
|
||||
|
||||
if inType.Kind() != outType.Kind() {
|
||||
if existingConversion {
|
||||
g.rememberConversionFunction(inType, outType, false)
|
||||
g.rememberConversionFunction(outType, inType, false)
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("cannot convert types of different kinds: %v %v", inType, outType)
|
||||
@ -194,6 +216,7 @@ func (g *conversionGenerator) generateConversionsBetween(inType, outType reflect
|
||||
if !existingConversion && (inErr != nil || outErr != nil) {
|
||||
return inErr
|
||||
}
|
||||
g.rememberConversionFunction(inType, outType, true)
|
||||
if existingConversion {
|
||||
g.overridden[inType] = true
|
||||
}
|
||||
@ -214,6 +237,42 @@ func isComplexType(reflection reflect.Type) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (g *conversionGenerator) rememberConversionFunction(inType, outType reflect.Type, willGenerate bool) {
|
||||
if _, ok := g.publicFuncs[typePair{inType, outType}]; ok {
|
||||
return
|
||||
}
|
||||
|
||||
if v, ok := g.scheme.Converter().ConversionFuncValue(inType, outType); ok {
|
||||
if fn := goruntime.FuncForPC(v.Pointer()); fn != nil {
|
||||
name := fn.Name()
|
||||
var p, n string
|
||||
if last := strings.LastIndex(name, "."); last != -1 {
|
||||
p = name[:last]
|
||||
n = name[last+1:]
|
||||
p = g.imports[p]
|
||||
if len(p) > 0 {
|
||||
p = p + "."
|
||||
}
|
||||
} else {
|
||||
n = name
|
||||
}
|
||||
if isPublic(n) {
|
||||
g.publicFuncs[typePair{inType, outType}] = p + n
|
||||
} else {
|
||||
log.Printf("WARNING: Cannot generate conversion %v -> %v, method %q is private", inType, outType, fn.Name())
|
||||
}
|
||||
} else {
|
||||
log.Printf("WARNING: Cannot generate conversion %v -> %v, method is not accessible", inType, outType)
|
||||
}
|
||||
} else if willGenerate {
|
||||
g.publicFuncs[typePair{inType, outType}] = g.conversionFunctionName(inType, outType)
|
||||
}
|
||||
}
|
||||
|
||||
func isPublic(name string) bool {
|
||||
return strings.ToUpper(name[:1]) == name[:1]
|
||||
}
|
||||
|
||||
func (g *conversionGenerator) generateConversionsForMap(inType, outType reflect.Type) error {
|
||||
inKey := inType.Key()
|
||||
outKey := outType.Key()
|
||||
@ -507,15 +566,24 @@ func packageForName(inType reflect.Type) string {
|
||||
}
|
||||
|
||||
func (g *conversionGenerator) conversionFunctionName(inType, outType reflect.Type) string {
|
||||
funcNameFormat := "convert_%s_%s_To_%s_%s"
|
||||
funcNameFormat := g.nameFormat
|
||||
inPkg := packageForName(inType)
|
||||
outPkg := packageForName(outType)
|
||||
funcName := fmt.Sprintf(funcNameFormat, inPkg, inType.Name(), outPkg, outType.Name())
|
||||
return funcName
|
||||
}
|
||||
|
||||
func (g *conversionGenerator) conversionFunctionCall(inType, outType reflect.Type, scopeName string, args ...string) string {
|
||||
if named, ok := g.publicFuncs[typePair{inType, outType}]; ok {
|
||||
args[len(args)-1] = scopeName
|
||||
return fmt.Sprintf("%s(%s)", named, strings.Join(args, ", "))
|
||||
}
|
||||
log.Printf("WARNING: Using reflection to convert %v -> %v (no public conversion)", inType, outType)
|
||||
return fmt.Sprintf("%s.Convert(%s)", scopeName, strings.Join(args, ", "))
|
||||
}
|
||||
|
||||
func (g *conversionGenerator) generatedFunctionName(inType, outType reflect.Type) string {
|
||||
return "auto" + g.conversionFunctionName(inType, outType)
|
||||
return g.generatedNamePrefix + g.conversionFunctionName(inType, outType)
|
||||
}
|
||||
|
||||
func (g *conversionGenerator) writeHeader(b *buffer, name, inType, outType string, indent int) {
|
||||
@ -547,7 +615,8 @@ func (g *conversionGenerator) writeConversionForMap(b *buffer, inField, outField
|
||||
newFormat := "newVal := %s{}\n"
|
||||
newStmt := fmt.Sprintf(newFormat, g.typeName(outField.Type.Elem()))
|
||||
b.addLine(newStmt, indent+2)
|
||||
convertStmt := "if err := s.Convert(&val, &newVal, 0); err != nil {\n"
|
||||
call := g.conversionFunctionCall(inField.Type.Elem(), outField.Type.Elem(), "s", "&val", "&newVal", "0")
|
||||
convertStmt := fmt.Sprintf("if err := %s; err != nil {\n", call)
|
||||
b.addLine(convertStmt, indent+2)
|
||||
b.addLine("return err\n", indent+3)
|
||||
b.addLine("}\n", indent+2)
|
||||
@ -607,15 +676,8 @@ func (g *conversionGenerator) writeConversionForSlice(b *buffer, inField, outFie
|
||||
}
|
||||
}
|
||||
if !assigned {
|
||||
assignStmt := ""
|
||||
if g.existsDedicatedConversionFunction(inField.Type.Elem(), outField.Type.Elem()) {
|
||||
assignFormat := "if err := %s(&in.%s[i], &out.%s[i], s); err != nil {\n"
|
||||
funcName := g.conversionFunctionName(inField.Type.Elem(), outField.Type.Elem())
|
||||
assignStmt = fmt.Sprintf(assignFormat, funcName, inField.Name, outField.Name)
|
||||
} else {
|
||||
assignFormat := "if err := s.Convert(&in.%s[i], &out.%s[i], 0); err != nil {\n"
|
||||
assignStmt = fmt.Sprintf(assignFormat, inField.Name, outField.Name)
|
||||
}
|
||||
call := g.conversionFunctionCall(inField.Type.Elem(), outField.Type.Elem(), "s", "&in."+inField.Name+"[i]", "&out."+outField.Name+"[i]", "0")
|
||||
assignStmt := fmt.Sprintf("if err := %s; err != nil {\n", call)
|
||||
b.addLine(assignStmt, indent+2)
|
||||
b.addLine("return err\n", indent+3)
|
||||
b.addLine("}\n", indent+2)
|
||||
@ -664,20 +726,20 @@ func (g *conversionGenerator) writeConversionForPtr(b *buffer, inField, outField
|
||||
}
|
||||
}
|
||||
|
||||
b.addLine(fmt.Sprintf("// unable to generate simple pointer conversion for %v -> %v\n", inField.Type.Elem(), outField.Type.Elem()), indent)
|
||||
ifFormat := "if in.%s != nil {\n"
|
||||
ifStmt := fmt.Sprintf(ifFormat, inField.Name)
|
||||
b.addLine(ifStmt, indent)
|
||||
assignStmt := ""
|
||||
if g.existsDedicatedConversionFunction(inField.Type.Elem(), outField.Type.Elem()) {
|
||||
if _, ok := g.publicFuncs[typePair{inField.Type.Elem(), outField.Type.Elem()}]; ok {
|
||||
newFormat := "out.%s = new(%s)\n"
|
||||
newStmt := fmt.Sprintf(newFormat, outField.Name, g.typeName(outField.Type.Elem()))
|
||||
b.addLine(newStmt, indent+1)
|
||||
assignFormat := "if err := %s(in.%s, out.%s, s); err != nil {\n"
|
||||
funcName := g.conversionFunctionName(inField.Type.Elem(), outField.Type.Elem())
|
||||
assignStmt = fmt.Sprintf(assignFormat, funcName, inField.Name, outField.Name)
|
||||
call := g.conversionFunctionCall(inField.Type.Elem(), outField.Type.Elem(), "s", "in."+inField.Name, "out."+outField.Name, "0")
|
||||
assignStmt = fmt.Sprintf("if err := %s; err != nil {\n", call)
|
||||
} else {
|
||||
assignFormat := "if err := s.Convert(&in.%s, &out.%s, 0); err != nil {\n"
|
||||
assignStmt = fmt.Sprintf(assignFormat, inField.Name, outField.Name)
|
||||
call := g.conversionFunctionCall(inField.Type.Elem(), outField.Type.Elem(), "s", "&in."+inField.Name, "&out."+outField.Name, "0")
|
||||
assignStmt = fmt.Sprintf("if err := %s; err != nil {\n", call)
|
||||
}
|
||||
b.addLine(assignStmt, indent+1)
|
||||
b.addLine("return err\n", indent+2)
|
||||
@ -714,10 +776,14 @@ func (g *conversionGenerator) writeConversionForStruct(b *buffer, inType, outTyp
|
||||
}
|
||||
|
||||
existsConversion := g.scheme.Converter().HasConversionFunc(inField.Type, outField.Type)
|
||||
if existsConversion && !g.existsDedicatedConversionFunction(inField.Type, outField.Type) {
|
||||
_, hasPublicConversion := g.publicFuncs[typePair{inField.Type, outField.Type}]
|
||||
// TODO: This allows a private conversion for a slice to take precedence over a public
|
||||
// conversion for the field, even though that is technically slower. We should report when
|
||||
// we generate an inefficient conversion.
|
||||
if existsConversion || hasPublicConversion {
|
||||
// Use the conversion method that is already defined.
|
||||
assignFormat := "if err := s.Convert(&in.%s, &out.%s, 0); err != nil {\n"
|
||||
assignStmt := fmt.Sprintf(assignFormat, inField.Name, outField.Name)
|
||||
call := g.conversionFunctionCall(inField.Type, outField.Type, "s", "&in."+inField.Name, "&out."+outField.Name, "0")
|
||||
assignStmt := fmt.Sprintf("if err := %s; err != nil {\n", call)
|
||||
b.addLine(assignStmt, indent)
|
||||
b.addLine("return err\n", indent+1)
|
||||
b.addLine("}\n", indent)
|
||||
@ -773,15 +839,8 @@ func (g *conversionGenerator) writeConversionForStruct(b *buffer, inType, outTyp
|
||||
}
|
||||
}
|
||||
|
||||
assignStmt := ""
|
||||
if g.existsDedicatedConversionFunction(inField.Type, outField.Type) {
|
||||
assignFormat := "if err := %s(&in.%s, &out.%s, s); err != nil {\n"
|
||||
funcName := g.conversionFunctionName(inField.Type, outField.Type)
|
||||
assignStmt = fmt.Sprintf(assignFormat, funcName, inField.Name, outField.Name)
|
||||
} else {
|
||||
assignFormat := "if err := s.Convert(&in.%s, &out.%s, 0); err != nil {\n"
|
||||
assignStmt = fmt.Sprintf(assignFormat, inField.Name, outField.Name)
|
||||
}
|
||||
call := g.conversionFunctionCall(inField.Type, outField.Type, "s", "&in."+inField.Name, "&out."+outField.Name, "0")
|
||||
assignStmt := fmt.Sprintf("if err := %s; err != nil {\n", call)
|
||||
b.addLine(assignStmt, indent)
|
||||
b.addLine("return err\n", indent+1)
|
||||
b.addLine("}\n", indent)
|
||||
@ -843,33 +902,6 @@ var defaultConversions []typePair = []typePair{
|
||||
{reflect.TypeOf(EmbeddedObject{}), reflect.TypeOf(RawExtension{})},
|
||||
}
|
||||
|
||||
func (g *conversionGenerator) existsDedicatedConversionFunction(inType, outType reflect.Type) bool {
|
||||
if inType == outType {
|
||||
// Assume that conversion are not defined for "deep copies".
|
||||
return false
|
||||
}
|
||||
|
||||
if g.existsConversionFunction(inType, outType) {
|
||||
return true
|
||||
}
|
||||
|
||||
for _, conv := range defaultConversions {
|
||||
if conv.inType == inType && conv.outType == outType {
|
||||
return false
|
||||
}
|
||||
}
|
||||
if inType.Kind() != outType.Kind() {
|
||||
// TODO(wojtek-t): Currently all conversions between types of different kinds are
|
||||
// unnamed. Thus we return false here.
|
||||
return false
|
||||
}
|
||||
// TODO: no way to handle private conversions in different packages
|
||||
if g.assumePrivateConversions {
|
||||
return false
|
||||
}
|
||||
return g.scheme.Converter().HasConversionFunc(inType, outType)
|
||||
}
|
||||
|
||||
func (g *conversionGenerator) OverwritePackage(pkg, overwrite string) {
|
||||
g.pkgOverwrites[pkg] = overwrite
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user