...

Source file src/sigs.k8s.io/controller-runtime/pkg/client/object.go

Documentation: sigs.k8s.io/controller-runtime/pkg/client

     1  /*
     2  Copyright 2020 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 client
    18  
    19  import (
    20  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    21  	"k8s.io/apimachinery/pkg/runtime"
    22  )
    23  
    24  // Object is a Kubernetes object, allows functions to work indistinctly with
    25  // any resource that implements both Object interfaces.
    26  //
    27  // Semantically, these are objects which are both serializable (runtime.Object)
    28  // and identifiable (metav1.Object) -- think any object which you could write
    29  // as YAML or JSON, and then `kubectl create`.
    30  //
    31  // Code-wise, this means that any object which embeds both ObjectMeta (which
    32  // provides metav1.Object) and TypeMeta (which provides half of runtime.Object)
    33  // and has a `DeepCopyObject` implementation (the other half of runtime.Object)
    34  // will implement this by default.
    35  //
    36  // For example, nearly all the built-in types are Objects, as well as all
    37  // KubeBuilder-generated CRDs (unless you do something real funky to them).
    38  //
    39  // By and large, most things that implement runtime.Object also implement
    40  // Object -- it's very rare to have *just* a runtime.Object implementation (the
    41  // cases tend to be funky built-in types like Webhook payloads that don't have
    42  // a `metadata` field).
    43  //
    44  // Notice that XYZList types are distinct: they implement ObjectList instead.
    45  type Object interface {
    46  	metav1.Object
    47  	runtime.Object
    48  }
    49  
    50  // ObjectList is a Kubernetes object list, allows functions to work
    51  // indistinctly with any resource that implements both runtime.Object and
    52  // metav1.ListInterface interfaces.
    53  //
    54  // Semantically, this is any object which may be serialized (ObjectMeta), and
    55  // is a kubernetes list wrapper (has items, pagination fields, etc) -- think
    56  // the wrapper used in a response from a `kubectl list --output yaml` call.
    57  //
    58  // Code-wise, this means that any object which embedds both ListMeta (which
    59  // provides metav1.ListInterface) and TypeMeta (which provides half of
    60  // runtime.Object) and has a `DeepCopyObject` implementation (the other half of
    61  // runtime.Object) will implement this by default.
    62  //
    63  // For example, nearly all the built-in XYZList types are ObjectLists, as well
    64  // as the XYZList types for all KubeBuilder-generated CRDs (unless you do
    65  // something real funky to them).
    66  //
    67  // By and large, most things that are XYZList and implement runtime.Object also
    68  // implement ObjectList -- it's very rare to have *just* a runtime.Object
    69  // implementation (the cases tend to be funky built-in types like Webhook
    70  // payloads that don't have a `metadata` field).
    71  //
    72  // This is similar to Object, which is almost always implemented by the items
    73  // in the list themselves.
    74  type ObjectList interface {
    75  	metav1.ListInterface
    76  	runtime.Object
    77  }
    78  

View as plain text