github.com/cilium/cilium@v1.16.2/pkg/k8s/client/clientset/versioned/fake/clientset_generated.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright Authors of Cilium
     3  
     4  // Code generated by client-gen. DO NOT EDIT.
     5  
     6  package fake
     7  
     8  import (
     9  	clientset "github.com/cilium/cilium/pkg/k8s/client/clientset/versioned"
    10  	ciliumv2 "github.com/cilium/cilium/pkg/k8s/client/clientset/versioned/typed/cilium.io/v2"
    11  	fakeciliumv2 "github.com/cilium/cilium/pkg/k8s/client/clientset/versioned/typed/cilium.io/v2/fake"
    12  	ciliumv2alpha1 "github.com/cilium/cilium/pkg/k8s/client/clientset/versioned/typed/cilium.io/v2alpha1"
    13  	fakeciliumv2alpha1 "github.com/cilium/cilium/pkg/k8s/client/clientset/versioned/typed/cilium.io/v2alpha1/fake"
    14  	"k8s.io/apimachinery/pkg/runtime"
    15  	"k8s.io/apimachinery/pkg/watch"
    16  	"k8s.io/client-go/discovery"
    17  	fakediscovery "k8s.io/client-go/discovery/fake"
    18  	"k8s.io/client-go/testing"
    19  )
    20  
    21  // NewSimpleClientset returns a clientset that will respond with the provided objects.
    22  // It's backed by a very simple object tracker that processes creates, updates and deletions as-is,
    23  // without applying any validations and/or defaults. It shouldn't be considered a replacement
    24  // for a real clientset and is mostly useful in simple unit tests.
    25  func NewSimpleClientset(objects ...runtime.Object) *Clientset {
    26  	o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder())
    27  	for _, obj := range objects {
    28  		if err := o.Add(obj); err != nil {
    29  			panic(err)
    30  		}
    31  	}
    32  
    33  	cs := &Clientset{tracker: o}
    34  	cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
    35  	cs.AddReactor("*", "*", testing.ObjectReaction(o))
    36  	cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
    37  		gvr := action.GetResource()
    38  		ns := action.GetNamespace()
    39  		watch, err := o.Watch(gvr, ns)
    40  		if err != nil {
    41  			return false, nil, err
    42  		}
    43  		return true, watch, nil
    44  	})
    45  
    46  	return cs
    47  }
    48  
    49  // Clientset implements clientset.Interface. Meant to be embedded into a
    50  // struct to get a default implementation. This makes faking out just the method
    51  // you want to test easier.
    52  type Clientset struct {
    53  	testing.Fake
    54  	discovery *fakediscovery.FakeDiscovery
    55  	tracker   testing.ObjectTracker
    56  }
    57  
    58  func (c *Clientset) Discovery() discovery.DiscoveryInterface {
    59  	return c.discovery
    60  }
    61  
    62  func (c *Clientset) Tracker() testing.ObjectTracker {
    63  	return c.tracker
    64  }
    65  
    66  var (
    67  	_ clientset.Interface = &Clientset{}
    68  	_ testing.FakeClient  = &Clientset{}
    69  )
    70  
    71  // CiliumV2 retrieves the CiliumV2Client
    72  func (c *Clientset) CiliumV2() ciliumv2.CiliumV2Interface {
    73  	return &fakeciliumv2.FakeCiliumV2{Fake: &c.Fake}
    74  }
    75  
    76  // CiliumV2alpha1 retrieves the CiliumV2alpha1Client
    77  func (c *Clientset) CiliumV2alpha1() ciliumv2alpha1.CiliumV2alpha1Interface {
    78  	return &fakeciliumv2alpha1.FakeCiliumV2alpha1{Fake: &c.Fake}
    79  }