From 896c670fb9bbff97f5551192c774e82bd82ad0cc Mon Sep 17 00:00:00 2001 From: Mike Danese Date: Mon, 1 Feb 2016 15:19:39 -0800 Subject: [PATCH] conversion: add default conversion for {string,bool} ptr to {string,bool} This is useful because it allows defaulting to infer wheter a string,bool value was provided by the user while still having the field represented as a non pointer type in the internal representation. --- pkg/api/conversion.go | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/pkg/api/conversion.go b/pkg/api/conversion.go index f6c95d0493f..5599db3460f 100644 --- a/pkg/api/conversion.go +++ b/pkg/api/conversion.go @@ -43,12 +43,54 @@ func init() { Convert_unversioned_Time_To_unversioned_Time, Convert_string_To_labels_Selector, Convert_string_To_fields_Selector, + Convert_bool_ref_To_bool, + Convert_bool_To_bool_ref, + Convert_string_ref_To_string, + Convert_string_To_string_ref, Convert_labels_Selector_To_string, Convert_fields_Selector_To_string, Convert_resource_Quantity_To_resource_Quantity, ) } +func Convert_string_ref_To_string(in **string, out *string, s conversion.Scope) error { + if *in == nil { + *out = "" + return nil + } + *out = **in + return nil +} + +func Convert_string_To_string_ref(in *string, out **string, s conversion.Scope) error { + if in == nil { + stringVar := "" + *out = &stringVar + return nil + } + *out = in + return nil +} + +func Convert_bool_ref_To_bool(in **bool, out *bool, s conversion.Scope) error { + if *in == nil { + *out = false + return nil + } + *out = **in + return nil +} + +func Convert_bool_To_bool_ref(in *bool, out **bool, s conversion.Scope) error { + if in == nil { + boolVar := false + *out = &boolVar + return nil + } + *out = in + return nil +} + func Convert_unversioned_TypeMeta_To_unversioned_TypeMeta(in, out *unversioned.TypeMeta, s conversion.Scope) error { // These values are explicitly not copied //out.APIVersion = in.APIVersion