-
Notifications
You must be signed in to change notification settings - Fork 38.7k
/
conversion.go
68 lines (59 loc) · 3.19 KB
/
conversion.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
Copyright 2019 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1alpha1
import (
"fmt"
conversion "k8s.io/apimachinery/pkg/conversion"
v1alpha1 "k8s.io/kube-scheduler/config/v1alpha1"
config "k8s.io/kubernetes/pkg/scheduler/apis/config"
)
// Convert_v1alpha1_KubeSchedulerLeaderElectionConfiguration_To_config_KubeSchedulerLeaderElectionConfiguration is an autogenerated conversion function.
func Convert_v1alpha1_KubeSchedulerLeaderElectionConfiguration_To_config_KubeSchedulerLeaderElectionConfiguration(in *v1alpha1.KubeSchedulerLeaderElectionConfiguration, out *config.KubeSchedulerLeaderElectionConfiguration, s conversion.Scope) error {
if err := autoConvert_v1alpha1_KubeSchedulerLeaderElectionConfiguration_To_config_KubeSchedulerLeaderElectionConfiguration(in, out, s); err != nil {
return err
}
if len(in.ResourceNamespace) > 0 && len(in.LockObjectNamespace) == 0 {
out.ResourceNamespace = in.ResourceNamespace
} else if len(in.ResourceNamespace) == 0 && len(in.LockObjectNamespace) > 0 {
out.ResourceNamespace = in.LockObjectNamespace
} else if len(in.ResourceNamespace) > 0 && len(in.LockObjectNamespace) > 0 {
if in.ResourceNamespace == in.LockObjectNamespace {
out.ResourceNamespace = in.ResourceNamespace
} else {
return fmt.Errorf("ResourceNamespace and LockObjectNamespace are both set and do not match, ResourceNamespace: %s, LockObjectNamespace: %s", in.ResourceNamespace, in.LockObjectNamespace)
}
}
if len(in.ResourceName) > 0 && len(in.LockObjectName) == 0 {
out.ResourceName = in.ResourceName
} else if len(in.ResourceName) == 0 && len(in.LockObjectName) > 0 {
out.ResourceName = in.LockObjectName
} else if len(in.ResourceName) > 0 && len(in.LockObjectName) > 0 {
if in.ResourceName == in.LockObjectName {
out.ResourceName = in.ResourceName
} else {
return fmt.Errorf("ResourceName and LockObjectName are both set and do not match, ResourceName: %s, LockObjectName: %s", in.ResourceName, in.LockObjectName)
}
}
return nil
}
// Convert_config_KubeSchedulerLeaderElectionConfiguration_To_v1alpha1_KubeSchedulerLeaderElectionConfiguration is an autogenerated conversion function.
func Convert_config_KubeSchedulerLeaderElectionConfiguration_To_v1alpha1_KubeSchedulerLeaderElectionConfiguration(in *config.KubeSchedulerLeaderElectionConfiguration, out *v1alpha1.KubeSchedulerLeaderElectionConfiguration, s conversion.Scope) error {
if err := autoConvert_config_KubeSchedulerLeaderElectionConfiguration_To_v1alpha1_KubeSchedulerLeaderElectionConfiguration(in, out, s); err != nil {
return err
}
out.ResourceNamespace = in.ResourceNamespace
out.LockObjectNamespace = in.ResourceNamespace
out.ResourceName = in.ResourceName
out.LockObjectName = in.ResourceName
return nil
}