conversion.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. "fmt"
  16. "k8s.io/apimachinery/pkg/conversion"
  17. "k8s.io/kube-scheduler/config/v1alpha1"
  18. "k8s.io/kubernetes/pkg/scheduler/apis/config"
  19. )
  20. // Convert_v1alpha1_KubeSchedulerLeaderElectionConfiguration_To_config_KubeSchedulerLeaderElectionConfiguration is an autogenerated conversion function.
  21. func Convert_v1alpha1_KubeSchedulerLeaderElectionConfiguration_To_config_KubeSchedulerLeaderElectionConfiguration(in *v1alpha1.KubeSchedulerLeaderElectionConfiguration, out *config.KubeSchedulerLeaderElectionConfiguration, s conversion.Scope) error {
  22. if err := autoConvert_v1alpha1_KubeSchedulerLeaderElectionConfiguration_To_config_KubeSchedulerLeaderElectionConfiguration(in, out, s); err != nil {
  23. return err
  24. }
  25. if len(in.ResourceNamespace) > 0 && len(in.LockObjectNamespace) == 0 {
  26. out.ResourceNamespace = in.ResourceNamespace
  27. } else if len(in.ResourceNamespace) == 0 && len(in.LockObjectNamespace) > 0 {
  28. out.ResourceNamespace = in.LockObjectNamespace
  29. } else if len(in.ResourceNamespace) > 0 && len(in.LockObjectNamespace) > 0 {
  30. if in.ResourceNamespace == in.LockObjectNamespace {
  31. out.ResourceNamespace = in.ResourceNamespace
  32. } else {
  33. return fmt.Errorf("ResourceNamespace and LockObjectNamespace are both set and do not match, ResourceNamespace: %s, LockObjectNamespace: %s", in.ResourceNamespace, in.LockObjectNamespace)
  34. }
  35. }
  36. if len(in.ResourceName) > 0 && len(in.LockObjectName) == 0 {
  37. out.ResourceName = in.ResourceName
  38. } else if len(in.ResourceName) == 0 && len(in.LockObjectName) > 0 {
  39. out.ResourceName = in.LockObjectName
  40. } else if len(in.ResourceName) > 0 && len(in.LockObjectName) > 0 {
  41. if in.ResourceName == in.LockObjectName {
  42. out.ResourceName = in.ResourceName
  43. } else {
  44. return fmt.Errorf("ResourceName and LockObjectName are both set and do not match, ResourceName: %s, LockObjectName: %s", in.ResourceName, in.LockObjectName)
  45. }
  46. }
  47. return nil
  48. }
  49. // Convert_config_KubeSchedulerLeaderElectionConfiguration_To_v1alpha1_KubeSchedulerLeaderElectionConfiguration is an autogenerated conversion function.
  50. func Convert_config_KubeSchedulerLeaderElectionConfiguration_To_v1alpha1_KubeSchedulerLeaderElectionConfiguration(in *config.KubeSchedulerLeaderElectionConfiguration, out *v1alpha1.KubeSchedulerLeaderElectionConfiguration, s conversion.Scope) error {
  51. if err := autoConvert_config_KubeSchedulerLeaderElectionConfiguration_To_v1alpha1_KubeSchedulerLeaderElectionConfiguration(in, out, s); err != nil {
  52. return err
  53. }
  54. out.ResourceNamespace = in.ResourceNamespace
  55. out.LockObjectNamespace = in.ResourceNamespace
  56. out.ResourceName = in.ResourceName
  57. out.LockObjectName = in.ResourceName
  58. return nil
  59. }