github.com/inspektor-gadget/inspektor-gadget@v0.28.1/pkg/client/clientset/versioned/fake/clientset_generated.go (about)

     1  // Copyright 2019-2021 The Inspektor Gadget authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // Code generated by client-gen. DO NOT EDIT.
    16  
    17  package fake
    18  
    19  import (
    20  	clientset "github.com/inspektor-gadget/inspektor-gadget/pkg/client/clientset/versioned"
    21  	gadgetv1alpha1 "github.com/inspektor-gadget/inspektor-gadget/pkg/client/clientset/versioned/typed/gadget/v1alpha1"
    22  	fakegadgetv1alpha1 "github.com/inspektor-gadget/inspektor-gadget/pkg/client/clientset/versioned/typed/gadget/v1alpha1/fake"
    23  	"k8s.io/apimachinery/pkg/runtime"
    24  	"k8s.io/apimachinery/pkg/watch"
    25  	"k8s.io/client-go/discovery"
    26  	fakediscovery "k8s.io/client-go/discovery/fake"
    27  	"k8s.io/client-go/testing"
    28  )
    29  
    30  // NewSimpleClientset returns a clientset that will respond with the provided objects.
    31  // It's backed by a very simple object tracker that processes creates, updates and deletions as-is,
    32  // without applying any validations and/or defaults. It shouldn't be considered a replacement
    33  // for a real clientset and is mostly useful in simple unit tests.
    34  func NewSimpleClientset(objects ...runtime.Object) *Clientset {
    35  	o := testing.NewObjectTracker(scheme, codecs.UniversalDecoder())
    36  	for _, obj := range objects {
    37  		if err := o.Add(obj); err != nil {
    38  			panic(err)
    39  		}
    40  	}
    41  
    42  	cs := &Clientset{tracker: o}
    43  	cs.discovery = &fakediscovery.FakeDiscovery{Fake: &cs.Fake}
    44  	cs.AddReactor("*", "*", testing.ObjectReaction(o))
    45  	cs.AddWatchReactor("*", func(action testing.Action) (handled bool, ret watch.Interface, err error) {
    46  		gvr := action.GetResource()
    47  		ns := action.GetNamespace()
    48  		watch, err := o.Watch(gvr, ns)
    49  		if err != nil {
    50  			return false, nil, err
    51  		}
    52  		return true, watch, nil
    53  	})
    54  
    55  	return cs
    56  }
    57  
    58  // Clientset implements clientset.Interface. Meant to be embedded into a
    59  // struct to get a default implementation. This makes faking out just the method
    60  // you want to test easier.
    61  type Clientset struct {
    62  	testing.Fake
    63  	discovery *fakediscovery.FakeDiscovery
    64  	tracker   testing.ObjectTracker
    65  }
    66  
    67  func (c *Clientset) Discovery() discovery.DiscoveryInterface {
    68  	return c.discovery
    69  }
    70  
    71  func (c *Clientset) Tracker() testing.ObjectTracker {
    72  	return c.tracker
    73  }
    74  
    75  var _ clientset.Interface = &Clientset{}
    76  
    77  // GadgetV1alpha1 retrieves the GadgetV1alpha1Client
    78  func (c *Clientset) GadgetV1alpha1() gadgetv1alpha1.GadgetV1alpha1Interface {
    79  	return &fakegadgetv1alpha1.FakeGadgetV1alpha1{Fake: &c.Fake}
    80  }