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


Golang conversion.NewScheme函数代码示例

本文整理汇总了Golang中github.com/GoogleCloudPlatform/kubernetes/pkg/conversion.NewScheme函数的典型用法代码示例。如果您正苦于以下问题:Golang NewScheme函数的具体用法?Golang NewScheme怎么用?Golang NewScheme使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: init

func init() {
	conversionScheme = conversion.NewScheme()
	conversionScheme.InternalVersion = ""
	conversionScheme.ExternalVersion = "v1beta1"
	conversionScheme.MetaInsertionFactory = metaInsertion{}
	AddKnownTypes("",
		PodList{},
		Pod{},
		ReplicationControllerList{},
		ReplicationController{},
		ServiceList{},
		Service{},
		MinionList{},
		Minion{},
		Status{},
		ServerOpList{},
		ServerOp{},
		ContainerManifestList{},
		Endpoints{},
	)
	AddKnownTypes("v1beta1",
		v1beta1.PodList{},
		v1beta1.Pod{},
		v1beta1.ReplicationControllerList{},
		v1beta1.ReplicationController{},
		v1beta1.ServiceList{},
		v1beta1.Service{},
		v1beta1.MinionList{},
		v1beta1.Minion{},
		v1beta1.Status{},
		v1beta1.ServerOpList{},
		v1beta1.ServerOp{},
		v1beta1.ContainerManifestList{},
		v1beta1.Endpoints{},
	)

	// TODO: when we get more of this stuff, move to its own file. This is not a
	// good home for lots of conversion functions.
	// TODO: Consider inverting dependency chain-- imagine v1beta1 package
	// registering all of these functions. Then, if you want to be able to understand
	// v1beta1 objects, you just import that package for its side effects.
	AddConversionFuncs(
		// EnvVar's Name is depricated in favor of Key.
		func(in *EnvVar, out *v1beta1.EnvVar) error {
			out.Value = in.Value
			out.Key = in.Name
			out.Name = in.Name
			return nil
		},
		func(in *v1beta1.EnvVar, out *EnvVar) error {
			out.Value = in.Value
			if in.Name != "" {
				out.Name = in.Name
			} else {
				out.Name = in.Key
			}
			return nil
		},
	)
}
开发者ID:htomika,项目名称:kubernetes,代码行数:60,代码来源:helper.go

示例2: NewScheme

// NewScheme creates a new Scheme. A default scheme is provided and accessible
// as the "DefaultScheme" variable.
func NewScheme(internalVersion, externalVersion string) *Scheme {
	s := &Scheme{conversion.NewScheme()}
	s.raw.InternalVersion = internalVersion
	s.raw.ExternalVersion = externalVersion
	s.raw.MetaInsertionFactory = metaInsertion{}
	return s
}
开发者ID:asim,项目名称:kubernetes,代码行数:9,代码来源:helper.go

示例3: NewScheme

// NewScheme creates a new Scheme. This scheme is pluggable by default.
func NewScheme() *Scheme {
	s := &Scheme{conversion.NewScheme()}
	s.raw.InternalVersion = ""
	s.raw.MetaFactory = conversion.SimpleMetaFactory{BaseFields: []string{"TypeMeta"}, VersionField: "APIVersion", KindField: "Kind"}
	s.raw.AddConversionFuncs(
		s.embeddedObjectToRawExtension,
		s.rawExtensionToEmbeddedObject,
	)
	return s
}
开发者ID:TencentSA,项目名称:kubernetes-0.5,代码行数:11,代码来源:scheme.go

示例4: NewScheme

// NewScheme creates a new Scheme. This scheme is pluggable by default.
func NewScheme() *Scheme {
	s := &Scheme{conversion.NewScheme()}
	s.raw.InternalVersion = ""
	s.raw.MetaInsertionFactory = metaInsertion{}
	s.raw.AddConversionFuncs(
		s.embeddedObjectToRawExtension,
		s.rawExtensionToEmbeddedObject,
	)
	return s
}
开发者ID:linuxwhy,项目名称:kubernetes,代码行数:11,代码来源:scheme.go

