2 Copyright 2014 The Kubernetes Authors.
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
8 http://www.apache.org/licenses/LICENSE-2.0
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.
24 "k8s.io/apimachinery/pkg/api/resource"
25 "k8s.io/apimachinery/pkg/conversion"
26 "k8s.io/apimachinery/pkg/fields"
27 "k8s.io/apimachinery/pkg/labels"
28 "k8s.io/apimachinery/pkg/runtime"
29 "k8s.io/apimachinery/pkg/util/intstr"
32 func AddConversionFuncs(scheme *runtime.Scheme) error {
33 return scheme.AddConversionFuncs(
34 Convert_v1_TypeMeta_To_v1_TypeMeta,
36 Convert_v1_ListMeta_To_v1_ListMeta,
38 Convert_intstr_IntOrString_To_intstr_IntOrString,
40 Convert_Pointer_v1_Duration_To_v1_Duration,
41 Convert_v1_Duration_To_Pointer_v1_Duration,
43 Convert_Slice_string_To_v1_Time,
45 Convert_v1_Time_To_v1_Time,
46 Convert_v1_MicroTime_To_v1_MicroTime,
48 Convert_resource_Quantity_To_resource_Quantity,
50 Convert_string_To_labels_Selector,
51 Convert_labels_Selector_To_string,
53 Convert_string_To_fields_Selector,
54 Convert_fields_Selector_To_string,
56 Convert_Pointer_bool_To_bool,
57 Convert_bool_To_Pointer_bool,
59 Convert_Pointer_string_To_string,
60 Convert_string_To_Pointer_string,
62 Convert_Pointer_int64_To_int,
63 Convert_int_To_Pointer_int64,
65 Convert_Pointer_int32_To_int32,
66 Convert_int32_To_Pointer_int32,
68 Convert_Pointer_int64_To_int64,
69 Convert_int64_To_Pointer_int64,
71 Convert_Pointer_float64_To_float64,
72 Convert_float64_To_Pointer_float64,
74 Convert_Map_string_To_string_To_v1_LabelSelector,
75 Convert_v1_LabelSelector_To_Map_string_To_string,
77 Convert_Slice_string_To_Slice_int32,
79 Convert_Slice_string_To_v1_DeletionPropagation,
83 func Convert_Pointer_float64_To_float64(in **float64, out *float64, s conversion.Scope) error {
92 func Convert_float64_To_Pointer_float64(in *float64, out **float64, s conversion.Scope) error {
98 func Convert_Pointer_int32_To_int32(in **int32, out *int32, s conversion.Scope) error {
107 func Convert_int32_To_Pointer_int32(in *int32, out **int32, s conversion.Scope) error {
113 func Convert_Pointer_int64_To_int64(in **int64, out *int64, s conversion.Scope) error {
122 func Convert_int64_To_Pointer_int64(in *int64, out **int64, s conversion.Scope) error {
128 func Convert_Pointer_int64_To_int(in **int64, out *int, s conversion.Scope) error {
137 func Convert_int_To_Pointer_int64(in *int, out **int64, s conversion.Scope) error {
143 func Convert_Pointer_string_To_string(in **string, out *string, s conversion.Scope) error {
152 func Convert_string_To_Pointer_string(in *string, out **string, s conversion.Scope) error {
162 func Convert_Pointer_bool_To_bool(in **bool, out *bool, s conversion.Scope) error {
171 func Convert_bool_To_Pointer_bool(in *bool, out **bool, s conversion.Scope) error {
181 // +k8s:conversion-fn=drop
182 func Convert_v1_TypeMeta_To_v1_TypeMeta(in, out *TypeMeta, s conversion.Scope) error {
183 // These values are explicitly not copied
184 //out.APIVersion = in.APIVersion
189 // +k8s:conversion-fn=copy-only
190 func Convert_v1_ListMeta_To_v1_ListMeta(in, out *ListMeta, s conversion.Scope) error {
195 // +k8s:conversion-fn=copy-only
196 func Convert_intstr_IntOrString_To_intstr_IntOrString(in, out *intstr.IntOrString, s conversion.Scope) error {
201 // +k8s:conversion-fn=copy-only
202 func Convert_v1_Time_To_v1_Time(in *Time, out *Time, s conversion.Scope) error {
203 // Cannot deep copy these, because time.Time has unexported fields.
208 // +k8s:conversion-fn=copy-only
209 func Convert_v1_MicroTime_To_v1_MicroTime(in *MicroTime, out *MicroTime, s conversion.Scope) error {
210 // Cannot deep copy these, because time.Time has unexported fields.
215 func Convert_Pointer_v1_Duration_To_v1_Duration(in **Duration, out *Duration, s conversion.Scope) error {
217 *out = Duration{} // zero duration
224 func Convert_v1_Duration_To_Pointer_v1_Duration(in *Duration, out **Duration, s conversion.Scope) error {
230 // Convert_Slice_string_To_v1_Time allows converting a URL query parameter value
231 func Convert_Slice_string_To_v1_Time(input *[]string, out *Time, s conversion.Scope) error {
236 return out.UnmarshalQueryParameter(str)
239 func Convert_string_To_labels_Selector(in *string, out *labels.Selector, s conversion.Scope) error {
240 selector, err := labels.Parse(*in)
248 func Convert_string_To_fields_Selector(in *string, out *fields.Selector, s conversion.Scope) error {
249 selector, err := fields.ParseSelector(*in)
257 func Convert_labels_Selector_To_string(in *labels.Selector, out *string, s conversion.Scope) error {
261 *out = (*in).String()
265 func Convert_fields_Selector_To_string(in *fields.Selector, out *string, s conversion.Scope) error {
269 *out = (*in).String()
273 // +k8s:conversion-fn=copy-only
274 func Convert_resource_Quantity_To_resource_Quantity(in *resource.Quantity, out *resource.Quantity, s conversion.Scope) error {
279 func Convert_Map_string_To_string_To_v1_LabelSelector(in *map[string]string, out *LabelSelector, s conversion.Scope) error {
283 for labelKey, labelValue := range *in {
284 AddLabelToSelector(out, labelKey, labelValue)
289 func Convert_v1_LabelSelector_To_Map_string_To_string(in *LabelSelector, out *map[string]string, s conversion.Scope) error {
291 *out, err = LabelSelectorAsMap(in)
295 // Convert_Slice_string_To_Slice_int32 converts multiple query parameters or
296 // a single query parameter with a comma delimited value to multiple int32.
297 // This is used for port forwarding which needs the ports as int32.
298 func Convert_Slice_string_To_Slice_int32(in *[]string, out *[]int32, s conversion.Scope) error {
299 for _, s := range *in {
300 for _, v := range strings.Split(s, ",") {
301 x, err := strconv.ParseUint(v, 10, 16)
303 return fmt.Errorf("cannot convert to []int32: %v", err)
305 *out = append(*out, int32(x))
311 // Convert_Slice_string_To_v1_DeletionPropagation allows converting a URL query parameter propagationPolicy
312 func Convert_Slice_string_To_v1_DeletionPropagation(input *[]string, out *DeletionPropagation, s conversion.Scope) error {
314 *out = DeletionPropagation((*input)[0])