...

Source file src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/deepcopy.go

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

     1  /*
     2  Copyright 2017 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 apiextensions
    18  
    19  import "k8s.io/apimachinery/pkg/runtime"
    20  
    21  // TODO: Update this after a tag is created for interface fields in DeepCopy
    22  func (in *JSONSchemaProps) DeepCopy() *JSONSchemaProps {
    23  	if in == nil {
    24  		return nil
    25  	}
    26  	out := new(JSONSchemaProps)
    27  
    28  	*out = *in
    29  
    30  	if in.Default != nil {
    31  		defaultJSON := JSON(runtime.DeepCopyJSONValue(*(in.Default)))
    32  		out.Default = &(defaultJSON)
    33  	} else {
    34  		out.Default = nil
    35  	}
    36  
    37  	if in.Example != nil {
    38  		exampleJSON := JSON(runtime.DeepCopyJSONValue(*(in.Example)))
    39  		out.Example = &(exampleJSON)
    40  	} else {
    41  		out.Example = nil
    42  	}
    43  
    44  	if in.Ref != nil {
    45  		in, out := &in.Ref, &out.Ref
    46  		if *in == nil {
    47  			*out = nil
    48  		} else {
    49  			*out = new(string)
    50  			**out = **in
    51  		}
    52  	}
    53  
    54  	if in.Maximum != nil {
    55  		in, out := &in.Maximum, &out.Maximum
    56  		if *in == nil {
    57  			*out = nil
    58  		} else {
    59  			*out = new(float64)
    60  			**out = **in
    61  		}
    62  	}
    63  
    64  	if in.Minimum != nil {
    65  		in, out := &in.Minimum, &out.Minimum
    66  		if *in == nil {
    67  			*out = nil
    68  		} else {
    69  			*out = new(float64)
    70  			**out = **in
    71  		}
    72  	}
    73  
    74  	if in.MaxLength != nil {
    75  		in, out := &in.MaxLength, &out.MaxLength
    76  		if *in == nil {
    77  			*out = nil
    78  		} else {
    79  			*out = new(int64)
    80  			**out = **in
    81  		}
    82  	}
    83  
    84  	if in.MinLength != nil {
    85  		in, out := &in.MinLength, &out.MinLength
    86  		if *in == nil {
    87  			*out = nil
    88  		} else {
    89  			*out = new(int64)
    90  			**out = **in
    91  		}
    92  	}
    93  	if in.MaxItems != nil {
    94  		in, out := &in.MaxItems, &out.MaxItems
    95  		if *in == nil {
    96  			*out = nil
    97  		} else {
    98  			*out = new(int64)
    99  			**out = **in
   100  		}
   101  	}
   102  
   103  	if in.MinItems != nil {
   104  		in, out := &in.MinItems, &out.MinItems
   105  		if *in == nil {
   106  			*out = nil
   107  		} else {
   108  			*out = new(int64)
   109  			**out = **in
   110  		}
   111  	}
   112  
   113  	if in.MultipleOf != nil {
   114  		in, out := &in.MultipleOf, &out.MultipleOf
   115  		if *in == nil {
   116  			*out = nil
   117  		} else {
   118  			*out = new(float64)
   119  			**out = **in
   120  		}
   121  	}
   122  
   123  	if in.Enum != nil {
   124  		out.Enum = make([]JSON, len(in.Enum))
   125  		for i := range in.Enum {
   126  			out.Enum[i] = runtime.DeepCopyJSONValue(in.Enum[i])
   127  		}
   128  	}
   129  
   130  	if in.MaxProperties != nil {
   131  		in, out := &in.MaxProperties, &out.MaxProperties
   132  		if *in == nil {
   133  			*out = nil
   134  		} else {
   135  			*out = new(int64)
   136  			**out = **in
   137  		}
   138  	}
   139  
   140  	if in.MinProperties != nil {
   141  		in, out := &in.MinProperties, &out.MinProperties
   142  		if *in == nil {
   143  			*out = nil
   144  		} else {
   145  			*out = new(int64)
   146  			**out = **in
   147  		}
   148  	}
   149  
   150  	if in.Required != nil {
   151  		in, out := &in.Required, &out.Required
   152  		*out = make([]string, len(*in))
   153  		copy(*out, *in)
   154  	}
   155  
   156  	if in.Items != nil {
   157  		in, out := &in.Items, &out.Items
   158  		if *in == nil {
   159  			*out = nil
   160  		} else {
   161  			*out = new(JSONSchemaPropsOrArray)
   162  			(*in).DeepCopyInto(*out)
   163  		}
   164  	}
   165  
   166  	if in.AllOf != nil {
   167  		in, out := &in.AllOf, &out.AllOf
   168  		*out = make([]JSONSchemaProps, len(*in))
   169  		for i := range *in {
   170  			(*in)[i].DeepCopyInto(&(*out)[i])
   171  		}
   172  	}
   173  
   174  	if in.OneOf != nil {
   175  		in, out := &in.OneOf, &out.OneOf
   176  		*out = make([]JSONSchemaProps, len(*in))
   177  		for i := range *in {
   178  			(*in)[i].DeepCopyInto(&(*out)[i])
   179  		}
   180  	}
   181  	if in.AnyOf != nil {
   182  		in, out := &in.AnyOf, &out.AnyOf
   183  		*out = make([]JSONSchemaProps, len(*in))
   184  		for i := range *in {
   185  			(*in)[i].DeepCopyInto(&(*out)[i])
   186  		}
   187  	}
   188  
   189  	if in.Not != nil {
   190  		in, out := &in.Not, &out.Not
   191  		if *in == nil {
   192  			*out = nil
   193  		} else {
   194  			*out = new(JSONSchemaProps)
   195  			(*in).DeepCopyInto(*out)
   196  		}
   197  	}
   198  
   199  	if in.Properties != nil {
   200  		in, out := &in.Properties, &out.Properties
   201  		*out = make(map[string]JSONSchemaProps, len(*in))
   202  		for key, val := range *in {
   203  			(*out)[key] = *val.DeepCopy()
   204  		}
   205  	}
   206  
   207  	if in.AdditionalProperties != nil {
   208  		in, out := &in.AdditionalProperties, &out.AdditionalProperties
   209  		if *in == nil {
   210  			*out = nil
   211  		} else {
   212  			*out = new(JSONSchemaPropsOrBool)
   213  			(*in).DeepCopyInto(*out)
   214  		}
   215  	}
   216  
   217  	if in.PatternProperties != nil {
   218  		in, out := &in.PatternProperties, &out.PatternProperties
   219  		*out = make(map[string]JSONSchemaProps, len(*in))
   220  		for key, val := range *in {
   221  			(*out)[key] = *val.DeepCopy()
   222  		}
   223  	}
   224  
   225  	if in.Dependencies != nil {
   226  		in, out := &in.Dependencies, &out.Dependencies
   227  		*out = make(JSONSchemaDependencies, len(*in))
   228  		for key, val := range *in {
   229  			(*out)[key] = *val.DeepCopy()
   230  		}
   231  	}
   232  
   233  	if in.AdditionalItems != nil {
   234  		in, out := &in.AdditionalItems, &out.AdditionalItems
   235  		if *in == nil {
   236  			*out = nil
   237  		} else {
   238  			*out = new(JSONSchemaPropsOrBool)
   239  			(*in).DeepCopyInto(*out)
   240  		}
   241  	}
   242  
   243  	if in.Definitions != nil {
   244  		in, out := &in.Definitions, &out.Definitions
   245  		*out = make(JSONSchemaDefinitions, len(*in))
   246  		for key, val := range *in {
   247  			(*out)[key] = *val.DeepCopy()
   248  		}
   249  	}
   250  
   251  	if in.ExternalDocs != nil {
   252  		in, out := &in.ExternalDocs, &out.ExternalDocs
   253  		if *in == nil {
   254  			*out = nil
   255  		} else {
   256  			*out = new(ExternalDocumentation)
   257  			(*in).DeepCopyInto(*out)
   258  		}
   259  	}
   260  
   261  	if in.XPreserveUnknownFields != nil {
   262  		in, out := &in.XPreserveUnknownFields, &out.XPreserveUnknownFields
   263  		if *in == nil {
   264  			*out = nil
   265  		} else {
   266  			*out = new(bool)
   267  			**out = **in
   268  		}
   269  	}
   270  
   271  	if in.XListMapKeys != nil {
   272  		in, out := &in.XListMapKeys, &out.XListMapKeys
   273  		*out = make([]string, len(*in))
   274  		copy(*out, *in)
   275  	}
   276  
   277  	if in.XListType != nil {
   278  		in, out := &in.XListType, &out.XListType
   279  		if *in == nil {
   280  			*out = nil
   281  		} else {
   282  			*out = new(string)
   283  			**out = **in
   284  		}
   285  	}
   286  
   287  	if in.XMapType != nil {
   288  		in, out := &in.XMapType, &out.XMapType
   289  		*out = new(string)
   290  		**out = **in
   291  	}
   292  
   293  	if in.XValidations != nil {
   294  		inValidations, outValidations := &in.XValidations, &out.XValidations
   295  		*outValidations = make([]ValidationRule, len(*inValidations))
   296  		for i := range *inValidations {
   297  			in.XValidations[i].DeepCopyInto(&out.XValidations[i])
   298  		}
   299  	}
   300  
   301  	return out
   302  }
   303  

View as plain text