...

Source file src/k8s.io/kubernetes/pkg/apis/policy/v1/conversion.go

Documentation: k8s.io/kubernetes/pkg/apis/policy/v1

     1  /*
     2  Copyright 2021 The Kubernetes Authors.
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package v1
    18  
    19  import (
    20  	"k8s.io/api/policy/v1"
    21  	apiequality "k8s.io/apimachinery/pkg/api/equality"
    22  	"k8s.io/apimachinery/pkg/conversion"
    23  	"k8s.io/kubernetes/pkg/apis/policy"
    24  )
    25  
    26  func Convert_v1_PodDisruptionBudget_To_policy_PodDisruptionBudget(in *v1.PodDisruptionBudget, out *policy.PodDisruptionBudget, s conversion.Scope) error {
    27  	if err := autoConvert_v1_PodDisruptionBudget_To_policy_PodDisruptionBudget(in, out, s); err != nil {
    28  		return err
    29  	}
    30  
    31  	switch {
    32  	case apiequality.Semantic.DeepEqual(in.Spec.Selector, policy.NonV1beta1MatchNoneSelector):
    33  		// no-op, preserve
    34  	case apiequality.Semantic.DeepEqual(in.Spec.Selector, policy.NonV1beta1MatchAllSelector):
    35  		// no-op, preserve
    36  	default:
    37  		// otherwise, make sure the label intended to be used in a match-all or match-none selector
    38  		// never gets combined with user-specified fields
    39  		policy.StripPDBV1beta1Label(out.Spec.Selector)
    40  	}
    41  	return nil
    42  }
    43  

View as plain text