Matthias Andreas Benkard | 832a54e | 2019-01-29 09:27:38 +0100 | [diff] [blame^] | 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 internalversion |
| 18 | |
| 19 | import ( |
| 20 | "fmt" |
| 21 | |
| 22 | metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 23 | "k8s.io/apimachinery/pkg/conversion" |
| 24 | "k8s.io/apimachinery/pkg/util/validation/field" |
| 25 | ) |
| 26 | |
| 27 | func Convert_internalversion_ListOptions_To_v1_ListOptions(in *ListOptions, out *metav1.ListOptions, s conversion.Scope) error { |
| 28 | if err := metav1.Convert_fields_Selector_To_string(&in.FieldSelector, &out.FieldSelector, s); err != nil { |
| 29 | return err |
| 30 | } |
| 31 | if err := metav1.Convert_labels_Selector_To_string(&in.LabelSelector, &out.LabelSelector, s); err != nil { |
| 32 | return err |
| 33 | } |
| 34 | out.IncludeUninitialized = in.IncludeUninitialized |
| 35 | out.ResourceVersion = in.ResourceVersion |
| 36 | out.TimeoutSeconds = in.TimeoutSeconds |
| 37 | out.Watch = in.Watch |
| 38 | out.Limit = in.Limit |
| 39 | out.Continue = in.Continue |
| 40 | return nil |
| 41 | } |
| 42 | |
| 43 | func Convert_v1_ListOptions_To_internalversion_ListOptions(in *metav1.ListOptions, out *ListOptions, s conversion.Scope) error { |
| 44 | if err := metav1.Convert_string_To_fields_Selector(&in.FieldSelector, &out.FieldSelector, s); err != nil { |
| 45 | return err |
| 46 | } |
| 47 | if err := metav1.Convert_string_To_labels_Selector(&in.LabelSelector, &out.LabelSelector, s); err != nil { |
| 48 | return err |
| 49 | } |
| 50 | out.IncludeUninitialized = in.IncludeUninitialized |
| 51 | out.ResourceVersion = in.ResourceVersion |
| 52 | out.TimeoutSeconds = in.TimeoutSeconds |
| 53 | out.Watch = in.Watch |
| 54 | out.Limit = in.Limit |
| 55 | out.Continue = in.Continue |
| 56 | return nil |
| 57 | } |
| 58 | |
| 59 | func Convert_map_to_v1_LabelSelector(in *map[string]string, out *metav1.LabelSelector, s conversion.Scope) error { |
| 60 | if in == nil { |
| 61 | return nil |
| 62 | } |
| 63 | out = new(metav1.LabelSelector) |
| 64 | for labelKey, labelValue := range *in { |
| 65 | metav1.AddLabelToSelector(out, labelKey, labelValue) |
| 66 | } |
| 67 | return nil |
| 68 | } |
| 69 | |
| 70 | func Convert_v1_LabelSelector_to_map(in *metav1.LabelSelector, out *map[string]string, s conversion.Scope) error { |
| 71 | var err error |
| 72 | *out, err = metav1.LabelSelectorAsMap(in) |
| 73 | if err != nil { |
| 74 | err = field.Invalid(field.NewPath("labelSelector"), *in, fmt.Sprintf("cannot convert to old selector: %v", err)) |
| 75 | } |
| 76 | return err |
| 77 | } |