mirror of
https://github.com/kubernetes-sigs/descheduler.git
synced 2026-01-26 21:31:18 +01:00
add v1alpha2 registry based conversion (#1006)
* add v1alpha2 registry based conversion * test defaults, set our 1st explicit default * fix typos and dates * move pluginregistry to its own dir * remove unused v1alpha2.Namespace type * move migration code folders, remove switch * validate internalPolicy a single time * remove structured logs * simplify return * check for nil methods * properly check before adding default evictor * add TODO comment * bump copyright year
This commit is contained in:
committed by
GitHub
parent
861c6325f3
commit
137f3b20dc
@@ -15,6 +15,7 @@ package removefailedpods
|
||||
|
||||
import (
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
utilpointer "k8s.io/utils/pointer"
|
||||
)
|
||||
|
||||
func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||
@@ -23,23 +24,24 @@ func addDefaultingFuncs(scheme *runtime.Scheme) error {
|
||||
|
||||
// SetDefaults_RemoveFailedPodsArgs
|
||||
// TODO: the final default values would be discussed in community
|
||||
func SetDefaults_RemoveFailedPodsArgs(obj *RemoveFailedPodsArgs) {
|
||||
if obj.Namespaces == nil {
|
||||
obj.Namespaces = nil
|
||||
func SetDefaults_RemoveFailedPodsArgs(obj runtime.Object) {
|
||||
args := obj.(*RemoveFailedPodsArgs)
|
||||
if args.Namespaces == nil {
|
||||
args.Namespaces = nil
|
||||
}
|
||||
if obj.LabelSelector == nil {
|
||||
obj.LabelSelector = nil
|
||||
if args.LabelSelector == nil {
|
||||
args.LabelSelector = nil
|
||||
}
|
||||
if obj.ExcludeOwnerKinds == nil {
|
||||
obj.ExcludeOwnerKinds = nil
|
||||
if args.ExcludeOwnerKinds == nil {
|
||||
args.ExcludeOwnerKinds = nil
|
||||
}
|
||||
if obj.MinPodLifetimeSeconds == nil {
|
||||
obj.MinPodLifetimeSeconds = nil
|
||||
if args.MinPodLifetimeSeconds == nil {
|
||||
args.MinPodLifetimeSeconds = utilpointer.Uint(3600)
|
||||
}
|
||||
if obj.Reasons == nil {
|
||||
obj.Reasons = nil
|
||||
if args.Reasons == nil {
|
||||
args.Reasons = nil
|
||||
}
|
||||
if !obj.IncludingInitContainers {
|
||||
obj.IncludingInitContainers = false
|
||||
if !args.IncludingInitContainers {
|
||||
args.IncludingInitContainers = false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,12 @@ import (
|
||||
"fmt"
|
||||
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
// ValidateRemoveFailedPodsArgs validates RemoveFailedPods arguments
|
||||
func ValidateRemoveFailedPodsArgs(args *RemoveFailedPodsArgs) error {
|
||||
func ValidateRemoveFailedPodsArgs(obj runtime.Object) error {
|
||||
args := obj.(*RemoveFailedPodsArgs)
|
||||
// At most one of include/exclude can be set
|
||||
if args.Namespaces != nil && len(args.Namespaces.Include) > 0 && len(args.Namespaces.Exclude) > 0 {
|
||||
return fmt.Errorf("only one of Include/Exclude namespaces can be set")
|
||||
|
||||
@@ -29,10 +29,5 @@ import (
|
||||
// Public to allow building arbitrary schemes.
|
||||
// All generated defaulters are covering - they call all nested defaulters.
|
||||
func RegisterDefaults(scheme *runtime.Scheme) error {
|
||||
scheme.AddTypeDefaultingFunc(&RemoveFailedPodsArgs{}, func(obj interface{}) { SetObjectDefaults_RemoveFailedPodsArgs(obj.(*RemoveFailedPodsArgs)) })
|
||||
return nil
|
||||
}
|
||||
|
||||
func SetObjectDefaults_RemoveFailedPodsArgs(in *RemoveFailedPodsArgs) {
|
||||
SetDefaults_RemoveFailedPodsArgs(in)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user