func addConversionFuncs(scheme *runtime.Scheme) error { // Add non-generated conversion functions err := scheme.AddConversionFuncs( Convert_batch_JobSpec_To_v2alpha1_JobSpec, Convert_v2alpha1_JobSpec_To_batch_JobSpec, ) if err != nil { return err } // Add field label conversions for kinds having selectable nothing but ObjectMeta fields. for _, kind := range []string{"Job", "JobTemplate", "CronJob"} { err = api.Scheme.AddFieldLabelConversionFunc("batch/v2alpha1", kind, func(label, value string) (string, string, error) { switch label { case "metadata.name", "metadata.namespace", "status.successful": return label, value, nil default: return "", "", fmt.Errorf("field label not supported: %s", label) } }) if err != nil { return err } } return nil }
func addConversionFuncs(scheme *runtime.Scheme) error { // Add non-generated conversion functions err := scheme.AddConversionFuncs( Convert_extensions_ScaleStatus_To_v1beta1_ScaleStatus, Convert_v1beta1_ScaleStatus_To_extensions_ScaleStatus, 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_extensions_ReplicaSetSpec_To_v1beta1_ReplicaSetSpec, Convert_v1beta1_ReplicaSetSpec_To_extensions_ReplicaSetSpec, // autoscaling Convert_autoscaling_CrossVersionObjectReference_To_v1beta1_SubresourceReference, Convert_v1beta1_SubresourceReference_To_autoscaling_CrossVersionObjectReference, Convert_autoscaling_HorizontalPodAutoscalerSpec_To_v1beta1_HorizontalPodAutoscalerSpec, Convert_v1beta1_HorizontalPodAutoscalerSpec_To_autoscaling_HorizontalPodAutoscalerSpec, // batch Convert_batch_JobSpec_To_v1beta1_JobSpec, Convert_v1beta1_JobSpec_To_batch_JobSpec, ) if err != nil { return err } // Add field label conversions for kinds having selectable nothing but ObjectMeta fields. for _, k := range []string{"DaemonSet", "Deployment", "Ingress"} { kind := k // don't close over range variables err = api.Scheme.AddFieldLabelConversionFunc("extensions/v1beta1", kind, func(label, value string) (string, string, error) { switch label { case "metadata.name", "metadata.namespace": return label, value, nil default: return "", "", fmt.Errorf("field label %q not supported for %q", label, kind) } }, ) if err != nil { return err } } return api.Scheme.AddFieldLabelConversionFunc("extensions/v1beta1", "Job", func(label, value string) (string, string, error) { switch label { case "metadata.name", "metadata.namespace", "status.successful": return label, value, nil default: return "", "", fmt.Errorf("field label not supported: %s", label) } }, ) }
// AddToGroupVersion registers the watch external and internal kinds with the scheme, and ensures the proper // conversions are in place. func AddToGroupVersion(scheme *runtime.Scheme, groupVersion schema.GroupVersion) { scheme.AddKnownTypeWithName(groupVersion.WithKind(WatchEventKind), &Event{}) scheme.AddKnownTypeWithName( schema.GroupVersion{Group: groupVersion.Group, Version: runtime.APIVersionInternal}.WithKind(WatchEventKind), &InternalEvent{}, ) scheme.AddConversionFuncs( Convert_versioned_Event_to_watch_Event, Convert_versioned_InternalEvent_to_versioned_Event, Convert_watch_Event_to_versioned_Event, Convert_versioned_Event_to_versioned_InternalEvent, ) }
func addConversionFuncs(scheme *runtime.Scheme) error { // Add non-generated conversion functions err := scheme.AddConversionFuncs( Convert_batch_JobSpec_To_v1_JobSpec, Convert_v1_JobSpec_To_batch_JobSpec, ) if err != nil { return err } return api.Scheme.AddFieldLabelConversionFunc("batch/v1", "Job", func(label, value string) (string, string, error) { switch label { case "metadata.name", "metadata.namespace", "status.successful": return label, value, nil default: return "", "", fmt.Errorf("field label not supported: %s", label) } }, ) }
func addConversionFuncs(scheme *runtime.Scheme) error { return scheme.AddConversionFuncs( 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_Slice_string_To_unversioned_Time, Convert_resource_Quantity_To_resource_Quantity, Convert_string_To_labels_Selector, Convert_labels_Selector_To_string, Convert_string_To_fields_Selector, Convert_fields_Selector_To_string, Convert_Pointer_bool_To_bool, Convert_bool_To_Pointer_bool, Convert_Pointer_string_To_string, Convert_string_To_Pointer_string, Convert_Pointer_int64_To_int, Convert_int_To_Pointer_int64, Convert_Pointer_int32_To_int32, Convert_int32_To_Pointer_int32, Convert_Pointer_float64_To_float64, Convert_float64_To_Pointer_float64, Convert_map_to_unversioned_LabelSelector, Convert_unversioned_LabelSelector_to_map, ) }
func addConversionFuncs(scheme *runtime.Scheme) error { // Add non-generated conversion functions to handle the *int32 -> int32 // conversion. A pointer is useful in the versioned type so we can default // it, but a plain int32 is more convenient in the internal type. These // functions are the same as the autogenerated ones in every other way. err := scheme.AddConversionFuncs( Convert_v1alpha1_PetSetSpec_To_apps_PetSetSpec, Convert_apps_PetSetSpec_To_v1alpha1_PetSetSpec, ) if err != nil { return err } return api.Scheme.AddFieldLabelConversionFunc("apps/v1alpha1", "PetSet", func(label, value string) (string, string, error) { switch label { case "metadata.name", "metadata.namespace", "status.successful": return label, value, nil default: return "", "", fmt.Errorf("field label not supported: %s", label) } }, ) }
func addConversionFuncs(scheme *runtime.Scheme) error { // Add non-generated conversion functions return scheme.AddConversionFuncs() }
func addConversionFuncs(scheme *runtime.Scheme) error { // 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_Secret_To_api_Secret, Convert_v1_ServiceSpec_To_api_ServiceSpec, Convert_v1_ResourceList_To_api_ResourceList, Convert_v1_ReplicationController_to_extensions_ReplicaSet, Convert_v1_ReplicationControllerSpec_to_extensions_ReplicaSetSpec, Convert_v1_ReplicationControllerStatus_to_extensions_ReplicaSetStatus, Convert_extensions_ReplicaSet_to_v1_ReplicationController, Convert_extensions_ReplicaSetSpec_to_v1_ReplicationControllerSpec, Convert_extensions_ReplicaSetStatus_to_v1_ReplicationControllerStatus, ) if err != nil { return err } // Add field label conversions for kinds having selectable nothing but ObjectMeta fields. for _, k := range []string{ "Endpoints", "ResourceQuota", "PersistentVolumeClaim", "Service", "ServiceAccount", "ConfigMap", } { kind := k // don't close over range variables err = scheme.AddFieldLabelConversionFunc("v1", kind, func(label, value string) (string, string, error) { switch label { case "metadata.namespace", "metadata.name": return label, value, nil default: return "", "", fmt.Errorf("field label %q not supported for %q", label, kind) } }, ) if err != nil { return err } } // Add field conversion funcs. err = scheme.AddFieldLabelConversionFunc("v1", "Pod", func(label, value string) (string, string, error) { switch label { case "metadata.annotations", "metadata.labels", "metadata.name", "metadata.namespace", "spec.nodeName", "spec.restartPolicy", "spec.serviceAccountName", "status.phase", "status.podIP": return label, value, nil // This is for backwards compatibility with old v1 clients which send spec.host case "spec.host": return "spec.nodeName", value, nil default: return "", "", fmt.Errorf("field label not supported: %s", label) } }, ) if err != nil { return err } err = scheme.AddFieldLabelConversionFunc("v1", "Node", func(label, value string) (string, string, error) { switch label { case "metadata.name": return label, value, nil case "spec.unschedulable": return label, value, nil default: return "", "", fmt.Errorf("field label not supported: %s", label) } }, ) if err != nil { return err } err = scheme.AddFieldLabelConversionFunc("v1", "ReplicationController", func(label, value string) (string, string, error) { switch label { case "metadata.name", "metadata.namespace", "status.replicas": return label, value, nil default: return "", "", fmt.Errorf("field label not supported: %s", label) } }) if err != nil { return err } err = scheme.AddFieldLabelConversionFunc("v1", "PersistentVolume", func(label, value string) (string, string, error) { switch label { case "metadata.name": return label, value, nil default: return "", "", fmt.Errorf("field label not supported: %s", label) } }, ) if err != nil { return err } if err := AddFieldLabelConversionsForEvent(scheme); err != nil { return err } if err := AddFieldLabelConversionsForNamespace(scheme); err != nil { return err } if err := AddFieldLabelConversionsForSecret(scheme); err != nil { return err } return nil }
func addConversionFuncs(scheme *runtime.Scheme) error { return scheme.AddConversionFuncs( func(in *Cluster, out *api.Cluster, s conversion.Scope) error { return s.DefaultConvert(in, out, conversion.IgnoreMissingFields) }, func(in *api.Cluster, out *Cluster, s conversion.Scope) error { return s.DefaultConvert(in, out, conversion.IgnoreMissingFields) }, func(in *Preferences, out *api.Preferences, s conversion.Scope) error { return s.DefaultConvert(in, out, conversion.IgnoreMissingFields) }, func(in *api.Preferences, out *Preferences, s conversion.Scope) error { return s.DefaultConvert(in, out, conversion.IgnoreMissingFields) }, func(in *AuthInfo, out *api.AuthInfo, s conversion.Scope) error { return s.DefaultConvert(in, out, conversion.IgnoreMissingFields) }, func(in *api.AuthInfo, out *AuthInfo, s conversion.Scope) error { return s.DefaultConvert(in, out, conversion.IgnoreMissingFields) }, func(in *Context, out *api.Context, s conversion.Scope) error { return s.DefaultConvert(in, out, conversion.IgnoreMissingFields) }, func(in *api.Context, out *Context, s conversion.Scope) error { return s.DefaultConvert(in, out, conversion.IgnoreMissingFields) }, func(in *Config, out *api.Config, s conversion.Scope) error { out.CurrentContext = in.CurrentContext if err := s.Convert(&in.Preferences, &out.Preferences, 0); err != nil { return err } out.Clusters = make(map[string]*api.Cluster) if err := s.Convert(&in.Clusters, &out.Clusters, 0); err != nil { return err } out.AuthInfos = make(map[string]*api.AuthInfo) if err := s.Convert(&in.AuthInfos, &out.AuthInfos, 0); err != nil { return err } out.Contexts = make(map[string]*api.Context) if err := s.Convert(&in.Contexts, &out.Contexts, 0); err != nil { return err } out.Extensions = make(map[string]runtime.Object) if err := s.Convert(&in.Extensions, &out.Extensions, 0); err != nil { return err } return nil }, func(in *api.Config, out *Config, s conversion.Scope) error { out.CurrentContext = in.CurrentContext if err := s.Convert(&in.Preferences, &out.Preferences, 0); err != nil { return err } out.Clusters = make([]NamedCluster, 0, 0) if err := s.Convert(&in.Clusters, &out.Clusters, 0); err != nil { return err } out.AuthInfos = make([]NamedAuthInfo, 0, 0) if err := s.Convert(&in.AuthInfos, &out.AuthInfos, 0); err != nil { return err } out.Contexts = make([]NamedContext, 0, 0) if err := s.Convert(&in.Contexts, &out.Contexts, 0); err != nil { return err } out.Extensions = make([]NamedExtension, 0, 0) if err := s.Convert(&in.Extensions, &out.Extensions, 0); err != nil { return err } return nil }, func(in *[]NamedCluster, out *map[string]*api.Cluster, s conversion.Scope) error { for _, curr := range *in { newCluster := api.NewCluster() if err := s.Convert(&curr.Cluster, newCluster, 0); err != nil { return err } (*out)[curr.Name] = newCluster } return nil }, func(in *map[string]*api.Cluster, out *[]NamedCluster, s conversion.Scope) error { allKeys := make([]string, 0, len(*in)) for key := range *in { allKeys = append(allKeys, key) } sort.Strings(allKeys) for _, key := range allKeys { newCluster := (*in)[key] oldCluster := &Cluster{} if err := s.Convert(newCluster, oldCluster, 0); err != nil { return err } namedCluster := NamedCluster{key, *oldCluster} *out = append(*out, namedCluster) } return nil }, func(in *[]NamedAuthInfo, out *map[string]*api.AuthInfo, s conversion.Scope) error { for _, curr := range *in { newAuthInfo := api.NewAuthInfo() if err := s.Convert(&curr.AuthInfo, newAuthInfo, 0); err != nil { return err } (*out)[curr.Name] = newAuthInfo } return nil }, func(in *map[string]*api.AuthInfo, out *[]NamedAuthInfo, s conversion.Scope) error { allKeys := make([]string, 0, len(*in)) for key := range *in { allKeys = append(allKeys, key) } sort.Strings(allKeys) for _, key := range allKeys { newAuthInfo := (*in)[key] oldAuthInfo := &AuthInfo{} if err := s.Convert(newAuthInfo, oldAuthInfo, 0); err != nil { return err } namedAuthInfo := NamedAuthInfo{key, *oldAuthInfo} *out = append(*out, namedAuthInfo) } return nil }, func(in *[]NamedContext, out *map[string]*api.Context, s conversion.Scope) error { for _, curr := range *in { newContext := api.NewContext() if err := s.Convert(&curr.Context, newContext, 0); err != nil { return err } (*out)[curr.Name] = newContext } return nil }, func(in *map[string]*api.Context, out *[]NamedContext, s conversion.Scope) error { allKeys := make([]string, 0, len(*in)) for key := range *in { allKeys = append(allKeys, key) } sort.Strings(allKeys) for _, key := range allKeys { newContext := (*in)[key] oldContext := &Context{} if err := s.Convert(newContext, oldContext, 0); err != nil { return err } namedContext := NamedContext{key, *oldContext} *out = append(*out, namedContext) } return nil }, func(in *[]NamedExtension, out *map[string]runtime.Object, s conversion.Scope) error { for _, curr := range *in { var newExtension runtime.Object if err := s.Convert(&curr.Extension, &newExtension, 0); err != nil { return err } (*out)[curr.Name] = newExtension } return nil }, func(in *map[string]runtime.Object, out *[]NamedExtension, s conversion.Scope) error { allKeys := make([]string, 0, len(*in)) for key := range *in { allKeys = append(allKeys, key) } sort.Strings(allKeys) for _, key := range allKeys { newExtension := (*in)[key] oldExtension := &runtime.RawExtension{} if err := s.Convert(newExtension, oldExtension, 0); err != nil { return err } namedExtension := NamedExtension{key, *oldExtension} *out = append(*out, namedExtension) } return nil }, ) }