...

Source file src/k8s.io/kubernetes/pkg/apis/admissionregistration/v1alpha1/defaults.go

Documentation: k8s.io/kubernetes/pkg/apis/admissionregistration/v1alpha1

     1  /*
     2  Copyright 2022 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 v1alpha1
    18  
    19  import (
    20  	admissionregistrationv1alpha1 "k8s.io/api/admissionregistration/v1alpha1"
    21  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    22  	"k8s.io/apimachinery/pkg/runtime"
    23  )
    24  
    25  func addDefaultingFuncs(scheme *runtime.Scheme) error {
    26  	return RegisterDefaults(scheme)
    27  }
    28  
    29  // SetDefaults_ValidatingAdmissionPolicySpec sets defaults for ValidatingAdmissionPolicySpec
    30  func SetDefaults_ValidatingAdmissionPolicySpec(obj *admissionregistrationv1alpha1.ValidatingAdmissionPolicySpec) {
    31  	if obj.FailurePolicy == nil {
    32  		policy := admissionregistrationv1alpha1.Fail
    33  		obj.FailurePolicy = &policy
    34  	}
    35  }
    36  
    37  // SetDefaults_MatchResources sets defaults for MatchResources
    38  func SetDefaults_MatchResources(obj *admissionregistrationv1alpha1.MatchResources) {
    39  	if obj.MatchPolicy == nil {
    40  		policy := admissionregistrationv1alpha1.Equivalent
    41  		obj.MatchPolicy = &policy
    42  	}
    43  	if obj.NamespaceSelector == nil {
    44  		selector := metav1.LabelSelector{}
    45  		obj.NamespaceSelector = &selector
    46  	}
    47  	if obj.ObjectSelector == nil {
    48  		selector := metav1.LabelSelector{}
    49  		obj.ObjectSelector = &selector
    50  	}
    51  }
    52  
    53  // SetDefaults_ParamRef sets defaults for ParamRef
    54  func SetDefaults_ParamRef(obj *admissionregistrationv1alpha1.ParamRef) {
    55  	if obj.ParameterNotFoundAction == nil {
    56  		v := admissionregistrationv1alpha1.DenyAction
    57  		obj.ParameterNotFoundAction = &v
    58  	}
    59  }
    60  

View as plain text