github.com/argoproj/argo-cd/v3@v3.2.1/pkg/client/clientset/versioned/fake/clientset_generated.go (about)

     1  // Code generated by client-gen. DO NOT EDIT.
     2  
     3  package fake
     4  
     5  import (
     6  	clientset "github.com/argoproj/argo-cd/v3/pkg/client/clientset/versioned"
     7  	argoprojv1alpha1 "github.com/argoproj/argo-cd/v3/pkg/client/clientset/versioned/typed/application/v1alpha1"
     8  	fakeargoprojv1alpha1 "github.com/argoproj/argo-cd/v3/pkg/client/clientset/versioned/typed/application/v1alpha1/fake"
     9  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
    10  	"k8s.io/apimachinery/pkg/runtime"
    11  	"k8s.io/apimachinery/pkg/watch"
    12  	"k8s.io/client-go/discovery"
    13  	fakediscovery "k8s.io/client-go/discovery/fake"
    14  	"k8s.io/client-go/testing"
    15  )
    16  
    17  // NewSimpleClientset returns a clientset that will respond with the provided objects.
    18  // It's backed by a very simple object tracker that processes creates, updates and deletions as-is,
    19  // without applying any field management, validations and/or defaults. It shouldn't be considered a replacement
    20  // for a real clientset and is mostly useful in simple unit tests.
    21  //
    22  // DEPRECATED: NewClientset replaces this with support for field management, which significantly improves
    23  // server side apply testing. NewClientset is only available when apply configurations are generated (e.g.
    24  // via --with-applyconfig).
    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  		var opts metav1.ListOptions
    38  		if watchActcion, ok := action.(testing.WatchActionImpl); ok {
    39  			opts = watchActcion.ListOptions
    40  		}
    41  		gvr := action.GetResource()
    42  		ns := action.GetNamespace()
    43  		watch, err := o.Watch(gvr, ns, opts)
    44  		if err != nil {
    45  			return false, nil, err
    46  		}
    47  		return true, watch, nil
    48  	})
    49  
    50  	return cs
    51  }
    52  
    53  // Clientset implements clientset.Interface. Meant to be embedded into a
    54  // struct to get a default implementation. This makes faking out just the method
    55  // you want to test easier.
    56  type Clientset struct {
    57  	testing.Fake
    58  	discovery *fakediscovery.FakeDiscovery
    59  	tracker   testing.ObjectTracker
    60  }
    61  
    62  func (c *Clientset) Discovery() discovery.DiscoveryInterface {
    63  	return c.discovery
    64  }
    65  
    66  func (c *Clientset) Tracker() testing.ObjectTracker {
    67  	return c.tracker
    68  }
    69  
    70  var (
    71  	_ clientset.Interface = &Clientset{}
    72  	_ testing.FakeClient  = &Clientset{}
    73  )
    74  
    75  // ArgoprojV1alpha1 retrieves the ArgoprojV1alpha1Client
    76  func (c *Clientset) ArgoprojV1alpha1() argoprojv1alpha1.ArgoprojV1alpha1Interface {
    77  	return &fakeargoprojv1alpha1.FakeArgoprojV1alpha1{Fake: &c.Fake}
    78  }