本文整理匯總了Golang中k8s/io/kubernetes/pkg/conversion.Scope.DefaultConvert方法的典型用法代碼示例。如果您正苦於以下問題:Golang Scope.DefaultConvert方法的具體用法?Golang Scope.DefaultConvert怎麽用?Golang Scope.DefaultConvert使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類k8s/io/kubernetes/pkg/conversion.Scope
的用法示例。
在下文中一共展示了Scope.DefaultConvert方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: convert_api_SourceRevision_To_v1beta3_SourceRevision
func convert_api_SourceRevision_To_v1beta3_SourceRevision(in *newer.SourceRevision, out *SourceRevision, s conversion.Scope) error {
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
return err
}
out.Type = BuildSourceGit
return nil
}
示例2: Convert_v1beta1_VolumeSource_To_api_VolumeSource
// This will Convert the v1 representation of VolumeSource to our internal representation
// Used for keeping backwards compatibility for the Metadata field
func Convert_v1beta1_VolumeSource_To_api_VolumeSource(in *v1.VolumeSource, out *api.VolumeSource, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*v1.VolumeSource))(in)
}
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
return err
}
// if specified Metadata will stomp DownwardAPI
if in.Metadata != nil {
out.DownwardAPI = new(api.DownwardAPIVolumeSource)
if err := Convert_v1_MetadataVolumeSource_To_api_DownwardAPIVolumeSource(in.Metadata, out.DownwardAPI, s); err != nil {
return err
}
} else {
if in.DownwardAPI != nil {
out.DownwardAPI = new(api.DownwardAPIVolumeSource)
if err := Convert_v1_DownwardAPIVolumeSource_To_api_DownwardAPIVolumeSource(in.DownwardAPI, out.DownwardAPI, s); err != nil {
return err
}
} else {
out.DownwardAPI = nil
}
}
return nil
}
示例3: Convert_api_VolumeSource_To_v1beta1_VolumeSource
// This will Convert our internal represantation of VolumeSource to its v1 representation
// Used for keeping backwards compatibility for the Metadata field
func Convert_api_VolumeSource_To_v1beta1_VolumeSource(in *api.VolumeSource, out *v1.VolumeSource, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*api.VolumeSource))(in)
}
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
return err
}
if in.DownwardAPI != nil {
out.DownwardAPI = new(v1.DownwardAPIVolumeSource)
if err := Convert_api_DownwardAPIVolumeSource_To_v1_DownwardAPIVolumeSource(in.DownwardAPI, out.DownwardAPI, s); err != nil {
return err
}
// also copy to Metadata
out.Metadata = new(v1.MetadataVolumeSource)
if err := Convert_api_DownwardAPIVolumeSource_To_v1_MetadataVolumeSource(in.DownwardAPI, out.Metadata, s); err != nil {
return err
}
} else {
out.DownwardAPI = nil
}
return nil
}
示例4: Convert_api_Template_To_v1beta3_Template
func Convert_api_Template_To_v1beta3_Template(in *newer.Template, out *Template, s conversion.Scope) error {
//FIXME: DefaultConvert should not overwrite the Labels field on the
// the base object. This is likely a bug in the DefaultConvert
// code. For now, it is called before converting the labels.
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
return err
}
if err := s.Convert(&in.ObjectLabels, &out.Labels, 0); err != nil {
return err
}
// if we have runtime.Unstructured objects from the Process call. We need to encode those
// objects using the unstructured codec BEFORE the REST layers gets its shot at encoding to avoid a layered
// encode being done.
for i := range in.Objects {
if unstructured, ok := in.Objects[i].(*runtime.Unstructured); ok {
bytes, err := runtime.Encode(runtime.UnstructuredJSONScheme, unstructured)
if err != nil {
return err
}
out.Objects[i] = runtime.RawExtension{Raw: bytes}
}
}
return nil
}
示例5: convert_api_SubjectAccessReview_To_v1beta3_SubjectAccessReview
func convert_api_SubjectAccessReview_To_v1beta3_SubjectAccessReview(in *newer.SubjectAccessReview, out *SubjectAccessReview, s conversion.Scope) error {
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
return err
}
out.GroupsSlice = in.Groups.List()
return nil
}
示例6: convert_api_ClusterRoleBinding_To_v1_ClusterRoleBinding
func convert_api_ClusterRoleBinding_To_v1_ClusterRoleBinding(in *newer.ClusterRoleBinding, out *ClusterRoleBinding, s conversion.Scope) error {
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields|conversion.AllowDifferentFieldTypeNames); err != nil {
return err
}
out.UserNames, out.GroupNames = newer.StringSubjectsFor(in.Namespace, in.Subjects)
return nil
}
示例7: convert_api_Template_To_v1beta3_Template
func convert_api_Template_To_v1beta3_Template(in *newer.Template, out *Template, s conversion.Scope) error {
//FIXME: DefaultConvert should not overwrite the Labels field on the
// the base object. This is likely a bug in the DefaultConvert
// code. For now, it is called before converting the labels.
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
return err
}
return s.Convert(&in.ObjectLabels, &out.Labels, 0)
}
示例8: convert_v1beta3_SubjectAccessReview_To_api_SubjectAccessReview
func convert_v1beta3_SubjectAccessReview_To_api_SubjectAccessReview(in *SubjectAccessReview, out *newer.SubjectAccessReview, s conversion.Scope) error {
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
return err
}
out.Groups = util.NewStringSet(in.GroupsSlice...)
return nil
}
示例9: convert_api_ResourceAccessReviewResponse_To_v1_ResourceAccessReviewResponse
func convert_api_ResourceAccessReviewResponse_To_v1_ResourceAccessReviewResponse(in *newer.ResourceAccessReviewResponse, out *ResourceAccessReviewResponse, s conversion.Scope) error {
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
return err
}
out.UsersSlice = in.Users.List()
out.GroupsSlice = in.Groups.List()
return nil
}
示例10: convert_api_ClusterRoleBinding_To_v1_ClusterRoleBinding
func convert_api_ClusterRoleBinding_To_v1_ClusterRoleBinding(in *newer.ClusterRoleBinding, out *ClusterRoleBinding, s conversion.Scope) error {
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields|conversion.AllowDifferentFieldTypeNames); err != nil {
return err
}
out.UserNames = in.Users.List()
out.GroupNames = in.Groups.List()
return nil
}
示例11: convert_v1_RoleBinding_To_api_RoleBinding
func convert_v1_RoleBinding_To_api_RoleBinding(in *RoleBinding, out *newer.RoleBinding, s conversion.Scope) error {
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields|conversion.AllowDifferentFieldTypeNames); err != nil {
return err
}
out.Users = util.NewStringSet(in.UserNames...)
out.Groups = util.NewStringSet(in.GroupNames...)
return nil
}
示例12: convert_v1beta3_BuildOutput_To_api_BuildOutput
func convert_v1beta3_BuildOutput_To_api_BuildOutput(in *BuildOutput, out *newer.BuildOutput, s conversion.Scope) error {
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
return err
}
if in.To != nil && (in.To.Kind == "ImageStream" || len(in.To.Kind) == 0) {
out.To.Kind = "ImageStreamTag"
out.To.Name = imageapi.JoinImageStreamTag(in.To.Name, "")
}
return nil
}
示例13: convert_v1_ResourceAccessReviewResponse_To_api_ResourceAccessReviewResponse
func convert_v1_ResourceAccessReviewResponse_To_api_ResourceAccessReviewResponse(in *ResourceAccessReviewResponse, out *newer.ResourceAccessReviewResponse, s conversion.Scope) error {
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
return err
}
out.Users = sets.NewString(in.UsersSlice...)
out.Groups = sets.NewString(in.GroupsSlice...)
return nil
}
示例14: convert_api_LocalResourceAccessReview_To_v1_LocalResourceAccessReview
func convert_api_LocalResourceAccessReview_To_v1_LocalResourceAccessReview(in *newer.LocalResourceAccessReview, out *LocalResourceAccessReview, s conversion.Scope) error {
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
return err
}
if err := s.DefaultConvert(&in.Action, &out.AuthorizationAttributes, conversion.IgnoreMissingFields); err != nil {
return err
}
return nil
}
示例15: convert_v1beta3_CustomBuildStrategy_To_api_CustomBuildStrategy
func convert_v1beta3_CustomBuildStrategy_To_api_CustomBuildStrategy(in *CustomBuildStrategy, out *newer.CustomBuildStrategy, s conversion.Scope) error {
if err := s.DefaultConvert(in, out, conversion.IgnoreMissingFields); err != nil {
return err
}
switch in.From.Kind {
case "ImageStream":
out.From.Kind = "ImageStreamTag"
out.From.Name = imageapi.JoinImageStreamTag(in.From.Name, "")
}
return nil
}