k8s.io/kubernetes@v1.29.3/pkg/apis/batch/v1/conversion.go (about) 1 /* 2 Copyright 2015 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package v1 18 19 import ( 20 "fmt" 21 22 v1 "k8s.io/api/batch/v1" 23 "k8s.io/apimachinery/pkg/conversion" 24 "k8s.io/apimachinery/pkg/runtime" 25 "k8s.io/kubernetes/pkg/apis/batch" 26 ) 27 28 func addConversionFuncs(scheme *runtime.Scheme) error { 29 return scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("Job"), 30 func(label, value string) (string, string, error) { 31 switch label { 32 case "metadata.name", "metadata.namespace", "status.successful": 33 return label, value, nil 34 default: 35 return "", "", fmt.Errorf("field label %q not supported for Job", label) 36 } 37 }) 38 } 39 40 // The following functions don't do anything special, but they need to be added 41 // here due to the dependency of v1beta1 on v1. 42 43 func Convert_batch_JobSpec_To_v1_JobSpec(in *batch.JobSpec, out *v1.JobSpec, s conversion.Scope) error { 44 return autoConvert_batch_JobSpec_To_v1_JobSpec(in, out, s) 45 } 46 47 func Convert_v1_JobSpec_To_batch_JobSpec(in *v1.JobSpec, out *batch.JobSpec, s conversion.Scope) error { 48 return autoConvert_v1_JobSpec_To_batch_JobSpec(in, out, s) 49 }