knative.dev/pkg@v0.0.0-20260602142205-ac97e43f6622/apis/duck/v1alpha1/legacy_targetable_types.go (about) 1 /* 2 Copyright 2018 The Knative 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 v1alpha1 18 19 import ( 20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 "k8s.io/apimachinery/pkg/runtime" 22 23 "knative.dev/pkg/apis" 24 "knative.dev/pkg/apis/duck" 25 ) 26 27 // +genduck 28 29 // LegacyTargetable left around until we migrate to Addressable in the 30 // dependent resources. Addressable has more structure in the way it 31 // defines the fields. LegacyTargetable only assumed a single string 32 // in the Status field and we're moving towards defining proper structs 33 // under Status rather than strings. 34 // This is to support existing resources until they migrate. 35 // 36 // # Do not use this for anything new, use Addressable 37 // 38 // LegacyTargetable is the old schema for the addressable portion 39 // of the payload 40 // 41 // For new resources use Addressable. 42 type LegacyTargetable struct { 43 DomainInternal string `json:"domainInternal,omitempty"` 44 } 45 46 // LegacyTargetable is an Implementable "duck type". 47 var _ duck.Implementable = (*LegacyTargetable)(nil) 48 49 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 50 51 // LegacyTarget is a skeleton type wrapping LegacyTargetable in the manner we 52 // want to support unless they get migrated into supporting Legacy. 53 // We will typically use this type to deserialize LegacyTargetable 54 // ObjectReferences and access the LegacyTargetable data. This is not a 55 // real resource. 56 // ** Do not use this for any new resources ** 57 type LegacyTarget struct { 58 metav1.TypeMeta `json:",inline"` 59 metav1.ObjectMeta `json:"metadata,omitempty"` 60 61 Status LegacyTargetable `json:"status"` 62 } 63 64 // In order for LegacyTargetable to be Implementable, LegacyTarget must be Populatable. 65 var _ duck.Populatable = (*LegacyTarget)(nil) 66 67 // Ensure LegacyTarget satisfies apis.Listable 68 var _ apis.Listable = (*LegacyTarget)(nil) 69 70 // GetFullType implements duck.Implementable 71 func (*LegacyTargetable) GetFullType() duck.Populatable { 72 return &LegacyTarget{} 73 } 74 75 // Populate implements duck.Populatable 76 func (t *LegacyTarget) Populate() { 77 t.Status = LegacyTargetable{ 78 // Populate ALL fields 79 DomainInternal: "this is not empty", 80 } 81 } 82 83 // GetListType implements apis.Listable 84 func (*LegacyTarget) GetListType() runtime.Object { 85 return &LegacyTargetList{} 86 } 87 88 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 89 90 // LegacyTargetList is a list of LegacyTarget resources 91 type LegacyTargetList struct { 92 metav1.TypeMeta `json:",inline"` 93 metav1.ListMeta `json:"metadata"` 94 95 Items []LegacyTarget `json:"items"` 96 }