conversion.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. Copyright 2019 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package v1alpha1
  14. import (
  15. v1alpha1 "k8s.io/api/node/v1alpha1"
  16. conversion "k8s.io/apimachinery/pkg/conversion"
  17. node "k8s.io/kubernetes/pkg/apis/node"
  18. )
  19. // Convert_v1alpha1_RuntimeClass_To_node_RuntimeClass must override the automatic
  20. // conversion since we unnested the spec struct after v1alpha1
  21. func Convert_v1alpha1_RuntimeClass_To_node_RuntimeClass(in *v1alpha1.RuntimeClass, out *node.RuntimeClass, s conversion.Scope) error {
  22. out.ObjectMeta = in.ObjectMeta
  23. out.Handler = in.Spec.RuntimeHandler
  24. if in.Spec.Overhead != nil {
  25. out.Overhead = &node.Overhead{}
  26. if err := Convert_v1alpha1_Overhead_To_node_Overhead(in.Spec.Overhead, out.Overhead, s); err != nil {
  27. return err
  28. }
  29. }
  30. if in.Spec.Scheduling != nil {
  31. out.Scheduling = &node.Scheduling{}
  32. if err := Convert_v1alpha1_Scheduling_To_node_Scheduling(in.Spec.Scheduling, out.Scheduling, s); err != nil {
  33. return err
  34. }
  35. }
  36. return nil
  37. }
  38. // Convert_node_RuntimeClass_To_v1alpha1_RuntimeClass must override the automatic
  39. // conversion since we unnested the spec struct after v1alpha1
  40. func Convert_node_RuntimeClass_To_v1alpha1_RuntimeClass(in *node.RuntimeClass, out *v1alpha1.RuntimeClass, s conversion.Scope) error {
  41. out.ObjectMeta = in.ObjectMeta
  42. out.Spec.RuntimeHandler = in.Handler
  43. if in.Overhead != nil {
  44. out.Spec.Overhead = &v1alpha1.Overhead{}
  45. if err := Convert_node_Overhead_To_v1alpha1_Overhead(in.Overhead, out.Spec.Overhead, s); err != nil {
  46. return err
  47. }
  48. }
  49. if in.Scheduling != nil {
  50. out.Spec.Scheduling = &v1alpha1.Scheduling{}
  51. if err := Convert_node_Scheduling_To_v1alpha1_Scheduling(in.Scheduling, out.Spec.Scheduling, s); err != nil {
  52. return err
  53. }
  54. }
  55. return nil
  56. }