...

Source file src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/skeleton.go

Documentation: k8s.io/apiextensions-apiserver/pkg/apiserver/schema

     1  /*
     2  Copyright 2019 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 schema
    18  
    19  // StripValueValidations returns a copy without value validations.
    20  func (s *Structural) StripValueValidations() *Structural {
    21  	s = s.DeepCopy()
    22  	v := Visitor{
    23  		Structural: func(s *Structural) bool {
    24  			changed := false
    25  			if s.ValueValidation != nil {
    26  				s.ValueValidation = nil
    27  				changed = true
    28  			}
    29  			return changed
    30  		},
    31  	}
    32  	v.Visit(s)
    33  	return s
    34  }
    35  
    36  // StripNullable returns a copy without nullable.
    37  func (s *Structural) StripNullable() *Structural {
    38  	s = s.DeepCopy()
    39  	v := Visitor{
    40  		Structural: func(s *Structural) bool {
    41  			changed := s.Nullable
    42  			s.Nullable = false
    43  			return changed
    44  		},
    45  	}
    46  	v.Visit(s)
    47  	return s
    48  }
    49  

View as plain text