Files
kubernetes/pkg/scheduler/apis/config/v1alpha2/conversion.go
Aldo Culquicondor 11c4bcd9dd Copy kubescheduler.config.k8s.io/v1alpha1 files onto v1alpha2
Signed-off-by: Aldo Culquicondor <acondor@google.com>
2020-01-29 17:18:41 -05:00

69 lines
3.2 KiB
Go

/*
Copyright 2020 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 v1alpha2
import (
"fmt"
"k8s.io/apimachinery/pkg/conversion"
"k8s.io/kube-scheduler/config/v1alpha2"
"k8s.io/kubernetes/pkg/scheduler/apis/config"
)
// Convert_v1alpha2_KubeSchedulerLeaderElectionConfiguration_To_config_KubeSchedulerLeaderElectionConfiguration is an autogenerated conversion function.
func Convert_v1alpha2_KubeSchedulerLeaderElectionConfiguration_To_config_KubeSchedulerLeaderElectionConfiguration(in *v1alpha2.KubeSchedulerLeaderElectionConfiguration, out *config.KubeSchedulerLeaderElectionConfiguration, s conversion.Scope) error {
if err := autoConvert_v1alpha2_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_v1alpha2_KubeSchedulerLeaderElectionConfiguration is an autogenerated conversion function.
func Convert_config_KubeSchedulerLeaderElectionConfiguration_To_v1alpha2_KubeSchedulerLeaderElectionConfiguration(in *config.KubeSchedulerLeaderElectionConfiguration, out *v1alpha2.KubeSchedulerLeaderElectionConfiguration, s conversion.Scope) error {
if err := autoConvert_config_KubeSchedulerLeaderElectionConfiguration_To_v1alpha2_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
}