当前位置: 首页>>代码示例>>Golang>>正文


Golang Scheme.AddGenericConversionFunc方法代码示例

本文整理汇总了Golang中k8s/io/apimachinery/pkg/runtime.Scheme.AddGenericConversionFunc方法的典型用法代码示例。如果您正苦于以下问题:Golang Scheme.AddGenericConversionFunc方法的具体用法?Golang Scheme.AddGenericConversionFunc怎么用?Golang Scheme.AddGenericConversionFunc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在k8s/io/apimachinery/pkg/runtime.Scheme的用法示例。


在下文中一共展示了Scheme.AddGenericConversionFunc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: addFastPathConversionFuncs

// This is a "fast-path" that avoids reflection for common types. It focuses on the objects that are
// converted the most in the cluster.
// TODO: generate one of these for every external API group - this is to prove the impact
func addFastPathConversionFuncs(scheme *runtime.Scheme) error {
	scheme.AddGenericConversionFunc(func(objA, objB interface{}, s conversion.Scope) (bool, error) {
		switch a := objA.(type) {
		case *Pod:
			switch b := objB.(type) {
			case *api.Pod:
				return true, Convert_v1_Pod_To_api_Pod(a, b, s)
			}
		case *api.Pod:
			switch b := objB.(type) {
			case *Pod:
				return true, Convert_api_Pod_To_v1_Pod(a, b, s)
			}

		case *Event:
			switch b := objB.(type) {
			case *api.Event:
				return true, Convert_v1_Event_To_api_Event(a, b, s)
			}
		case *api.Event:
			switch b := objB.(type) {
			case *Event:
				return true, Convert_api_Event_To_v1_Event(a, b, s)
			}

		case *ReplicationController:
			switch b := objB.(type) {
			case *api.ReplicationController:
				return true, Convert_v1_ReplicationController_To_api_ReplicationController(a, b, s)
			}
		case *api.ReplicationController:
			switch b := objB.(type) {
			case *ReplicationController:
				return true, Convert_api_ReplicationController_To_v1_ReplicationController(a, b, s)
			}

		case *Node:
			switch b := objB.(type) {
			case *api.Node:
				return true, Convert_v1_Node_To_api_Node(a, b, s)
			}
		case *api.Node:
			switch b := objB.(type) {
			case *Node:
				return true, Convert_api_Node_To_v1_Node(a, b, s)
			}

		case *Namespace:
			switch b := objB.(type) {
			case *api.Namespace:
				return true, Convert_v1_Namespace_To_api_Namespace(a, b, s)
			}
		case *api.Namespace:
			switch b := objB.(type) {
			case *Namespace:
				return true, Convert_api_Namespace_To_v1_Namespace(a, b, s)
			}

		case *Service:
			switch b := objB.(type) {
			case *api.Service:
				return true, Convert_v1_Service_To_api_Service(a, b, s)
			}
		case *api.Service:
			switch b := objB.(type) {
			case *Service:
				return true, Convert_api_Service_To_v1_Service(a, b, s)
			}

		case *Endpoints:
			switch b := objB.(type) {
			case *api.Endpoints:
				return true, Convert_v1_Endpoints_To_api_Endpoints(a, b, s)
			}
		case *api.Endpoints:
			switch b := objB.(type) {
			case *Endpoints:
				return true, Convert_api_Endpoints_To_v1_Endpoints(a, b, s)
			}

		case *metav1.WatchEvent:
			switch b := objB.(type) {
			case *metav1.InternalEvent:
				return true, metav1.Convert_versioned_Event_to_versioned_InternalEvent(a, b, s)
			}
		case *metav1.InternalEvent:
			switch b := objB.(type) {
			case *metav1.WatchEvent:
				return true, metav1.Convert_versioned_InternalEvent_to_versioned_Event(a, b, s)
			}
		}
		return false, nil
	})
	return nil
}
开发者ID:kubernetes,项目名称:kubernetes,代码行数:98,代码来源:conversion.go


注:本文中的k8s/io/apimachinery/pkg/runtime.Scheme.AddGenericConversionFunc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。