k8s.io/kubernetes@v1.29.3/pkg/apis/node/v1alpha1/conversion.go (about) 1 /* 2 Copyright 2019 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 v1alpha1 18 19 import ( 20 v1alpha1 "k8s.io/api/node/v1alpha1" 21 conversion "k8s.io/apimachinery/pkg/conversion" 22 node "k8s.io/kubernetes/pkg/apis/node" 23 ) 24 25 // Convert_v1alpha1_RuntimeClass_To_node_RuntimeClass must override the automatic 26 // conversion since we unnested the spec struct after v1alpha1 27 func Convert_v1alpha1_RuntimeClass_To_node_RuntimeClass(in *v1alpha1.RuntimeClass, out *node.RuntimeClass, s conversion.Scope) error { 28 out.ObjectMeta = in.ObjectMeta 29 out.Handler = in.Spec.RuntimeHandler 30 31 if in.Spec.Overhead != nil { 32 out.Overhead = &node.Overhead{} 33 if err := Convert_v1alpha1_Overhead_To_node_Overhead(in.Spec.Overhead, out.Overhead, s); err != nil { 34 return err 35 } 36 } 37 if in.Spec.Scheduling != nil { 38 out.Scheduling = &node.Scheduling{} 39 if err := Convert_v1alpha1_Scheduling_To_node_Scheduling(in.Spec.Scheduling, out.Scheduling, s); err != nil { 40 return err 41 } 42 } 43 return nil 44 } 45 46 // Convert_node_RuntimeClass_To_v1alpha1_RuntimeClass must override the automatic 47 // conversion since we unnested the spec struct after v1alpha1 48 func Convert_node_RuntimeClass_To_v1alpha1_RuntimeClass(in *node.RuntimeClass, out *v1alpha1.RuntimeClass, s conversion.Scope) error { 49 out.ObjectMeta = in.ObjectMeta 50 out.Spec.RuntimeHandler = in.Handler 51 52 if in.Overhead != nil { 53 out.Spec.Overhead = &v1alpha1.Overhead{} 54 if err := Convert_node_Overhead_To_v1alpha1_Overhead(in.Overhead, out.Spec.Overhead, s); err != nil { 55 return err 56 } 57 } 58 if in.Scheduling != nil { 59 out.Spec.Scheduling = &v1alpha1.Scheduling{} 60 if err := Convert_node_Scheduling_To_v1alpha1_Scheduling(in.Scheduling, out.Spec.Scheduling, s); err != nil { 61 return err 62 } 63 } 64 return nil 65 }