knative.dev/pkg@v0.0.0-20260602142205-ac97e43f6622/apis/duck/v1alpha1/retired_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  // Targetable is an earlier version of the Callable interface.
    30  // Callable is a higher-level interface which implements Addressable
    31  // but further promises that the destination may synchronously return
    32  // response messages in reply to a message.
    33  //
    34  // Targetable implementations should instead implement Addressable and
    35  // include an `eventing.knative.dev/returns=any` annotation.
    36  //
    37  // Targetable is retired; implement Addressable for now.
    38  type Targetable struct {
    39  	DomainInternal string `json:"domainInternal,omitempty"`
    40  }
    41  
    42  // Targetable is an Implementable "duck type".
    43  var _ duck.Implementable = (*Targetable)(nil)
    44  
    45  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    46  
    47  // Target is a skeleton type wrapping Targetable in the manner we expect
    48  // resource writers defining compatible resources to embed it.  We will
    49  // typically use this type to deserialize Targetable ObjectReferences and
    50  // access the Targetable data.  This is not a real resource.
    51  type Target struct {
    52  	metav1.TypeMeta   `json:",inline"`
    53  	metav1.ObjectMeta `json:"metadata,omitempty"`
    54  
    55  	Status TargetStatus `json:"status"`
    56  }
    57  
    58  // TargetStatus shows how we expect folks to embed Targetable in
    59  // their Status field.
    60  type TargetStatus struct {
    61  	Targetable *Targetable `json:"targetable,omitempty"`
    62  }
    63  
    64  var (
    65  	// In order for Targetable to be Implementable, Target must be Populatable.
    66  	_ duck.Populatable = (*Target)(nil)
    67  
    68  	// Ensure Target satisfies apis.Listable
    69  	_ apis.Listable = (*Target)(nil)
    70  )
    71  
    72  // GetFullType implements duck.Implementable
    73  func (*Targetable) GetFullType() duck.Populatable {
    74  	return &Target{}
    75  }
    76  
    77  // Populate implements duck.Populatable
    78  func (t *Target) Populate() {
    79  	t.Status = TargetStatus{
    80  		&Targetable{
    81  			// Populate ALL fields
    82  			DomainInternal: "this is not empty",
    83  		},
    84  	}
    85  }
    86  
    87  // GetListType implements apis.Listable
    88  func (*Target) GetListType() runtime.Object {
    89  	return &TargetList{}
    90  }
    91  
    92  // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
    93  
    94  // TargetList is a list of Target resources
    95  type TargetList struct {
    96  	metav1.TypeMeta `json:",inline"`
    97  	metav1.ListMeta `json:"metadata"`
    98  
    99  	Items []Target `json:"items"`
   100  }