sigs.k8s.io/controller-runtime@v0.18.2/pkg/controller/controllertest/unconventionallisttypecrd.go (about) 1 /* 2 Copyright 2021 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 controllertest 18 19 import ( 20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 "k8s.io/apimachinery/pkg/runtime" 22 ) 23 24 var _ runtime.Object = &UnconventionalListType{} 25 var _ runtime.Object = &UnconventionalListTypeList{} 26 27 // UnconventionalListType is used to test CRDs with List types that 28 // have a slice of pointers rather than a slice of literals. 29 type UnconventionalListType struct { 30 metav1.TypeMeta `json:",inline"` 31 metav1.ObjectMeta `json:"metadata,omitempty"` 32 Spec string `json:"spec,omitempty"` 33 } 34 35 // DeepCopyObject implements runtime.Object 36 // Handwritten for simplicity. 37 func (u *UnconventionalListType) DeepCopyObject() runtime.Object { 38 return u.DeepCopy() 39 } 40 41 // DeepCopy implements *UnconventionalListType 42 // Handwritten for simplicity. 43 func (u *UnconventionalListType) DeepCopy() *UnconventionalListType { 44 return &UnconventionalListType{ 45 TypeMeta: u.TypeMeta, 46 ObjectMeta: *u.ObjectMeta.DeepCopy(), 47 Spec: u.Spec, 48 } 49 } 50 51 // UnconventionalListTypeList is used to test CRDs with List types that 52 // have a slice of pointers rather than a slice of literals. 53 type UnconventionalListTypeList struct { 54 metav1.TypeMeta `json:",inline"` 55 metav1.ListMeta `json:"metadata,omitempty"` 56 Items []*UnconventionalListType `json:"items"` 57 } 58 59 // DeepCopyObject implements runtime.Object 60 // Handwritten for simplicity. 61 func (u *UnconventionalListTypeList) DeepCopyObject() runtime.Object { 62 return u.DeepCopy() 63 } 64 65 // DeepCopy implements *UnconventionalListTypeListt 66 // Handwritten for simplicity. 67 func (u *UnconventionalListTypeList) DeepCopy() *UnconventionalListTypeList { 68 out := &UnconventionalListTypeList{ 69 TypeMeta: u.TypeMeta, 70 ListMeta: *u.ListMeta.DeepCopy(), 71 } 72 for _, item := range u.Items { 73 out.Items = append(out.Items, item.DeepCopy()) 74 } 75 return out 76 }