示例5: NewScheme

// NewScheme creates a new Scheme. This scheme is pluggable by default.
func NewScheme() *Scheme {
	s := &Scheme{conversion.NewScheme(), map[string]map[string]FieldLabelConversionFunc{}}
	s.raw.InternalVersion = ""
	s.raw.MetaFactory = conversion.SimpleMetaFactory{BaseFields: []string{"TypeMeta"}, VersionField: "APIVersion", KindField: "Kind"}
	if err := s.raw.AddConversionFuncs(
		s.embeddedObjectToRawExtension,
		s.rawExtensionToEmbeddedObject,
		s.runtimeObjectToRawExtensionArray,
		s.rawExtensionToRuntimeObjectArray,
	); err != nil {
		panic(err)
	}
	return s
}
开发者ID:DreadPirateShawn,项目名称:heapster,代码行数:15,代码来源:scheme.go

示例6: NewScheme

// NewScheme creates a new Scheme. This scheme is pluggable by default.
func NewScheme() *Scheme {
	s := &Scheme{conversion.NewScheme(), map[string]map[string]FieldLabelConversionFunc{}}
	s.raw.InternalVersion = ""
	s.raw.MetaFactory = conversion.SimpleMetaFactory{BaseFields: []string{"TypeMeta"}, VersionField: "APIVersion", KindField: "Kind"}
	if err := s.raw.AddConversionFuncs(
		s.embeddedObjectToRawExtension,
		s.rawExtensionToEmbeddedObject,
		s.runtimeObjectToRawExtensionArray,
		s.rawExtensionToRuntimeObjectArray,
	); err != nil {
		panic(err)
	}
	// Enable map[string][]string conversions by default
	if err := s.raw.AddConversionFuncs(DefaultStringConversions...); err != nil {
		panic(err)
	}
	if err := s.raw.RegisterInputDefaults(&map[string][]string{}, JSONKeyMapper, conversion.AllowDifferentFieldTypeNames|conversion.IgnoreMissingFields); err != nil {
		panic(err)
	}
	if err := s.raw.RegisterInputDefaults(&url.Values{}, JSONKeyMapper, conversion.AllowDifferentFieldTypeNames|conversion.IgnoreMissingFields); err != nil {
		panic(err)
	}
	return s
}
开发者ID:cjnygard,项目名称:origin,代码行数:25,代码来源:scheme.go

示例7: init

func init() {
	scheme = conversion.NewScheme()
	scheme.ExternalVersion = "v1beta1"
	scheme.AddKnownTypes("", TestResource{})
	scheme.AddKnownTypes("v1beta1", TestResource{})
}
开发者ID:hvdb,项目名称:kubernetes,代码行数:6,代码来源:etcd_tools_test.go

示例8: init

// objects.
type codec interface {
	Encode(obj interface{}) (data []byte, err error)
	Decode(data []byte) (interface{}, error)
	DecodeInto(data []byte, obj interface{}) error
}

// resourceVersioner provides methods for setting and retrieving
// the resource version from an API object.
type resourceVersioner interface {
	SetResourceVersion(obj interface{}, version uint64) error
	ResourceVersion(obj interface{}) (uint64, error)
}

var ResourceVersioner resourceVersioner = NewJSONBaseResourceVersioner()
var conversionScheme = conversion.NewScheme()
var Codec codec = conversionScheme

func init() {
	conversionScheme.InternalVersion = ""
	conversionScheme.ExternalVersion = "v1beta1"
	conversionScheme.MetaInsertionFactory = metaInsertion{}
}

// AddKnownTypes registers the types of the arguments to the marshaller of the package api.
// Encode() refuses the object unless its type is registered with AddKnownTypes.
func AddKnownTypes(version string, types ...interface{}) {
	conversionScheme.AddKnownTypes(version, types...)
}

// New returns a new API object of the given version ("" for internal
开发者ID:lmiccini,项目名称:origin,代码行数:31,代码来源:helper.go


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