本文整理匯總了Golang中github.com/jordic/k8s/cloudsqlip/Godeps/_workspace/src/k8s/io/kubernetes/pkg/conversion.Scope.Convert方法的典型用法代碼示例。如果您正苦於以下問題:Golang Scope.Convert方法的具體用法?Golang Scope.Convert怎麽用?Golang Scope.Convert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/jordic/k8s/cloudsqlip/Godeps/_workspace/src/k8s/io/kubernetes/pkg/conversion.Scope
的用法示例。
在下文中一共展示了Scope.Convert方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: autoconvert_v1alpha1_KubeProxyConfiguration_To_componentconfig_KubeProxyConfiguration
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 {
return err
}
out.BindAddress = in.BindAddress
out.CleanupIPTables = in.CleanupIPTables
out.HealthzBindAddress = in.HealthzBindAddress
out.HealthzPort = int(in.HealthzPort)
out.HostnameOverride = in.HostnameOverride
out.IPTablesSyncePeriodSeconds = int(in.IPTablesSyncePeriodSeconds)
out.KubeAPIBurst = int(in.KubeAPIBurst)
out.KubeAPIQPS = int(in.KubeAPIQPS)
out.KubeconfigPath = in.KubeconfigPath
out.MasqueradeAll = in.MasqueradeAll
out.Master = in.Master
if in.OOMScoreAdj != nil {
out.OOMScoreAdj = new(int)
*out.OOMScoreAdj = int(*in.OOMScoreAdj)
} else {
out.OOMScoreAdj = nil
}
out.Mode = componentconfig.ProxyMode(in.Mode)
out.PortRange = in.PortRange
out.ResourceContainer = in.ResourceContainer
out.UDPTimeoutMilliseconds = int(in.UDPTimeoutMilliseconds)
return nil
}
示例2: autoconvert_v1alpha1_RawPod_To_metrics_RawPod
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 {
return err
}
return nil
}
示例3: convert_v1beta1_RollingUpdateDeployment_To_extensions_RollingUpdateDeployment
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)
}
if err := s.Convert(in.MaxUnavailable, &out.MaxUnavailable, 0); err != nil {
return err
}
if err := s.Convert(in.MaxSurge, &out.MaxSurge, 0); err != nil {
return err
}
out.MinReadySeconds = int(in.MinReadySeconds)
return nil
}
示例4: rawExtensionToEmbeddedObject
// rawExtensionToEmbeddedObject does the conversion you would expect from the name, using the information
// given in conversion.Scope. It's placed in all schemes as a ConversionFunc to enable plugins;
// see the comment for RawExtension.
func (self *Scheme) rawExtensionToEmbeddedObject(in *RawExtension, out *EmbeddedObject, s conversion.Scope) error {
if len(in.RawJSON) == 0 || (len(in.RawJSON) == 4 && string(in.RawJSON) == "null") {
out.Object = nil
return nil
}
// Figure out the type and kind of the output object.
inVersion, outVersion, scheme := self.fromScope(s)
_, kind, err := scheme.raw.DataVersionAndKind(in.RawJSON)
if err != nil {
return err
}
// We have to make this object ourselves because we don't store the version field for
// plugin objects.
inObj, err := scheme.New(inVersion, kind)
if err != nil {
return err
}
err = scheme.DecodeInto(in.RawJSON, inObj)
if err != nil {
return err
}
// Make the desired internal version, and do the conversion.
outObj, err := scheme.New(outVersion, kind)
if err != nil {
return err
}
err = scheme.Convert(inObj, outObj)
if err != nil {
return err
}
// Last step, clear the Kind field; that should always be blank in memory.
err = s.Convert(
&emptyPlugin{PluginBase: PluginBase{Kind: ""}},
outObj,
conversion.SourceToDest|conversion.IgnoreMissingFields|conversion.AllowDifferentFieldTypeNames,
)
if err != nil {
return err
}
out.Object = outObj
return nil
}
示例5: embeddedObjectToRawExtension
// embeddedObjectToRawExtension does the conversion you would expect from the name, using the information
// given in conversion.Scope. It's placed in the DefaultScheme as a ConversionFunc to enable plugins;
// see the comment for RawExtension.
func (self *Scheme) embeddedObjectToRawExtension(in *EmbeddedObject, out *RawExtension, s conversion.Scope) error {
if in.Object == nil {
out.RawJSON = []byte("null")
return nil
}
// Figure out the type and kind of the output object.
_, outVersion, scheme := self.fromScope(s)
_, kind, err := scheme.raw.ObjectVersionAndKind(in.Object)
if err != nil {
return err
}
// Manufacture an object of this type and kind.
outObj, err := scheme.New(outVersion, kind)
if err != nil {
return err
}
// Manually do the conversion.
err = s.Convert(in.Object, outObj, 0)
if err != nil {
return err
}
// Copy the kind field into the output object.
err = s.Convert(
&emptyPlugin{PluginBase: PluginBase{Kind: kind}},
outObj,
conversion.SourceToDest|conversion.IgnoreMissingFields|conversion.AllowDifferentFieldTypeNames,
)
if err != nil {
return err
}
// Because we provide the correct version, EncodeToVersion will not attempt a conversion.
raw, err := scheme.EncodeToVersion(outObj, outVersion)
if err != nil {
// TODO: if this fails, create an Unknown-- maybe some other
// component will understand it.
return err
}
out.RawJSON = raw
return nil
}