本文整理匯總了Golang中k8s/io/kubernetes/pkg/runtime.Scheme.AddFieldLabelConversionFunc方法的典型用法代碼示例。如果您正苦於以下問題:Golang Scheme.AddFieldLabelConversionFunc方法的具體用法?Golang Scheme.AddFieldLabelConversionFunc怎麽用?Golang Scheme.AddFieldLabelConversionFunc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類k8s/io/kubernetes/pkg/runtime.Scheme
的用法示例。
在下文中一共展示了Scheme.AddFieldLabelConversionFunc方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: addConversionFuncs
func addConversionFuncs(scheme *runtime.Scheme) {
if err := scheme.AddFieldLabelConversionFunc("v1", "Application",
oapi.GetFieldLabelConversionFunc(api.ApplicationToSelectableFields(&api.Application{}), nil),
); err != nil {
panic(err)
}
}
示例2: addConversionFuncs
func addConversionFuncs(scheme *runtime.Scheme) {
if err := scheme.AddFieldLabelConversionFunc("v1", "Project",
oapi.GetFieldLabelConversionFunc(namespace.NamespaceToSelectableFields(&kapi.Namespace{}), nil),
); err != nil {
panic(err)
}
}
示例3: addConversionFuncs
func addConversionFuncs(scheme *runtime.Scheme) {
err := scheme.AddDefaultingFuncs(
func(obj *RouteSpec) {
obj.To.Kind = "Service"
},
func(obj *TLSConfig) {
if len(obj.Termination) == 0 && len(obj.DestinationCACertificate) == 0 {
obj.Termination = TLSTerminationEdge
}
switch obj.Termination {
case TLSTerminationType("Reencrypt"):
obj.Termination = TLSTerminationReencrypt
case TLSTerminationType("Edge"):
obj.Termination = TLSTerminationEdge
case TLSTerminationType("Passthrough"):
obj.Termination = TLSTerminationPassthrough
}
},
)
if err != nil {
panic(err)
}
err = scheme.AddConversionFuncs()
if err != nil {
panic(err)
}
if err := scheme.AddFieldLabelConversionFunc("v1", "Route",
oapi.GetFieldLabelConversionFunc(routeapi.RouteToSelectableFields(&routeapi.Route{}), nil),
); err != nil {
panic(err)
}
}
示例4: addConversionFuncs
func addConversionFuncs(scheme *runtime.Scheme) {
err := scheme.AddConversionFuncs(
Convert_v1_NamedTagEventListArray_to_api_TagEventListArray,
Convert_api_TagEventListArray_to_v1_NamedTagEventListArray,
Convert_v1_TagReferenceArray_to_api_TagReferenceMap,
Convert_api_TagReferenceMap_to_v1_TagReferenceArray,
Convert_api_Image_To_v1_Image,
Convert_v1_Image_To_api_Image,
Convert_v1_ImageStreamSpec_To_api_ImageStreamSpec,
Convert_api_ImageStreamSpec_To_v1_ImageStreamSpec,
Convert_v1_ImageStreamStatus_To_api_ImageStreamStatus,
Convert_api_ImageStreamStatus_To_v1_ImageStreamStatus,
Convert_api_ImageStreamMapping_To_v1_ImageStreamMapping,
Convert_v1_ImageStreamMapping_To_api_ImageStreamMapping,
)
if err != nil {
// If one of the conversion functions is malformed, detect it immediately.
panic(err)
}
if err := scheme.AddFieldLabelConversionFunc("v1", "Image",
oapi.GetFieldLabelConversionFunc(newer.ImageToSelectableFields(&newer.Image{}), nil),
); err != nil {
panic(err)
}
if err := scheme.AddFieldLabelConversionFunc("v1", "ImageStream",
oapi.GetFieldLabelConversionFunc(newer.ImageStreamToSelectableFields(&newer.ImageStream{}), map[string]string{"name": "metadata.name"}),
); err != nil {
panic(err)
}
}
示例5: addConversionFuncs
func addConversionFuncs(scheme *runtime.Scheme) error {
// Add non-generated conversion functions
err := scheme.AddConversionFuncs(
v1.Convert_v1_DeleteOptions_To_api_DeleteOptions,
v1.Convert_api_DeleteOptions_To_v1_DeleteOptions,
v1.Convert_v1_ExportOptions_To_api_ExportOptions,
v1.Convert_api_ExportOptions_To_v1_ExportOptions,
v1.Convert_v1_List_To_api_List,
v1.Convert_api_List_To_v1_List,
v1.Convert_v1_ListOptions_To_api_ListOptions,
v1.Convert_api_ListOptions_To_v1_ListOptions,
v1.Convert_v1_ObjectFieldSelector_To_api_ObjectFieldSelector,
v1.Convert_api_ObjectFieldSelector_To_v1_ObjectFieldSelector,
v1.Convert_v1_ObjectMeta_To_api_ObjectMeta,
v1.Convert_api_ObjectMeta_To_v1_ObjectMeta,
v1.Convert_v1_ObjectReference_To_api_ObjectReference,
v1.Convert_api_ObjectReference_To_v1_ObjectReference,
v1.Convert_v1_OwnerReference_To_api_OwnerReference,
v1.Convert_api_OwnerReference_To_v1_OwnerReference,
v1.Convert_v1_Secret_To_api_Secret,
v1.Convert_api_Secret_To_v1_Secret,
v1.Convert_v1_SecretList_To_api_SecretList,
v1.Convert_api_SecretList_To_v1_SecretList,
v1.Convert_v1_Service_To_api_Service,
v1.Convert_api_Service_To_v1_Service,
v1.Convert_v1_ServiceList_To_api_ServiceList,
v1.Convert_api_ServiceList_To_v1_ServiceList,
v1.Convert_v1_ServicePort_To_api_ServicePort,
v1.Convert_api_ServicePort_To_v1_ServicePort,
v1.Convert_v1_ServiceProxyOptions_To_api_ServiceProxyOptions,
v1.Convert_api_ServiceProxyOptions_To_v1_ServiceProxyOptions,
v1.Convert_v1_ServiceSpec_To_api_ServiceSpec,
v1.Convert_api_ServiceSpec_To_v1_ServiceSpec,
v1.Convert_v1_ServiceStatus_To_api_ServiceStatus,
v1.Convert_api_ServiceStatus_To_v1_ServiceStatus,
)
if err != nil {
return err
}
// Add field label conversions for kinds having selectable nothing but ObjectMeta fields.
for _, kind := range []string{
"Service",
} {
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
}
}
return nil
}
示例6: addConversionFuncs
func addConversionFuncs(scheme *runtime.Scheme) {
if err := scheme.AddFieldLabelConversionFunc("v1", "BackingServiceInstance",
oapi.GetFieldLabelConversionFunc(backingserviceinstanceapi.BackingServiceInstanceToSelectableFields(&backingserviceinstanceapi.BackingServiceInstance{}), nil),
); err != nil {
panic(err)
}
}
示例7: addConversionFuncs
func addConversionFuncs(scheme *runtime.Scheme) {
scheme.AddConversionFuncs(
Convert_v1_BuildConfig_To_api_BuildConfig,
Convert_api_BuildConfig_To_v1_BuildConfig,
Convert_v1_SourceBuildStrategy_To_api_SourceBuildStrategy,
Convert_api_SourceBuildStrategy_To_v1_SourceBuildStrategy,
Convert_v1_DockerBuildStrategy_To_api_DockerBuildStrategy,
Convert_api_DockerBuildStrategy_To_v1_DockerBuildStrategy,
Convert_v1_CustomBuildStrategy_To_api_CustomBuildStrategy,
Convert_api_CustomBuildStrategy_To_v1_CustomBuildStrategy,
Convert_v1_BuildOutput_To_api_BuildOutput,
Convert_api_BuildOutput_To_v1_BuildOutput,
Convert_v1_BuildTriggerPolicy_To_api_BuildTriggerPolicy,
Convert_api_BuildTriggerPolicy_To_v1_BuildTriggerPolicy,
Convert_v1_SourceRevision_To_api_SourceRevision,
Convert_api_SourceRevision_To_v1_SourceRevision,
Convert_v1_BuildSource_To_api_BuildSource,
Convert_api_BuildSource_To_v1_BuildSource,
Convert_v1_BuildStrategy_To_api_BuildStrategy,
Convert_api_BuildStrategy_To_v1_BuildStrategy,
)
if err := scheme.AddFieldLabelConversionFunc("v1", "Build",
oapi.GetFieldLabelConversionFunc(newer.BuildToSelectableFields(&newer.Build{}), map[string]string{"name": "metadata.name"}),
); err != nil {
panic(err)
}
if err := scheme.AddFieldLabelConversionFunc("v1", "BuildConfig",
oapi.GetFieldLabelConversionFunc(newer.BuildConfigToSelectableFields(&newer.BuildConfig{}), map[string]string{"name": "metadata.name"}),
); err != nil {
panic(err)
}
}
示例8: addConversionFuncs
func addConversionFuncs(scheme *runtime.Scheme) {
if err := scheme.AddFieldLabelConversionFunc("v1", "Template",
oapi.GetFieldLabelConversionFunc(api.TemplateToSelectableFields(&api.Template{}), nil),
); err != nil {
panic(err)
}
}
示例9: addConversionFuncs
func addConversionFuncs(scheme *runtime.Scheme) {
if err := scheme.AddFieldLabelConversionFunc("v1", "ServiceBroker",
oapi.GetFieldLabelConversionFunc(api.ServiceBrokerToSelectableFields(&api.ServiceBroker{}), nil),
); err != nil {
panic(err)
}
}
示例10: addConversionFuncs
func addConversionFuncs(scheme *runtime.Scheme) {
err := scheme.AddDefaultingFuncs(
func(obj *RouteTargetReference) {
if len(obj.Kind) == 0 {
obj.Kind = "Service"
}
if obj.Weight == nil {
obj.Weight = new(int32)
*obj.Weight = 100
}
},
func(obj *TLSConfig) {
if len(obj.Termination) == 0 && len(obj.DestinationCACertificate) == 0 {
obj.Termination = TLSTerminationEdge
}
switch obj.Termination {
case TLSTerminationType("Reencrypt"):
obj.Termination = TLSTerminationReencrypt
case TLSTerminationType("Edge"):
obj.Termination = TLSTerminationEdge
case TLSTerminationType("Passthrough"):
obj.Termination = TLSTerminationPassthrough
}
},
)
if err != nil {
panic(err)
}
err = scheme.AddConversionFuncs()
if err != nil {
panic(err)
}
// Add field conversion funcs.
err = scheme.AddFieldLabelConversionFunc("v1beta3", "Route",
func(label, value string) (string, string, error) {
switch label {
case "metadata.name",
"spec.host",
"spec.path",
"spec.to.name":
return label, value, nil
// This is for backwards compatibility with old v1 clients which send spec.host
default:
return "", "", fmt.Errorf("field label not supported: %s", label)
}
})
if err != nil {
// If one of the conversion functions is malformed, detect it immediately.
panic(err)
}
}
示例11: addConversionFuncs
func addConversionFuncs(scheme *runtime.Scheme) error {
return scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.String(), "Cluster",
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)
}
},
)
}
示例12: AddFieldLabelConversionsForNamespace
func AddFieldLabelConversionsForNamespace(scheme *runtime.Scheme) error {
return scheme.AddFieldLabelConversionFunc("v1", "Namespace",
func(label, value string) (string, string, error) {
switch label {
case "status.phase",
"metadata.name":
return label, value, nil
default:
return "", "", fmt.Errorf("field label not supported: %s", label)
}
})
}
示例13: addConversionFuncs
func addConversionFuncs(scheme *runtime.Scheme) error {
if err := scheme.AddFieldLabelConversionFunc("v1", "OAuthAccessToken",
oapi.GetFieldLabelConversionFunc(api.OAuthAccessTokenToSelectableFields(&api.OAuthAccessToken{}), nil),
); err != nil {
return err
}
if err := scheme.AddFieldLabelConversionFunc("v1", "OAuthAuthorizeToken",
oapi.GetFieldLabelConversionFunc(api.OAuthAuthorizeTokenToSelectableFields(&api.OAuthAuthorizeToken{}), nil),
); err != nil {
return err
}
if err := scheme.AddFieldLabelConversionFunc("v1", "OAuthClient",
oapi.GetFieldLabelConversionFunc(api.OAuthClientToSelectableFields(&api.OAuthClient{}), nil),
); err != nil {
return err
}
if err := scheme.AddFieldLabelConversionFunc("v1", "OAuthClientAuthorization",
oapi.GetFieldLabelConversionFunc(api.OAuthClientAuthorizationToSelectableFields(&api.OAuthClientAuthorization{}), nil),
); err != nil {
return err
}
return nil
}
示例14: addConversionFuncs
func addConversionFuncs(scheme *runtime.Scheme) {
if err := scheme.AddFieldLabelConversionFunc("v1", "ClusterNetwork",
oapi.GetFieldLabelConversionFunc(api.ClusterNetworkToSelectableFields(&api.ClusterNetwork{}), nil),
); err != nil {
panic(err)
}
if err := scheme.AddFieldLabelConversionFunc("v1", "HostSubnet",
oapi.GetFieldLabelConversionFunc(api.HostSubnetToSelectableFields(&api.HostSubnet{}), nil),
); err != nil {
panic(err)
}
if err := scheme.AddFieldLabelConversionFunc("v1", "NetNamespace",
oapi.GetFieldLabelConversionFunc(api.NetNamespaceToSelectableFields(&api.NetNamespace{}), nil),
); err != nil {
panic(err)
}
if err := scheme.AddFieldLabelConversionFunc("v1", "EgressNetworkPolicy",
oapi.GetFieldLabelConversionFunc(api.EgressNetworkPolicyToSelectableFields(&api.EgressNetworkPolicy{}), nil),
); err != nil {
panic(err)
}
}
示例15: addConversionFuncs
func addConversionFuncs(scheme *runtime.Scheme) {
err := scheme.AddConversionFuncs(
Convert_api_Template_To_v1_Template,
Convert_v1_Template_To_api_Template,
)
if err != nil {
panic(err)
}
if err := scheme.AddFieldLabelConversionFunc("v1", "Template",
oapi.GetFieldLabelConversionFunc(newer.TemplateToSelectableFields(&newer.Template{}), nil),
); err != nil {
panic(err)
}
}